@@ -553,14 +553,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
553
553
resolution_error : ResolutionError < ' a > ,
554
554
) -> DiagnosticBuilder < ' _ , ErrorGuaranteed > {
555
555
match resolution_error {
556
- ResolutionError :: GenericParamsFromOuterFunction ( outer_res, has_generic_params) => {
556
+ ResolutionError :: GenericParamsFromOuterItem ( outer_res, has_generic_params) => {
557
557
let mut err = struct_span_err ! (
558
558
self . tcx. sess,
559
559
span,
560
560
E0401 ,
561
- "can't use generic parameters from outer function " ,
561
+ "can't use generic parameters from outer item " ,
562
562
) ;
563
- err. span_label ( span, "use of generic parameter from outer function " ) ;
563
+ err. span_label ( span, "use of generic parameter from outer item " ) ;
564
564
565
565
let sm = self . tcx . sess . source_map ( ) ;
566
566
let def_id = match outer_res {
@@ -573,33 +573,28 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
573
573
reduce_impl_span_to_impl_keyword ( sm, self . def_span ( def_id) ) ,
574
574
"`Self` type implicitly declared here, by this `impl`" ,
575
575
) ;
576
- err. span_label ( span, "use a type here instead" ) ;
576
+ err. span_label ( span, "refer to the type directly here instead" ) ;
577
577
return err;
578
578
}
579
579
Res :: Def ( DefKind :: TyParam , def_id) => {
580
- err. span_label ( self . def_span ( def_id) , "type parameter from outer function " ) ;
580
+ err. span_label ( self . def_span ( def_id) , "type parameter from outer item " ) ;
581
581
def_id
582
582
}
583
583
Res :: Def ( DefKind :: ConstParam , def_id) => {
584
- err. span_label (
585
- self . def_span ( def_id) ,
586
- "const parameter from outer function" ,
587
- ) ;
584
+ err. span_label ( self . def_span ( def_id) , "const parameter from outer item" ) ;
588
585
def_id
589
586
}
590
587
_ => {
591
588
bug ! (
592
- "GenericParamsFromOuterFunction should only be used with \
589
+ "GenericParamsFromOuterItem should only be used with \
593
590
Res::SelfTyParam, Res::SelfTyAlias, DefKind::TyParam or \
594
591
DefKind::ConstParam"
595
592
) ;
596
593
}
597
594
} ;
598
595
599
596
if let HasGenericParams :: Yes ( span) = has_generic_params {
600
- // Try to retrieve the span of the function signature and generate a new
601
- // message with a local type or const parameter.
602
- let sugg_msg = "try using a local generic parameter instead" ;
597
+ let sugg_msg = "try introducing a local generic parameter here" ;
603
598
let name = self . tcx . item_name ( def_id) ;
604
599
let ( span, snippet) = if span. is_empty ( ) {
605
600
let snippet = format ! ( "<{name}>" ) ;
@@ -609,7 +604,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
609
604
let snippet = format ! ( "{name}, " ) ;
610
605
( span, snippet)
611
606
} ;
612
- // Suggest the modification to the user
613
607
err. span_suggestion ( span, sugg_msg, snippet, Applicability :: MaybeIncorrect ) ;
614
608
}
615
609
0 commit comments