@@ -443,11 +443,12 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver<'_>,
443443 err
444444 }
445445 ResolutionError :: BindingShadowsSomethingUnacceptable ( what_binding, name, binding) => {
446- let shadows_what = binding. descr ( ) ;
446+ let res = binding. res ( ) ;
447+ let shadows_what = res. descr ( ) ;
447448 let mut err = struct_span_err ! ( resolver. session, span, E0530 , "{}s cannot shadow {}s" ,
448449 what_binding, shadows_what) ;
449450 err. span_label ( span, format ! ( "cannot be named the same as {} {}" ,
450- binding . article( ) , shadows_what) ) ;
451+ res . article( ) , shadows_what) ) ;
451452 let participle = if binding. is_import ( ) { "imported" } else { "defined" } ;
452453 let msg = format ! ( "the {} `{}` is {} here" , shadows_what, name, participle) ;
453454 err. span_label ( binding. span , msg) ;
@@ -1242,13 +1243,6 @@ impl<'a> ModuleData<'a> {
12421243 }
12431244 }
12441245
1245- fn def_kind ( & self ) -> Option < DefKind > {
1246- match self . kind {
1247- ModuleKind :: Def ( kind, ..) => Some ( kind) ,
1248- _ => None ,
1249- }
1250- }
1251-
12521246 fn def_id ( & self ) -> Option < DefId > {
12531247 match self . kind {
12541248 ModuleKind :: Def ( _, def_id, _) => Some ( def_id) ,
@@ -1493,14 +1487,6 @@ impl<'a> NameBinding<'a> {
14931487 self . res ( ) . macro_kind ( )
14941488 }
14951489
1496- fn descr ( & self ) -> & ' static str {
1497- if self . is_extern_crate ( ) { "extern crate" } else { self . res ( ) . descr ( ) }
1498- }
1499-
1500- fn article ( & self ) -> & ' static str {
1501- if self . is_extern_crate ( ) { "an" } else { self . res ( ) . article ( ) }
1502- }
1503-
15041490 // Suppose that we resolved macro invocation with `invoc_parent_expansion` to binding `binding`
15051491 // at some expansion round `max(invoc, binding)` when they both emerged from macros.
15061492 // Then this function returns `true` if `self` may emerge from a macro *after* that
@@ -4691,6 +4677,7 @@ impl<'a> Resolver<'a> {
46914677 }
46924678
46934679 fn binding_description ( & self , b : & NameBinding < ' _ > , ident : Ident , from_prelude : bool ) -> String {
4680+ let res = b. res ( ) ;
46944681 if b. span . is_dummy ( ) {
46954682 let add_built_in = match b. res ( ) {
46964683 // These already contain the "built-in" prefix or look bad with it.
@@ -4708,13 +4695,13 @@ impl<'a> Resolver<'a> {
47084695 ( "" , "" )
47094696 } ;
47104697
4711- let article = if built_in. is_empty ( ) { b . article ( ) } else { "a" } ;
4698+ let article = if built_in. is_empty ( ) { res . article ( ) } else { "a" } ;
47124699 format ! ( "{a}{built_in} {thing}{from}" ,
4713- a = article, thing = b . descr( ) , built_in = built_in, from = from)
4700+ a = article, thing = res . descr( ) , built_in = built_in, from = from)
47144701 } else {
47154702 let introduced = if b. is_import ( ) { "imported" } else { "defined" } ;
47164703 format ! ( "the {thing} {introduced} here" ,
4717- thing = b . descr( ) , introduced = introduced)
4704+ thing = res . descr( ) , introduced = introduced)
47184705 }
47194706 }
47204707
@@ -4737,6 +4724,7 @@ impl<'a> Resolver<'a> {
47374724 let note_msg = format ! ( "`{ident}` could{also} refer to {what}" ,
47384725 ident = ident, also = also, what = what) ;
47394726
4727+ let thing = b. res ( ) . descr ( ) ;
47404728 let mut help_msgs = Vec :: new ( ) ;
47414729 if b. is_glob_import ( ) && ( kind == AmbiguityKind :: GlobVsGlob ||
47424730 kind == AmbiguityKind :: GlobVsExpanded ||
@@ -4748,18 +4736,18 @@ impl<'a> Resolver<'a> {
47484736 if b. is_extern_crate ( ) && ident. span . rust_2018 ( ) {
47494737 help_msgs. push ( format ! (
47504738 "use `::{ident}` to refer to this {thing} unambiguously" ,
4751- ident = ident, thing = b . descr ( ) ,
4739+ ident = ident, thing = thing ,
47524740 ) )
47534741 }
47544742 if misc == AmbiguityErrorMisc :: SuggestCrate {
47554743 help_msgs. push ( format ! (
47564744 "use `crate::{ident}` to refer to this {thing} unambiguously" ,
4757- ident = ident, thing = b . descr ( ) ,
4745+ ident = ident, thing = thing ,
47584746 ) )
47594747 } else if misc == AmbiguityErrorMisc :: SuggestSelf {
47604748 help_msgs. push ( format ! (
47614749 "use `self::{ident}` to refer to this {thing} unambiguously" ,
4762- ident = ident, thing = b . descr ( ) ,
4750+ ident = ident, thing = thing ,
47634751 ) )
47644752 }
47654753
@@ -4797,7 +4785,7 @@ impl<'a> Resolver<'a> {
47974785 for & PrivacyError ( dedup_span, ident, binding) in & self . privacy_errors {
47984786 if reported_spans. insert ( dedup_span) {
47994787 span_err ! ( self . session, ident. span, E0603 , "{} `{}` is private" ,
4800- binding. descr( ) , ident. name) ;
4788+ binding. res ( ) . descr( ) , ident. name) ;
48014789 }
48024790 }
48034791 }
0 commit comments