Rename Res::kind_name
to Res::descr
for consistency
This commit is contained in:
parent
917a0fbc1b
commit
85ddd1dc58
8 changed files with 17 additions and 17 deletions
|
@ -370,7 +370,7 @@ impl<Id> Res<Id> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A human readable name for the res kind ("function", "module", etc.).
|
/// A human readable name for the res kind ("function", "module", etc.).
|
||||||
pub fn kind_name(&self) -> &'static str {
|
pub fn descr(&self) -> &'static str {
|
||||||
match *self {
|
match *self {
|
||||||
Res::Def(kind, _) => kind.descr(),
|
Res::Def(kind, _) => kind.descr(),
|
||||||
Res::SelfCtor(..) => "self constructor",
|
Res::SelfCtor(..) => "self constructor",
|
||||||
|
|
|
@ -286,7 +286,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> {
|
||||||
PatKind::Path(hir::QPath::Resolved(None, ref path))
|
PatKind::Path(hir::QPath::Resolved(None, ref path))
|
||||||
if path.segments.len() == 1 && path.segments[0].args.is_none() => {
|
if path.segments.len() == 1 && path.segments[0].args.is_none() => {
|
||||||
format!("interpreted as {} {} pattern, not new variable",
|
format!("interpreted as {} {} pattern, not new variable",
|
||||||
path.res.article(), path.res.kind_name())
|
path.res.article(), path.res.descr())
|
||||||
}
|
}
|
||||||
_ => format!("pattern `{}` not covered", pattern_string),
|
_ => format!("pattern `{}` not covered", pattern_string),
|
||||||
};
|
};
|
||||||
|
|
|
@ -41,7 +41,7 @@ impl<'a> Resolver<'a> {
|
||||||
let item_str = path.last().unwrap().ident;
|
let item_str = path.last().unwrap().ident;
|
||||||
let code = source.error_code(res.is_some());
|
let code = source.error_code(res.is_some());
|
||||||
let (base_msg, fallback_label, base_span) = if let Some(res) = res {
|
let (base_msg, fallback_label, base_span) = if let Some(res) = res {
|
||||||
(format!("expected {}, found {} `{}`", expected, res.kind_name(), path_str),
|
(format!("expected {}, found {} `{}`", expected, res.descr(), path_str),
|
||||||
format!("not a {}", expected),
|
format!("not a {}", expected),
|
||||||
span)
|
span)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1532,7 +1532,7 @@ impl<'a> NameBinding<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn descr(&self) -> &'static str {
|
fn descr(&self) -> &'static str {
|
||||||
if self.is_extern_crate() { "extern crate" } else { self.res().kind_name() }
|
if self.is_extern_crate() { "extern crate" } else { self.res().descr() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn article(&self) -> &'static str {
|
fn article(&self) -> &'static str {
|
||||||
|
@ -3868,7 +3868,7 @@ impl<'a> Resolver<'a> {
|
||||||
"`{}` is {} {}, not a module",
|
"`{}` is {} {}, not a module",
|
||||||
ident,
|
ident,
|
||||||
res.article(),
|
res.article(),
|
||||||
res.kind_name(),
|
res.descr(),
|
||||||
);
|
);
|
||||||
|
|
||||||
return PathResult::Failed {
|
return PathResult::Failed {
|
||||||
|
@ -4220,7 +4220,7 @@ impl<'a> Resolver<'a> {
|
||||||
names.push(TypoSuggestion {
|
names.push(TypoSuggestion {
|
||||||
candidate: ident.name,
|
candidate: ident.name,
|
||||||
article: binding.res().article(),
|
article: binding.res().article(),
|
||||||
kind: binding.res().kind_name(),
|
kind: binding.res().descr(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4238,7 +4238,7 @@ impl<'a> Resolver<'a> {
|
||||||
names.push(TypoSuggestion {
|
names.push(TypoSuggestion {
|
||||||
candidate: ident.name,
|
candidate: ident.name,
|
||||||
article: res.article(),
|
article: res.article(),
|
||||||
kind: res.kind_name(),
|
kind: res.descr(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -333,7 +333,7 @@ impl<'a> Resolver<'a> {
|
||||||
// Not only attributes, but anything in macro namespace can result in
|
// Not only attributes, but anything in macro namespace can result in
|
||||||
// `Res::NonMacroAttr` definition (e.g., `inline!()`), so we must report
|
// `Res::NonMacroAttr` definition (e.g., `inline!()`), so we must report
|
||||||
// an error for those cases.
|
// an error for those cases.
|
||||||
let msg = format!("expected a macro, found {}", res.kind_name());
|
let msg = format!("expected a macro, found {}", res.descr());
|
||||||
self.session.span_err(path.span, &msg);
|
self.session.span_err(path.span, &msg);
|
||||||
return Err(Determinacy::Determined);
|
return Err(Determinacy::Determined);
|
||||||
}
|
}
|
||||||
|
@ -913,7 +913,7 @@ impl<'a> Resolver<'a> {
|
||||||
// (which is a best effort error recovery tool, basically), so we can't
|
// (which is a best effort error recovery tool, basically), so we can't
|
||||||
// promise their resolution won't change later.
|
// promise their resolution won't change later.
|
||||||
let msg = format!("inconsistent resolution for a macro: first {}, then {}",
|
let msg = format!("inconsistent resolution for a macro: first {}, then {}",
|
||||||
initial_res.kind_name(), res.kind_name());
|
initial_res.descr(), res.descr());
|
||||||
this.session.span_err(span, &msg);
|
this.session.span_err(span, &msg);
|
||||||
} else {
|
} else {
|
||||||
span_bug!(span, "inconsistent resolution for a macro");
|
span_bug!(span, "inconsistent resolution for a macro");
|
||||||
|
|
|
@ -884,7 +884,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
|
||||||
};
|
};
|
||||||
let report_unexpected_res = |res: Res| {
|
let report_unexpected_res = |res: Res| {
|
||||||
let msg = format!("expected tuple struct/variant, found {} `{}`",
|
let msg = format!("expected tuple struct/variant, found {} `{}`",
|
||||||
res.kind_name(),
|
res.descr(),
|
||||||
hir::print::to_string(tcx.hir(), |s| s.print_qpath(qpath, false)));
|
hir::print::to_string(tcx.hir(), |s| s.print_qpath(qpath, false)));
|
||||||
struct_span_err!(tcx.sess, pat.span, E0164, "{}", msg)
|
struct_span_err!(tcx.sess, pat.span, E0164, "{}", msg)
|
||||||
.span_label(pat.span, "not a tuple variant or struct").emit();
|
.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");
|
||||||
let fields_ending = if variant.fields.len() == 1 { "" } else { "s" };
|
let fields_ending = if variant.fields.len() == 1 { "" } else { "s" };
|
||||||
struct_span_err!(tcx.sess, pat.span, E0023,
|
struct_span_err!(tcx.sess, pat.span, E0023,
|
||||||
"this pattern has {} field{}, but the corresponding {} has {} field{}",
|
"this pattern has {} field{}, but the corresponding {} has {} field{}",
|
||||||
subpats.len(), subpats_ending, res.kind_name(),
|
subpats.len(), subpats_ending, res.descr(),
|
||||||
variant.fields.len(), fields_ending)
|
variant.fields.len(), fields_ending)
|
||||||
.span_label(pat.span, format!("expected {} field{}, found {}",
|
.span_label(pat.span, format!("expected {} field{}, found {}",
|
||||||
variant.fields.len(), fields_ending, subpats.len()))
|
variant.fields.len(), fields_ending, subpats.len()))
|
||||||
|
|
|
@ -1902,7 +1902,7 @@ fn report_unexpected_variant_res<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||||
qpath: &QPath) {
|
qpath: &QPath) {
|
||||||
span_err!(tcx.sess, span, E0533,
|
span_err!(tcx.sess, span, E0533,
|
||||||
"expected unit struct/variant or constant, found {} `{}`",
|
"expected unit struct/variant or constant, found {} `{}`",
|
||||||
res.kind_name(),
|
res.descr(),
|
||||||
hir::print::to_string(tcx.hir(), |s| s.print_qpath(qpath, false)));
|
hir::print::to_string(tcx.hir(), |s| s.print_qpath(qpath, false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -513,18 +513,18 @@ fn ambiguity_error(
|
||||||
msg += &format!(
|
msg += &format!(
|
||||||
"both {} {} and {} {}",
|
"both {} {} and {} {}",
|
||||||
first_def.article(),
|
first_def.article(),
|
||||||
first_def.kind_name(),
|
first_def.descr(),
|
||||||
second_def.article(),
|
second_def.article(),
|
||||||
second_def.kind_name(),
|
second_def.descr(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let mut candidates = candidates.iter().peekable();
|
let mut candidates = candidates.iter().peekable();
|
||||||
while let Some((res, _)) = candidates.next() {
|
while let Some((res, _)) = candidates.next() {
|
||||||
if candidates.peek().is_some() {
|
if candidates.peek().is_some() {
|
||||||
msg += &format!("{} {}, ", res.article(), res.kind_name());
|
msg += &format!("{} {}, ", res.article(), res.descr());
|
||||||
} else {
|
} else {
|
||||||
msg += &format!("and {} {}", res.article(), res.kind_name());
|
msg += &format!("and {} {}", res.article(), res.descr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -575,7 +575,7 @@ fn ambiguity_error(
|
||||||
|
|
||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
sp,
|
sp,
|
||||||
&format!("to link to the {}, {}", res.kind_name(), action),
|
&format!("to link to the {}, {}", res.descr(), action),
|
||||||
suggestion,
|
suggestion,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue