diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 09f76552279..6ca18ae1847 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -3613,10 +3613,10 @@ impl<'a> LoweringContext<'a> { hir::LoopSource::Loop, ) }), - ExprKind::Catch(ref body) => { + ExprKind::TryBlock(ref body) => { self.with_catch_scope(body.id, |this| { let unstable_span = - this.allow_internal_unstable(CompilerDesugaringKind::Catch, body.span); + this.allow_internal_unstable(CompilerDesugaringKind::TryBlock, body.span); let mut block = this.lower_block(body, true).into_inner(); let tail = block.expr.take().map_or_else( || { diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index d086d3bd28d..cb90d2d1277 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -412,7 +412,7 @@ impl_stable_hash_for!(enum ::syntax_pos::hygiene::CompilerDesugaringKind { QuestionMark, ExistentialReturnType, ForLoop, - Catch + TryBlock }); impl_stable_hash_for!(enum ::syntax_pos::FileName { diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index e53f3ea9036..0f2afde8f9e 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -987,7 +987,7 @@ impl Expr { ExprKind::Match(..) => ExprPrecedence::Match, ExprKind::Closure(..) => ExprPrecedence::Closure, ExprKind::Block(..) => ExprPrecedence::Block, - ExprKind::Catch(..) => ExprPrecedence::Catch, + ExprKind::TryBlock(..) => ExprPrecedence::TryBlock, ExprKind::Async(..) => ExprPrecedence::Async, ExprKind::Assign(..) => ExprPrecedence::Assign, ExprKind::AssignOp(..) => ExprPrecedence::AssignOp, @@ -1108,8 +1108,8 @@ pub enum ExprKind { /// created during lowering cannot be made the parent of any other /// preexisting defs. Async(CaptureBy, NodeId, P), - /// A catch block (`catch { ... }`) - Catch(P), + /// A try block (`try { ... }`) + TryBlock(P), /// An assignment (`a = foo()`) Assign(P, P), diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index e8245a553eb..32769130940 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -1734,7 +1734,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { e.span, "yield syntax is experimental"); } - ast::ExprKind::Catch(_) => { + ast::ExprKind::TryBlock(_) => { gate_feature_post!(&self, catch_expr, e.span, "`catch` expression is experimental"); } ast::ExprKind::IfLet(ref pats, ..) | ast::ExprKind::WhileLet(ref pats, ..) => { diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 3209939d9b1..632dd5c3309 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -1351,7 +1351,7 @@ pub fn noop_fold_expr(Expr {id, node, span, attrs}: Expr, folder: &mu } ExprKind::Yield(ex) => ExprKind::Yield(ex.map(|x| folder.fold_expr(x))), ExprKind::Try(ex) => ExprKind::Try(folder.fold_expr(ex)), - ExprKind::Catch(body) => ExprKind::Catch(folder.fold_block(body)), + ExprKind::TryBlock(body) => ExprKind::TryBlock(folder.fold_block(body)), }, id: folder.new_id(id), span: folder.new_span(span), diff --git a/src/libsyntax/parse/classify.rs b/src/libsyntax/parse/classify.rs index 531483e7de1..99f9d0511fe 100644 --- a/src/libsyntax/parse/classify.rs +++ b/src/libsyntax/parse/classify.rs @@ -31,7 +31,7 @@ pub fn expr_requires_semi_to_be_stmt(e: &ast::Expr) -> bool { ast::ExprKind::WhileLet(..) | ast::ExprKind::Loop(..) | ast::ExprKind::ForLoop(..) | - ast::ExprKind::Catch(..) => false, + ast::ExprKind::TryBlock(..) => false, _ => true, } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 345464c6664..fdb9f80b7c6 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3458,7 +3458,7 @@ impl<'a> Parser<'a> { { let (iattrs, body) = self.parse_inner_attrs_and_block()?; attrs.extend(iattrs); - Ok(self.mk_expr(span_lo.to(body.span), ExprKind::Catch(body), attrs)) + Ok(self.mk_expr(span_lo.to(body.span), ExprKind::TryBlock(body), attrs)) } // `match` token already eaten diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 54ce06f61ef..f8d01fee950 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2379,7 +2379,7 @@ impl<'a> State<'a> { self.print_expr_maybe_paren(e, parser::PREC_POSTFIX)?; self.s.word("?")? } - ast::ExprKind::Catch(ref blk) => { + ast::ExprKind::TryBlock(ref blk) => { self.head("do catch")?; self.s.space()?; self.print_block_with_attrs(blk, attrs)? diff --git a/src/libsyntax/util/parser.rs b/src/libsyntax/util/parser.rs index 67bc6f947b5..6866806cd7c 100644 --- a/src/libsyntax/util/parser.rs +++ b/src/libsyntax/util/parser.rs @@ -273,7 +273,7 @@ pub enum ExprPrecedence { Loop, Match, Block, - Catch, + TryBlock, Struct, Async, } @@ -332,7 +332,7 @@ impl ExprPrecedence { ExprPrecedence::Loop | ExprPrecedence::Match | ExprPrecedence::Block | - ExprPrecedence::Catch | + ExprPrecedence::TryBlock | ExprPrecedence::Async | ExprPrecedence::Struct => PREC_PAREN, } diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 51be129737e..e57d692faae 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -809,7 +809,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) { ExprKind::Try(ref subexpression) => { visitor.visit_expr(subexpression) } - ExprKind::Catch(ref body) => { + ExprKind::TryBlock(ref body) => { visitor.visit_block(body) } } diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs index 670fd5b872d..56901917450 100644 --- a/src/libsyntax_pos/hygiene.rs +++ b/src/libsyntax_pos/hygiene.rs @@ -595,7 +595,7 @@ impl ExpnFormat { #[derive(Clone, Copy, Hash, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)] pub enum CompilerDesugaringKind { QuestionMark, - Catch, + TryBlock, /// Desugaring of an `impl Trait` in return type position /// to an `existential type Foo: Trait;` + replacing the /// `impl Trait` with `Foo`. @@ -609,7 +609,7 @@ impl CompilerDesugaringKind { Symbol::intern(match self { CompilerDesugaringKind::Async => "async", CompilerDesugaringKind::QuestionMark => "?", - CompilerDesugaringKind::Catch => "do catch", + CompilerDesugaringKind::TryBlock => "do catch", CompilerDesugaringKind::ExistentialReturnType => "existential type", CompilerDesugaringKind::ForLoop => "for loop", })