@@ -68,6 +68,7 @@ fn check_region_bounds_on_impl_item<'tcx>(
68
68
let mut generics_span = None ;
69
69
let mut bounds_span = vec ! [ ] ;
70
70
let mut where_span = None ;
71
+
71
72
if let Some ( declaration_node) = tcx. hir_get_if_local ( declaration)
72
73
&& let Some ( declaration_generics) = declaration_node. generics ( )
73
74
{
@@ -83,11 +84,9 @@ fn check_region_bounds_on_impl_item<'tcx>(
83
84
}
84
85
}
85
86
}
86
- if let Some ( declaration_node) = tcx. hir_get_if_local ( declaration)
87
- && let Some ( declaration_generics) = declaration_node. generics ( )
88
- {
87
+ if let Some ( implementation_generics) = tcx. hir_get_generics ( external_impl) {
89
88
let mut impl_bounds = 0 ;
90
- for p in declaration_generics . predicates {
89
+ for p in implementation_generics . predicates {
91
90
if let hir:: WherePredicateKind :: BoundPredicate ( pred) = p. kind {
92
91
for b in pred. bounds {
93
92
if let hir:: GenericBound :: Outlives ( _) = b {
@@ -98,8 +97,8 @@ fn check_region_bounds_on_impl_item<'tcx>(
98
97
}
99
98
if impl_bounds == bounds_span. len ( ) {
100
99
bounds_span = vec ! [ ] ;
101
- } else if declaration_generics . has_where_clause_predicates {
102
- where_span = Some ( declaration_generics . where_clause_span ) ;
100
+ } else if implementation_generics . has_where_clause_predicates {
101
+ where_span = Some ( implementation_generics . where_clause_span ) ;
103
102
}
104
103
}
105
104
}
@@ -145,7 +144,8 @@ fn compare_number_of_method_arguments<'tcx>(
145
144
}
146
145
} )
147
146
} )
148
- . or_else ( || tcx. hir_span_if_local ( declaration) ) ;
147
+ . or_else ( || tcx. hir_span_if_local ( declaration) )
148
+ . unwrap_or_else ( || tcx. def_span ( declaration) ) ;
149
149
150
150
let ( _, external_impl_sig, _, _) = & tcx. hir_expect_item ( external_impl) . expect_fn ( ) ;
151
151
let pos = external_impl_number_args. saturating_sub ( 1 ) ;
@@ -171,15 +171,12 @@ fn compare_number_of_method_arguments<'tcx>(
171
171
declaration_number_args
172
172
) ;
173
173
174
- if let Some ( declaration_span) = declaration_span {
175
- err. span_label (
176
- declaration_span,
177
- format ! (
178
- "requires {}" ,
179
- potentially_plural_count( declaration_number_args, "parameter" )
180
- ) ,
181
- ) ;
182
- }
174
+ // if let Some(declaration_span) = declaration_span {
175
+ err. span_label (
176
+ declaration_span,
177
+ format ! ( "requires {}" , potentially_plural_count( declaration_number_args, "parameter" ) ) ,
178
+ ) ;
179
+ // }
183
180
184
181
err. span_label (
185
182
impl_span,
@@ -395,7 +392,11 @@ fn extract_spans_for_error_reporting<'tcx>(
395
392
declaration_args. and_then ( |mut args| args. nth ( i) ) ,
396
393
external_impl_name,
397
394
) ,
398
- _ => ( cause. span , tcx. hir_span_if_local ( declaration) , external_impl_name) ,
395
+ _ => (
396
+ cause. span ,
397
+ tcx. hir_span_if_local ( declaration) . or_else ( || Some ( tcx. def_span ( declaration) ) ) ,
398
+ external_impl_name,
399
+ ) ,
399
400
}
400
401
}
401
402
0 commit comments