@@ -444,11 +444,12 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver<'_>,
444444 err
445445 }
446446 ResolutionError :: BindingShadowsSomethingUnacceptable ( what_binding, name, binding) => {
447- let shadows_what = binding. descr ( ) ;
447+ let res = binding. res ( ) ;
448+ let shadows_what = res. descr ( ) ;
448449 let mut err = struct_span_err ! ( resolver. session, span, E0530 , "{}s cannot shadow {}s" ,
449450 what_binding, shadows_what) ;
450451 err. span_label ( span, format ! ( "cannot be named the same as {} {}" ,
451- binding . article( ) , shadows_what) ) ;
452+ res . article( ) , shadows_what) ) ;
452453 let participle = if binding. is_import ( ) { "imported" } else { "defined" } ;
453454 let msg = format ! ( "the {} `{}` is {} here" , shadows_what, name, participle) ;
454455 err. span_label ( binding. span , msg) ;
@@ -1243,13 +1244,6 @@ impl<'a> ModuleData<'a> {
12431244 }
12441245 }
12451246
1246- fn def_kind ( & self ) -> Option < DefKind > {
1247- match self . kind {
1248- ModuleKind :: Def ( kind, ..) => Some ( kind) ,
1249- _ => None ,
1250- }
1251- }
1252-
12531247 fn def_id ( & self ) -> Option < DefId > {
12541248 match self . kind {
12551249 ModuleKind :: Def ( _, def_id, _) => Some ( def_id) ,
@@ -1494,14 +1488,6 @@ impl<'a> NameBinding<'a> {
14941488 self . res ( ) . macro_kind ( )
14951489 }
14961490
1497- fn descr ( & self ) -> & ' static str {
1498- if self . is_extern_crate ( ) { "extern crate" } else { self . res ( ) . descr ( ) }
1499- }
1500-
1501- fn article ( & self ) -> & ' static str {
1502- if self . is_extern_crate ( ) { "an" } else { self . res ( ) . article ( ) }
1503- }
1504-
15051491 // Suppose that we resolved macro invocation with `invoc_parent_expansion` to binding `binding`
15061492 // at some expansion round `max(invoc, binding)` when they both emerged from macros.
15071493 // Then this function returns `true` if `self` may emerge from a macro *after* that
@@ -4675,6 +4661,7 @@ impl<'a> Resolver<'a> {
46754661 }
46764662
46774663 fn binding_description ( & self , b : & NameBinding < ' _ > , ident : Ident , from_prelude : bool ) -> String {
4664+ let res = b. res ( ) ;
46784665 if b. span . is_dummy ( ) {
46794666 let add_built_in = match b. res ( ) {
46804667 // These already contain the "built-in" prefix or look bad with it.
@@ -4692,13 +4679,13 @@ impl<'a> Resolver<'a> {
46924679 ( "" , "" )
46934680 } ;
46944681
4695- let article = if built_in. is_empty ( ) { b . article ( ) } else { "a" } ;
4682+ let article = if built_in. is_empty ( ) { res . article ( ) } else { "a" } ;
46964683 format ! ( "{a}{built_in} {thing}{from}" ,
4697- a = article, thing = b . descr( ) , built_in = built_in, from = from)
4684+ a = article, thing = res . descr( ) , built_in = built_in, from = from)
46984685 } else {
46994686 let introduced = if b. is_import ( ) { "imported" } else { "defined" } ;
47004687 format ! ( "the {thing} {introduced} here" ,
4701- thing = b . descr( ) , introduced = introduced)
4688+ thing = res . descr( ) , introduced = introduced)
47024689 }
47034690 }
47044691
@@ -4721,6 +4708,7 @@ impl<'a> Resolver<'a> {
47214708 let note_msg = format ! ( "`{ident}` could{also} refer to {what}" ,
47224709 ident = ident, also = also, what = what) ;
47234710
4711+ let thing = b. res ( ) . descr ( ) ;
47244712 let mut help_msgs = Vec :: new ( ) ;
47254713 if b. is_glob_import ( ) && ( kind == AmbiguityKind :: GlobVsGlob ||
47264714 kind == AmbiguityKind :: GlobVsExpanded ||
@@ -4732,18 +4720,18 @@ impl<'a> Resolver<'a> {
47324720 if b. is_extern_crate ( ) && ident. span . rust_2018 ( ) {
47334721 help_msgs. push ( format ! (
47344722 "use `::{ident}` to refer to this {thing} unambiguously" ,
4735- ident = ident, thing = b . descr ( ) ,
4723+ ident = ident, thing = thing ,
47364724 ) )
47374725 }
47384726 if misc == AmbiguityErrorMisc :: SuggestCrate {
47394727 help_msgs. push ( format ! (
47404728 "use `crate::{ident}` to refer to this {thing} unambiguously" ,
4741- ident = ident, thing = b . descr ( ) ,
4729+ ident = ident, thing = thing ,
47424730 ) )
47434731 } else if misc == AmbiguityErrorMisc :: SuggestSelf {
47444732 help_msgs. push ( format ! (
47454733 "use `self::{ident}` to refer to this {thing} unambiguously" ,
4746- ident = ident, thing = b . descr ( ) ,
4734+ ident = ident, thing = thing ,
47474735 ) )
47484736 }
47494737
@@ -4781,7 +4769,7 @@ impl<'a> Resolver<'a> {
47814769 for & PrivacyError ( dedup_span, ident, binding) in & self . privacy_errors {
47824770 if reported_spans. insert ( dedup_span) {
47834771 span_err ! ( self . session, ident. span, E0603 , "{} `{}` is private" ,
4784- binding. descr( ) , ident. name) ;
4772+ binding. res ( ) . descr( ) , ident. name) ;
47854773 }
47864774 }
47874775 }
0 commit comments