@@ -68,6 +68,7 @@ fn check_region_bounds_on_impl_item<'tcx>(
6868 let mut generics_span = None ;
6969 let mut bounds_span = vec ! [ ] ;
7070 let mut where_span = None ;
71+
7172 if let Some ( declaration_node) = tcx. hir_get_if_local ( declaration)
7273 && let Some ( declaration_generics) = declaration_node. generics ( )
7374 {
@@ -83,11 +84,9 @@ fn check_region_bounds_on_impl_item<'tcx>(
8384 }
8485 }
8586 }
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) {
8988 let mut impl_bounds = 0 ;
90- for p in declaration_generics . predicates {
89+ for p in implementation_generics . predicates {
9190 if let hir:: WherePredicateKind :: BoundPredicate ( pred) = p. kind {
9291 for b in pred. bounds {
9392 if let hir:: GenericBound :: Outlives ( _) = b {
@@ -98,8 +97,8 @@ fn check_region_bounds_on_impl_item<'tcx>(
9897 }
9998 if impl_bounds == bounds_span. len ( ) {
10099 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 ) ;
103102 }
104103 }
105104 }
@@ -145,7 +144,8 @@ fn compare_number_of_method_arguments<'tcx>(
145144 }
146145 } )
147146 } )
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) ) ;
149149
150150 let ( _, external_impl_sig, _, _) = & tcx. hir_expect_item ( external_impl) . expect_fn ( ) ;
151151 let pos = external_impl_number_args. saturating_sub ( 1 ) ;
@@ -171,15 +171,12 @@ fn compare_number_of_method_arguments<'tcx>(
171171 declaration_number_args
172172 ) ;
173173
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+ // }
183180
184181 err. span_label (
185182 impl_span,
@@ -395,7 +392,11 @@ fn extract_spans_for_error_reporting<'tcx>(
395392 declaration_args. and_then ( |mut args| args. nth ( i) ) ,
396393 external_impl_name,
397394 ) ,
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+ ) ,
399400 }
400401}
401402
0 commit comments