@@ -494,13 +494,6 @@ impl<'a> ModuleData<'a> {
494494 }
495495 }
496496
497- fn def_kind ( & self ) -> Option < DefKind > {
498- match self . kind {
499- ModuleKind :: Def ( kind, ..) => Some ( kind) ,
500- _ => None ,
501- }
502- }
503-
504497 fn def_id ( & self ) -> Option < DefId > {
505498 match self . kind {
506499 ModuleKind :: Def ( _, def_id, _) => Some ( def_id) ,
@@ -745,14 +738,6 @@ impl<'a> NameBinding<'a> {
745738 self . res ( ) . macro_kind ( )
746739 }
747740
748- fn descr ( & self ) -> & ' static str {
749- if self . is_extern_crate ( ) { "extern crate" } else { self . res ( ) . descr ( ) }
750- }
751-
752- fn article ( & self ) -> & ' static str {
753- if self . is_extern_crate ( ) { "an" } else { self . res ( ) . article ( ) }
754- }
755-
756741 // Suppose that we resolved macro invocation with `invoc_parent_expansion` to binding `binding`
757742 // at some expansion round `max(invoc, binding)` when they both emerged from macros.
758743 // Then this function returns `true` if `self` may emerge from a macro *after* that
@@ -2200,6 +2185,7 @@ impl<'a> Resolver<'a> {
22002185 }
22012186
22022187 fn binding_description ( & self , b : & NameBinding < ' _ > , ident : Ident , from_prelude : bool ) -> String {
2188+ let res = b. res ( ) ;
22032189 if b. span . is_dummy ( ) {
22042190 let add_built_in = match b. res ( ) {
22052191 // These already contain the "built-in" prefix or look bad with it.
@@ -2217,13 +2203,13 @@ impl<'a> Resolver<'a> {
22172203 ( "" , "" )
22182204 } ;
22192205
2220- let article = if built_in. is_empty ( ) { b . article ( ) } else { "a" } ;
2206+ let article = if built_in. is_empty ( ) { res . article ( ) } else { "a" } ;
22212207 format ! ( "{a}{built_in} {thing}{from}" ,
2222- a = article, thing = b . descr( ) , built_in = built_in, from = from)
2208+ a = article, thing = res . descr( ) , built_in = built_in, from = from)
22232209 } else {
22242210 let introduced = if b. is_import ( ) { "imported" } else { "defined" } ;
22252211 format ! ( "the {thing} {introduced} here" ,
2226- thing = b . descr( ) , introduced = introduced)
2212+ thing = res . descr( ) , introduced = introduced)
22272213 }
22282214 }
22292215
@@ -2246,6 +2232,7 @@ impl<'a> Resolver<'a> {
22462232 let note_msg = format ! ( "`{ident}` could{also} refer to {what}" ,
22472233 ident = ident, also = also, what = what) ;
22482234
2235+ let thing = b. res ( ) . descr ( ) ;
22492236 let mut help_msgs = Vec :: new ( ) ;
22502237 if b. is_glob_import ( ) && ( kind == AmbiguityKind :: GlobVsGlob ||
22512238 kind == AmbiguityKind :: GlobVsExpanded ||
@@ -2257,18 +2244,18 @@ impl<'a> Resolver<'a> {
22572244 if b. is_extern_crate ( ) && ident. span . rust_2018 ( ) {
22582245 help_msgs. push ( format ! (
22592246 "use `::{ident}` to refer to this {thing} unambiguously" ,
2260- ident = ident, thing = b . descr ( ) ,
2247+ ident = ident, thing = thing ,
22612248 ) )
22622249 }
22632250 if misc == AmbiguityErrorMisc :: SuggestCrate {
22642251 help_msgs. push ( format ! (
22652252 "use `crate::{ident}` to refer to this {thing} unambiguously" ,
2266- ident = ident, thing = b . descr ( ) ,
2253+ ident = ident, thing = thing ,
22672254 ) )
22682255 } else if misc == AmbiguityErrorMisc :: SuggestSelf {
22692256 help_msgs. push ( format ! (
22702257 "use `self::{ident}` to refer to this {thing} unambiguously" ,
2271- ident = ident, thing = b . descr ( ) ,
2258+ ident = ident, thing = thing ,
22722259 ) )
22732260 }
22742261
@@ -2310,7 +2297,7 @@ impl<'a> Resolver<'a> {
23102297 ident. span,
23112298 E0603 ,
23122299 "{} `{}` is private" ,
2313- binding. descr( ) ,
2300+ binding. res ( ) . descr( ) ,
23142301 ident. name,
23152302 ) ;
23162303 // FIXME: use the ctor's `def_id` to check wether any of the fields is not visible
0 commit comments