@@ -20,7 +20,6 @@ use rustc_middle::span_bug;
2020use rustc_session:: errors:: report_lit_error;
2121use rustc_span:: source_map:: { respan, Spanned } ;
2222use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
23- use rustc_span:: DUMMY_SP ;
2423use rustc_span:: { DesugaringKind , Span } ;
2524use thin_vec:: { thin_vec, ThinVec } ;
2625
@@ -190,7 +189,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
190189 MatchKind :: Postfix => hir:: MatchSource :: Postfix ,
191190 } ,
192191 ) ,
193- ExprKind :: Await ( expr, await_kw_span) => self . lower_expr_await ( * await_kw_span, expr) ,
192+ ExprKind :: Await ( expr, await_kw_span) => {
193+ self . lower_expr_await ( * await_kw_span, e. span , expr)
194+ }
194195 ExprKind :: Closure ( box Closure {
195196 binder,
196197 capture_clause,
@@ -256,9 +257,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
256257 ExprKind :: Field ( el, ident) => {
257258 hir:: ExprKind :: Field ( self . lower_expr ( el) , self . lower_ident ( * ident) )
258259 }
259- ExprKind :: Index ( el, er, brackets_span) => {
260- hir:: ExprKind :: Index ( self . lower_expr ( el) , self . lower_expr ( er) , * brackets_span)
261- }
260+ ExprKind :: Index ( el, er, brackets_span) => hir:: ExprKind :: Index (
261+ self . lower_expr ( el) ,
262+ self . lower_expr ( er) ,
263+ self . lower_span ( * brackets_span) ,
264+ ) ,
262265 ExprKind :: Range ( Some ( e1) , Some ( e2) , RangeLimits :: Closed ) => {
263266 self . lower_expr_range_closed ( e. span , e1, e2)
264267 }
@@ -400,7 +403,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
400403 let last_segment = path. segments . last_mut ( ) . unwrap ( ) ;
401404 assert ! ( last_segment. args. is_none( ) ) ;
402405 last_segment. args = Some ( AstP ( GenericArgs :: AngleBracketed ( AngleBracketedArgs {
403- span : DUMMY_SP ,
406+ span : last_segment . span ( ) . shrink_to_hi ( ) ,
404407 args : generic_args,
405408 } ) ) ) ;
406409
@@ -747,20 +750,24 @@ impl<'hir> LoweringContext<'_, 'hir> {
747750 /// }
748751 /// }
749752 /// ```
750- fn lower_expr_await ( & mut self , await_kw_span : Span , expr : & Expr ) -> hir:: ExprKind < ' hir > {
753+ fn lower_expr_await (
754+ & mut self ,
755+ await_kw_span : Span ,
756+ full_span : Span ,
757+ expr : & Expr ,
758+ ) -> hir:: ExprKind < ' hir > {
751759 let expr = self . arena . alloc ( self . lower_expr_mut ( expr) ) ;
752- self . make_lowered_await ( await_kw_span, expr, FutureKind :: Future )
760+ self . make_lowered_await ( await_kw_span, full_span , expr, FutureKind :: Future )
753761 }
754762
755763 /// Takes an expr that has already been lowered and generates a desugared await loop around it
756764 fn make_lowered_await (
757765 & mut self ,
758766 await_kw_span : Span ,
767+ full_span : Span ,
759768 expr : & ' hir hir:: Expr < ' hir > ,
760769 await_kind : FutureKind ,
761770 ) -> hir:: ExprKind < ' hir > {
762- let full_span = expr. span . to ( await_kw_span) ;
763-
764771 let is_async_gen = match self . coroutine_kind {
765772 Some ( hir:: CoroutineKind :: Desugared ( hir:: CoroutineDesugaring :: Async , _) ) => false ,
766773 Some ( hir:: CoroutineKind :: Desugared ( hir:: CoroutineDesugaring :: AsyncGen , _) ) => true ,
@@ -1692,7 +1699,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
16921699 ) ) ;
16931700 // `unsafe { ... }`
16941701 let iter = self . arena . alloc ( self . expr_unsafe ( iter) ) ;
1695- let kind = self . make_lowered_await ( head_span, iter, FutureKind :: AsyncIterator ) ;
1702+ let kind = self . make_lowered_await (
1703+ head_span,
1704+ head_span,
1705+ iter,
1706+ FutureKind :: AsyncIterator ,
1707+ ) ;
16961708 self . arena . alloc ( hir:: Expr { hir_id : self . next_id ( ) , kind, span : head_span } )
16971709 }
16981710 } ;
@@ -1998,6 +2010,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
19982010 }
19992011
20002012 pub ( super ) fn expr_str ( & mut self , sp : Span , value : Symbol ) -> hir:: Expr < ' hir > {
2013+ let sp = self . lower_span ( sp) ;
20012014 let lit = self
20022015 . arena
20032016 . alloc ( hir:: Lit { span : sp, node : ast:: LitKind :: Str ( value, ast:: StrStyle :: Cooked ) } ) ;
@@ -2052,7 +2065,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
20522065 lang_item : hir:: LangItem ,
20532066 name : Symbol ,
20542067 ) -> hir:: Expr < ' hir > {
2055- let qpath = self . make_lang_item_qpath ( lang_item, self . lower_span ( span) ) ;
2068+ let span = self . lower_span ( span) ;
2069+ let qpath = self . make_lang_item_qpath ( lang_item, span) ;
20562070 let path = hir:: ExprKind :: Path ( hir:: QPath :: TypeRelative (
20572071 self . arena . alloc ( self . ty ( span, hir:: TyKind :: Path ( qpath) ) ) ,
20582072 self . arena . alloc ( hir:: PathSegment :: new (
0 commit comments