@@ -103,6 +103,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
103103 None => String :: new ( ) ,
104104 } ;
105105
106+ let ty_sub_span = self . tcx ( ) . hir ( ) . span ( ty_sub. hir_id ) ;
107+ let ty_sup_span = self . tcx ( ) . hir ( ) . span ( ty_sup. hir_id ) ;
106108 let ( span_1, span_2, main_label, span_label, future_return_type) =
107109 match ( sup_is_ret_type, sub_is_ret_type) {
108110 ( None , None ) => {
@@ -117,7 +119,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
117119 format ! ( "...but data{} flows{} here" , span_label_var1, span_label_var2) ,
118120 )
119121 } ;
120- ( ty_sup . span , ty_sub . span , main_label_1, span_label_1, None )
122+ ( ty_sup_span , ty_sub_span , main_label_1, span_label_1, None )
121123 }
122124
123125 ( Some ( ret_span) , _) => {
@@ -129,7 +131,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
129131 } ;
130132
131133 (
132- ty_sub . span ,
134+ ty_sub_span ,
133135 ret_span,
134136 format ! (
135137 "this parameter and the {} are declared with different lifetimes..." ,
@@ -148,7 +150,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
148150 } ;
149151
150152 (
151- ty_sup . span ,
153+ ty_sup_span ,
152154 ret_span,
153155 format ! (
154156 "this parameter and the {} are declared with different lifetimes..." ,
@@ -167,11 +169,12 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
167169 e. span_label ( span, span_label) ;
168170
169171 if let Some ( t) = future_return_type {
172+ let t_span = self . tcx ( ) . hir ( ) . span ( t. hir_id ) ;
170173 let snip = self
171174 . tcx ( )
172175 . sess
173176 . source_map ( )
174- . span_to_snippet ( t . span )
177+ . span_to_snippet ( t_span )
175178 . ok ( )
176179 . and_then ( |s| match ( & t. kind , s. as_str ( ) ) {
177180 ( rustc_hir:: TyKind :: Tup ( & [ ] ) , "" ) => Some ( "()" . to_string ( ) ) ,
@@ -181,7 +184,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
181184 . unwrap_or ( "{unnamed_type}" . to_string ( ) ) ;
182185
183186 e. span_label (
184- t . span ,
187+ t_span ,
185188 & format ! ( "this `async fn` implicitly returns an `impl Future<Output = {}>`" , snip) ,
186189 ) ;
187190 }
0 commit comments