@@ -494,13 +494,6 @@ impl<'a> ModuleData<'a> {
494
494
}
495
495
}
496
496
497
- fn def_kind ( & self ) -> Option < DefKind > {
498
- match self . kind {
499
- ModuleKind :: Def ( kind, ..) => Some ( kind) ,
500
- _ => None ,
501
- }
502
- }
503
-
504
497
fn def_id ( & self ) -> Option < DefId > {
505
498
match self . kind {
506
499
ModuleKind :: Def ( _, def_id, _) => Some ( def_id) ,
@@ -745,14 +738,6 @@ impl<'a> NameBinding<'a> {
745
738
self . res ( ) . macro_kind ( )
746
739
}
747
740
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
-
756
741
// Suppose that we resolved macro invocation with `invoc_parent_expansion` to binding `binding`
757
742
// at some expansion round `max(invoc, binding)` when they both emerged from macros.
758
743
// Then this function returns `true` if `self` may emerge from a macro *after* that
@@ -2200,6 +2185,7 @@ impl<'a> Resolver<'a> {
2200
2185
}
2201
2186
2202
2187
fn binding_description ( & self , b : & NameBinding < ' _ > , ident : Ident , from_prelude : bool ) -> String {
2188
+ let res = b. res ( ) ;
2203
2189
if b. span . is_dummy ( ) {
2204
2190
let add_built_in = match b. res ( ) {
2205
2191
// These already contain the "built-in" prefix or look bad with it.
@@ -2217,13 +2203,13 @@ impl<'a> Resolver<'a> {
2217
2203
( "" , "" )
2218
2204
} ;
2219
2205
2220
- let article = if built_in. is_empty ( ) { b . article ( ) } else { "a" } ;
2206
+ let article = if built_in. is_empty ( ) { res . article ( ) } else { "a" } ;
2221
2207
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)
2223
2209
} else {
2224
2210
let introduced = if b. is_import ( ) { "imported" } else { "defined" } ;
2225
2211
format ! ( "the {thing} {introduced} here" ,
2226
- thing = b . descr( ) , introduced = introduced)
2212
+ thing = res . descr( ) , introduced = introduced)
2227
2213
}
2228
2214
}
2229
2215
@@ -2246,6 +2232,7 @@ impl<'a> Resolver<'a> {
2246
2232
let note_msg = format ! ( "`{ident}` could{also} refer to {what}" ,
2247
2233
ident = ident, also = also, what = what) ;
2248
2234
2235
+ let thing = b. res ( ) . descr ( ) ;
2249
2236
let mut help_msgs = Vec :: new ( ) ;
2250
2237
if b. is_glob_import ( ) && ( kind == AmbiguityKind :: GlobVsGlob ||
2251
2238
kind == AmbiguityKind :: GlobVsExpanded ||
@@ -2257,18 +2244,18 @@ impl<'a> Resolver<'a> {
2257
2244
if b. is_extern_crate ( ) && ident. span . rust_2018 ( ) {
2258
2245
help_msgs. push ( format ! (
2259
2246
"use `::{ident}` to refer to this {thing} unambiguously" ,
2260
- ident = ident, thing = b . descr ( ) ,
2247
+ ident = ident, thing = thing ,
2261
2248
) )
2262
2249
}
2263
2250
if misc == AmbiguityErrorMisc :: SuggestCrate {
2264
2251
help_msgs. push ( format ! (
2265
2252
"use `crate::{ident}` to refer to this {thing} unambiguously" ,
2266
- ident = ident, thing = b . descr ( ) ,
2253
+ ident = ident, thing = thing ,
2267
2254
) )
2268
2255
} else if misc == AmbiguityErrorMisc :: SuggestSelf {
2269
2256
help_msgs. push ( format ! (
2270
2257
"use `self::{ident}` to refer to this {thing} unambiguously" ,
2271
- ident = ident, thing = b . descr ( ) ,
2258
+ ident = ident, thing = thing ,
2272
2259
) )
2273
2260
}
2274
2261
@@ -2310,7 +2297,7 @@ impl<'a> Resolver<'a> {
2310
2297
ident. span,
2311
2298
E0603 ,
2312
2299
"{} `{}` is private" ,
2313
- binding. descr( ) ,
2300
+ binding. res ( ) . descr( ) ,
2314
2301
ident. name,
2315
2302
) ;
2316
2303
// FIXME: use the ctor's `def_id` to check wether any of the fields is not visible
0 commit comments