Skip to content

Commit 85ddd1d

Browse files
committed
Rename Res::kind_name to Res::descr for consistency
1 parent 917a0fb commit 85ddd1d

File tree

8 files changed

+17
-17
lines changed

8 files changed

+17
-17
lines changed

src/librustc/hir/def.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ impl<Id> Res<Id> {
370370
}
371371

372372
/// A human readable name for the res kind ("function", "module", etc.).
373-
pub fn kind_name(&self) -> &'static str {
373+
pub fn descr(&self) -> &'static str {
374374
match *self {
375375
Res::Def(kind, _) => kind.descr(),
376376
Res::SelfCtor(..) => "self constructor",

src/librustc_mir/hair/pattern/check_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> {
286286
PatKind::Path(hir::QPath::Resolved(None, ref path))
287287
if path.segments.len() == 1 && path.segments[0].args.is_none() => {
288288
format!("interpreted as {} {} pattern, not new variable",
289-
path.res.article(), path.res.kind_name())
289+
path.res.article(), path.res.descr())
290290
}
291291
_ => format!("pattern `{}` not covered", pattern_string),
292292
};

src/librustc_resolve/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl<'a> Resolver<'a> {
4141
let item_str = path.last().unwrap().ident;
4242
let code = source.error_code(res.is_some());
4343
let (base_msg, fallback_label, base_span) = if let Some(res) = res {
44-
(format!("expected {}, found {} `{}`", expected, res.kind_name(), path_str),
44+
(format!("expected {}, found {} `{}`", expected, res.descr(), path_str),
4545
format!("not a {}", expected),
4646
span)
4747
} else {

src/librustc_resolve/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,7 @@ impl<'a> NameBinding<'a> {
15321532
}
15331533

15341534
fn descr(&self) -> &'static str {
1535-
if self.is_extern_crate() { "extern crate" } else { self.res().kind_name() }
1535+
if self.is_extern_crate() { "extern crate" } else { self.res().descr() }
15361536
}
15371537

15381538
fn article(&self) -> &'static str {
@@ -3868,7 +3868,7 @@ impl<'a> Resolver<'a> {
38683868
"`{}` is {} {}, not a module",
38693869
ident,
38703870
res.article(),
3871-
res.kind_name(),
3871+
res.descr(),
38723872
);
38733873

38743874
return PathResult::Failed {
@@ -4220,7 +4220,7 @@ impl<'a> Resolver<'a> {
42204220
names.push(TypoSuggestion {
42214221
candidate: ident.name,
42224222
article: binding.res().article(),
4223-
kind: binding.res().kind_name(),
4223+
kind: binding.res().descr(),
42244224
});
42254225
}
42264226
}
@@ -4238,7 +4238,7 @@ impl<'a> Resolver<'a> {
42384238
names.push(TypoSuggestion {
42394239
candidate: ident.name,
42404240
article: res.article(),
4241-
kind: res.kind_name(),
4241+
kind: res.descr(),
42424242
});
42434243
}
42444244
}

src/librustc_resolve/macros.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ impl<'a> Resolver<'a> {
333333
// Not only attributes, but anything in macro namespace can result in
334334
// `Res::NonMacroAttr` definition (e.g., `inline!()`), so we must report
335335
// an error for those cases.
336-
let msg = format!("expected a macro, found {}", res.kind_name());
336+
let msg = format!("expected a macro, found {}", res.descr());
337337
self.session.span_err(path.span, &msg);
338338
return Err(Determinacy::Determined);
339339
}
@@ -913,7 +913,7 @@ impl<'a> Resolver<'a> {
913913
// (which is a best effort error recovery tool, basically), so we can't
914914
// promise their resolution won't change later.
915915
let msg = format!("inconsistent resolution for a macro: first {}, then {}",
916-
initial_res.kind_name(), res.kind_name());
916+
initial_res.descr(), res.descr());
917917
this.session.span_err(span, &msg);
918918
} else {
919919
span_bug!(span, "inconsistent resolution for a macro");

src/librustc_typeck/check/_match.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
884884
};
885885
let report_unexpected_res = |res: Res| {
886886
let msg = format!("expected tuple struct/variant, found {} `{}`",
887-
res.kind_name(),
887+
res.descr(),
888888
hir::print::to_string(tcx.hir(), |s| s.print_qpath(qpath, false)));
889889
struct_span_err!(tcx.sess, pat.span, E0164, "{}", msg)
890890
.span_label(pat.span, "not a tuple variant or struct").emit();
@@ -947,7 +947,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
947947
let fields_ending = if variant.fields.len() == 1 { "" } else { "s" };
948948
struct_span_err!(tcx.sess, pat.span, E0023,
949949
"this pattern has {} field{}, but the corresponding {} has {} field{}",
950-
subpats.len(), subpats_ending, res.kind_name(),
950+
subpats.len(), subpats_ending, res.descr(),
951951
variant.fields.len(), fields_ending)
952952
.span_label(pat.span, format!("expected {} field{}, found {}",
953953
variant.fields.len(), fields_ending, subpats.len()))

src/librustc_typeck/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1902,7 +1902,7 @@ fn report_unexpected_variant_res<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
19021902
qpath: &QPath) {
19031903
span_err!(tcx.sess, span, E0533,
19041904
"expected unit struct/variant or constant, found {} `{}`",
1905-
res.kind_name(),
1905+
res.descr(),
19061906
hir::print::to_string(tcx.hir(), |s| s.print_qpath(qpath, false)));
19071907
}
19081908

src/librustdoc/passes/collect_intra_doc_links.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -513,18 +513,18 @@ fn ambiguity_error(
513513
msg += &format!(
514514
"both {} {} and {} {}",
515515
first_def.article(),
516-
first_def.kind_name(),
516+
first_def.descr(),
517517
second_def.article(),
518-
second_def.kind_name(),
518+
second_def.descr(),
519519
);
520520
}
521521
_ => {
522522
let mut candidates = candidates.iter().peekable();
523523
while let Some((res, _)) = candidates.next() {
524524
if candidates.peek().is_some() {
525-
msg += &format!("{} {}, ", res.article(), res.kind_name());
525+
msg += &format!("{} {}, ", res.article(), res.descr());
526526
} else {
527-
msg += &format!("and {} {}", res.article(), res.kind_name());
527+
msg += &format!("and {} {}", res.article(), res.descr());
528528
}
529529
}
530530
}
@@ -575,7 +575,7 @@ fn ambiguity_error(
575575

576576
diag.span_suggestion(
577577
sp,
578-
&format!("to link to the {}, {}", res.kind_name(), action),
578+
&format!("to link to the {}, {}", res.descr(), action),
579579
suggestion,
580580
Applicability::MaybeIncorrect,
581581
);

0 commit comments

Comments
 (0)