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