@@ -20,7 +20,6 @@ use rustc_middle::span_bug;
20
20
use rustc_session:: errors:: report_lit_error;
21
21
use rustc_span:: source_map:: { respan, Spanned } ;
22
22
use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
23
- use rustc_span:: DUMMY_SP ;
24
23
use rustc_span:: { DesugaringKind , Span } ;
25
24
use thin_vec:: { thin_vec, ThinVec } ;
26
25
@@ -190,7 +189,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
190
189
MatchKind :: Postfix => hir:: MatchSource :: Postfix ,
191
190
} ,
192
191
) ,
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
+ }
194
195
ExprKind :: Closure ( box Closure {
195
196
binder,
196
197
capture_clause,
@@ -256,9 +257,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
256
257
ExprKind :: Field ( el, ident) => {
257
258
hir:: ExprKind :: Field ( self . lower_expr ( el) , self . lower_ident ( * ident) )
258
259
}
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
+ ) ,
262
265
ExprKind :: Range ( Some ( e1) , Some ( e2) , RangeLimits :: Closed ) => {
263
266
self . lower_expr_range_closed ( e. span , e1, e2)
264
267
}
@@ -400,7 +403,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
400
403
let last_segment = path. segments . last_mut ( ) . unwrap ( ) ;
401
404
assert ! ( last_segment. args. is_none( ) ) ;
402
405
last_segment. args = Some ( AstP ( GenericArgs :: AngleBracketed ( AngleBracketedArgs {
403
- span : DUMMY_SP ,
406
+ span : last_segment . span ( ) . shrink_to_hi ( ) ,
404
407
args : generic_args,
405
408
} ) ) ) ;
406
409
@@ -747,20 +750,24 @@ impl<'hir> LoweringContext<'_, 'hir> {
747
750
/// }
748
751
/// }
749
752
/// ```
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 > {
751
759
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 )
753
761
}
754
762
755
763
/// Takes an expr that has already been lowered and generates a desugared await loop around it
756
764
fn make_lowered_await (
757
765
& mut self ,
758
766
await_kw_span : Span ,
767
+ full_span : Span ,
759
768
expr : & ' hir hir:: Expr < ' hir > ,
760
769
await_kind : FutureKind ,
761
770
) -> hir:: ExprKind < ' hir > {
762
- let full_span = expr. span . to ( await_kw_span) ;
763
-
764
771
let is_async_gen = match self . coroutine_kind {
765
772
Some ( hir:: CoroutineKind :: Desugared ( hir:: CoroutineDesugaring :: Async , _) ) => false ,
766
773
Some ( hir:: CoroutineKind :: Desugared ( hir:: CoroutineDesugaring :: AsyncGen , _) ) => true ,
@@ -1692,7 +1699,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
1692
1699
) ) ;
1693
1700
// `unsafe { ... }`
1694
1701
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
+ ) ;
1696
1708
self . arena . alloc ( hir:: Expr { hir_id : self . next_id ( ) , kind, span : head_span } )
1697
1709
}
1698
1710
} ;
@@ -1998,6 +2010,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1998
2010
}
1999
2011
2000
2012
pub ( super ) fn expr_str ( & mut self , sp : Span , value : Symbol ) -> hir:: Expr < ' hir > {
2013
+ let sp = self . lower_span ( sp) ;
2001
2014
let lit = self
2002
2015
. arena
2003
2016
. alloc ( hir:: Lit { span : sp, node : ast:: LitKind :: Str ( value, ast:: StrStyle :: Cooked ) } ) ;
@@ -2052,7 +2065,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
2052
2065
lang_item : hir:: LangItem ,
2053
2066
name : Symbol ,
2054
2067
) -> 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) ;
2056
2070
let path = hir:: ExprKind :: Path ( hir:: QPath :: TypeRelative (
2057
2071
self . arena . alloc ( self . ty ( span, hir:: TyKind :: Path ( qpath) ) ) ,
2058
2072
self . arena . alloc ( hir:: PathSegment :: new (
0 commit comments