@@ -103,6 +103,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
103
103
None => String :: new ( ) ,
104
104
} ;
105
105
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 ) ;
106
108
let ( span_1, span_2, main_label, span_label, future_return_type) =
107
109
match ( sup_is_ret_type, sub_is_ret_type) {
108
110
( None , None ) => {
@@ -117,7 +119,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
117
119
format ! ( "...but data{} flows{} here" , span_label_var1, span_label_var2) ,
118
120
)
119
121
} ;
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 )
121
123
}
122
124
123
125
( Some ( ret_span) , _) => {
@@ -129,7 +131,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
129
131
} ;
130
132
131
133
(
132
- ty_sub . span ,
134
+ ty_sub_span ,
133
135
ret_span,
134
136
format ! (
135
137
"this parameter and the {} are declared with different lifetimes..." ,
@@ -148,7 +150,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
148
150
} ;
149
151
150
152
(
151
- ty_sup . span ,
153
+ ty_sup_span ,
152
154
ret_span,
153
155
format ! (
154
156
"this parameter and the {} are declared with different lifetimes..." ,
@@ -167,11 +169,12 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
167
169
e. span_label ( span, span_label) ;
168
170
169
171
if let Some ( t) = future_return_type {
172
+ let t_span = self . tcx ( ) . hir ( ) . span ( t. hir_id ) ;
170
173
let snip = self
171
174
. tcx ( )
172
175
. sess
173
176
. source_map ( )
174
- . span_to_snippet ( t . span )
177
+ . span_to_snippet ( t_span )
175
178
. ok ( )
176
179
. and_then ( |s| match ( & t. kind , s. as_str ( ) ) {
177
180
( rustc_hir:: TyKind :: Tup ( & [ ] ) , "" ) => Some ( "()" . to_string ( ) ) ,
@@ -181,7 +184,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
181
184
. unwrap_or ( "{unnamed_type}" . to_string ( ) ) ;
182
185
183
186
e. span_label (
184
- t . span ,
187
+ t_span ,
185
188
& format ! ( "this `async fn` implicitly returns an `impl Future<Output = {}>`" , snip) ,
186
189
) ;
187
190
}
0 commit comments