@@ -67,6 +67,7 @@ fn check_region_bounds_on_impl_item<'tcx>(
6767 let mut generics_span = None ;
6868 let mut bounds_span = vec ! [ ] ;
6969 let mut where_span = None ;
70+
7071 if let Some ( declaration_node) = tcx. hir_get_if_local ( declaration)
7172 && let Some ( declaration_generics) = declaration_node. generics ( )
7273 {
@@ -82,11 +83,9 @@ fn check_region_bounds_on_impl_item<'tcx>(
8283 }
8384 }
8485 }
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) {
8887 let mut impl_bounds = 0 ;
89- for p in declaration_generics . predicates {
88+ for p in implementation_generics . predicates {
9089 if let hir:: WherePredicateKind :: BoundPredicate ( pred) = p. kind {
9190 for b in pred. bounds {
9291 if let hir:: GenericBound :: Outlives ( _) = b {
@@ -97,8 +96,8 @@ fn check_region_bounds_on_impl_item<'tcx>(
9796 }
9897 if impl_bounds == bounds_span. len ( ) {
9998 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 ) ;
102101 }
103102 }
104103 }
@@ -144,7 +143,8 @@ fn compare_number_of_method_arguments<'tcx>(
144143 }
145144 } )
146145 } )
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) ) ;
148148
149149 let ( _, external_impl_sig, _, _) = & tcx. hir_expect_item ( external_impl) . expect_fn ( ) ;
150150 let pos = external_impl_number_args. saturating_sub ( 1 ) ;
@@ -170,15 +170,12 @@ fn compare_number_of_method_arguments<'tcx>(
170170 declaration_number_args
171171 ) ;
172172
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+ // }
182179
183180 err. span_label (
184181 impl_span,
@@ -397,7 +394,11 @@ fn extract_spans_for_error_reporting<'tcx>(
397394 declaration_args. and_then ( |mut args| args. nth ( i) ) ,
398395 external_impl_name,
399396 ) ,
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+ ) ,
401402 }
402403}
403404
0 commit comments