From f958e6c24615c4b1f1e77b0ee3d4f32383fb3617 Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Sat, 27 Jun 2020 21:36:35 +0100 Subject: Separate bounds and predicates for associated/opaque types --- compiler/rustc_ast_lowering/src/expr.rs | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'compiler/rustc_ast_lowering/src') diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index c97f80cf09b..4676ad5c31f 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -432,17 +432,25 @@ impl<'hir> LoweringContext<'_, 'hir> { self.with_catch_scope(body.id, |this| { let mut block = this.lower_block_noalloc(body, true); - let try_span = this.mark_span_with_reason( - DesugaringKind::TryBlock, - body.span, - this.allow_try_trait.clone(), - ); - // Final expression of the block (if present) or `()` with span at the end of block - let tail_expr = block - .expr - .take() - .unwrap_or_else(|| this.expr_unit(this.sess.source_map().end_point(try_span))); + let (try_span, tail_expr) = if let Some(expr) = block.expr.take() { + ( + this.mark_span_with_reason( + DesugaringKind::TryBlock, + expr.span, + this.allow_try_trait.clone(), + ), + expr, + ) + } else { + let try_span = this.mark_span_with_reason( + DesugaringKind::TryBlock, + this.sess.source_map().end_point(body.span), + this.allow_try_trait.clone(), + ); + + (try_span, this.expr_unit(try_span)) + }; let ok_wrapped_span = this.mark_span_with_reason(DesugaringKind::TryBlock, tail_expr.span, None); @@ -1553,7 +1561,7 @@ impl<'hir> LoweringContext<'_, 'hir> { hir::LangItem::TryFromError, unstable_span, from_expr, - try_span, + unstable_span, ); let thin_attrs = ThinVec::from(attrs); let catch_scope = self.catch_scopes.last().copied(); -- cgit 1.4.1-3-g733a5