Skip to content

Commit f2445fb

Browse files
committed
Rename Catch variants to TryBlock
(Not `Try` since `QuestionMark` is using that.)
1 parent f28f648 commit f2445fb

File tree

11 files changed

+16
-16
lines changed

11 files changed

+16
-16
lines changed

src/librustc/hir/lowering.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3613,10 +3613,10 @@ impl<'a> LoweringContext<'a> {
36133613
hir::LoopSource::Loop,
36143614
)
36153615
}),
3616-
ExprKind::Catch(ref body) => {
3616+
ExprKind::TryBlock(ref body) => {
36173617
self.with_catch_scope(body.id, |this| {
36183618
let unstable_span =
3619-
this.allow_internal_unstable(CompilerDesugaringKind::Catch, body.span);
3619+
this.allow_internal_unstable(CompilerDesugaringKind::TryBlock, body.span);
36203620
let mut block = this.lower_block(body, true).into_inner();
36213621
let tail = block.expr.take().map_or_else(
36223622
|| {

src/librustc/ich/impls_syntax.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ impl_stable_hash_for!(enum ::syntax_pos::hygiene::CompilerDesugaringKind {
412412
QuestionMark,
413413
ExistentialReturnType,
414414
ForLoop,
415-
Catch
415+
TryBlock
416416
});
417417

418418
impl_stable_hash_for!(enum ::syntax_pos::FileName {

src/libsyntax/ast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ impl Expr {
987987
ExprKind::Match(..) => ExprPrecedence::Match,
988988
ExprKind::Closure(..) => ExprPrecedence::Closure,
989989
ExprKind::Block(..) => ExprPrecedence::Block,
990-
ExprKind::Catch(..) => ExprPrecedence::Catch,
990+
ExprKind::TryBlock(..) => ExprPrecedence::TryBlock,
991991
ExprKind::Async(..) => ExprPrecedence::Async,
992992
ExprKind::Assign(..) => ExprPrecedence::Assign,
993993
ExprKind::AssignOp(..) => ExprPrecedence::AssignOp,
@@ -1108,8 +1108,8 @@ pub enum ExprKind {
11081108
/// created during lowering cannot be made the parent of any other
11091109
/// preexisting defs.
11101110
Async(CaptureBy, NodeId, P<Block>),
1111-
/// A catch block (`catch { ... }`)
1112-
Catch(P<Block>),
1111+
/// A try block (`try { ... }`)
1112+
TryBlock(P<Block>),
11131113

11141114
/// An assignment (`a = foo()`)
11151115
Assign(P<Expr>, P<Expr>),

src/libsyntax/feature_gate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1734,7 +1734,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
17341734
e.span,
17351735
"yield syntax is experimental");
17361736
}
1737-
ast::ExprKind::Catch(_) => {
1737+
ast::ExprKind::TryBlock(_) => {
17381738
gate_feature_post!(&self, catch_expr, e.span, "`catch` expression is experimental");
17391739
}
17401740
ast::ExprKind::IfLet(ref pats, ..) | ast::ExprKind::WhileLet(ref pats, ..) => {

src/libsyntax/fold.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,7 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span, attrs}: Expr, folder: &mu
13511351
}
13521352
ExprKind::Yield(ex) => ExprKind::Yield(ex.map(|x| folder.fold_expr(x))),
13531353
ExprKind::Try(ex) => ExprKind::Try(folder.fold_expr(ex)),
1354-
ExprKind::Catch(body) => ExprKind::Catch(folder.fold_block(body)),
1354+
ExprKind::TryBlock(body) => ExprKind::TryBlock(folder.fold_block(body)),
13551355
},
13561356
id: folder.new_id(id),
13571357
span: folder.new_span(span),

src/libsyntax/parse/classify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub fn expr_requires_semi_to_be_stmt(e: &ast::Expr) -> bool {
3131
ast::ExprKind::WhileLet(..) |
3232
ast::ExprKind::Loop(..) |
3333
ast::ExprKind::ForLoop(..) |
34-
ast::ExprKind::Catch(..) => false,
34+
ast::ExprKind::TryBlock(..) => false,
3535
_ => true,
3636
}
3737
}

src/libsyntax/parse/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3458,7 +3458,7 @@ impl<'a> Parser<'a> {
34583458
{
34593459
let (iattrs, body) = self.parse_inner_attrs_and_block()?;
34603460
attrs.extend(iattrs);
3461-
Ok(self.mk_expr(span_lo.to(body.span), ExprKind::Catch(body), attrs))
3461+
Ok(self.mk_expr(span_lo.to(body.span), ExprKind::TryBlock(body), attrs))
34623462
}
34633463

34643464
// `match` token already eaten

src/libsyntax/print/pprust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2379,7 +2379,7 @@ impl<'a> State<'a> {
23792379
self.print_expr_maybe_paren(e, parser::PREC_POSTFIX)?;
23802380
self.s.word("?")?
23812381
}
2382-
ast::ExprKind::Catch(ref blk) => {
2382+
ast::ExprKind::TryBlock(ref blk) => {
23832383
self.head("do catch")?;
23842384
self.s.space()?;
23852385
self.print_block_with_attrs(blk, attrs)?

src/libsyntax/util/parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ pub enum ExprPrecedence {
273273
Loop,
274274
Match,
275275
Block,
276-
Catch,
276+
TryBlock,
277277
Struct,
278278
Async,
279279
}
@@ -332,7 +332,7 @@ impl ExprPrecedence {
332332
ExprPrecedence::Loop |
333333
ExprPrecedence::Match |
334334
ExprPrecedence::Block |
335-
ExprPrecedence::Catch |
335+
ExprPrecedence::TryBlock |
336336
ExprPrecedence::Async |
337337
ExprPrecedence::Struct => PREC_PAREN,
338338
}

src/libsyntax/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
809809
ExprKind::Try(ref subexpression) => {
810810
visitor.visit_expr(subexpression)
811811
}
812-
ExprKind::Catch(ref body) => {
812+
ExprKind::TryBlock(ref body) => {
813813
visitor.visit_block(body)
814814
}
815815
}

src/libsyntax_pos/hygiene.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ impl ExpnFormat {
595595
#[derive(Clone, Copy, Hash, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)]
596596
pub enum CompilerDesugaringKind {
597597
QuestionMark,
598-
Catch,
598+
TryBlock,
599599
/// Desugaring of an `impl Trait` in return type position
600600
/// to an `existential type Foo: Trait;` + replacing the
601601
/// `impl Trait` with `Foo`.
@@ -609,7 +609,7 @@ impl CompilerDesugaringKind {
609609
Symbol::intern(match self {
610610
CompilerDesugaringKind::Async => "async",
611611
CompilerDesugaringKind::QuestionMark => "?",
612-
CompilerDesugaringKind::Catch => "do catch",
612+
CompilerDesugaringKind::TryBlock => "do catch",
613613
CompilerDesugaringKind::ExistentialReturnType => "existential type",
614614
CompilerDesugaringKind::ForLoop => "for loop",
615615
})

0 commit comments

Comments
 (0)