Skip to content

Commit

Permalink
Rename Res::kind_name to Res::descr for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed May 4, 2019
1 parent 917a0fb commit 85ddd1d
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/librustc/hir/def.rs
Expand Up @@ -370,7 +370,7 @@ impl<Id> Res<Id> {
}

/// 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 {
Res::Def(kind, _) => kind.descr(),
Res::SelfCtor(..) => "self constructor",
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/hair/pattern/check_match.rs
Expand Up @@ -286,7 +286,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> {
PatKind::Path(hir::QPath::Resolved(None, ref path))
if path.segments.len() == 1 && path.segments[0].args.is_none() => {
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),
};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_resolve/diagnostics.rs
Expand Up @@ -41,7 +41,7 @@ impl<'a> Resolver<'a> {
let item_str = path.last().unwrap().ident;
let code = source.error_code(res.is_some());
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),
span)
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_resolve/lib.rs
Expand Up @@ -1532,7 +1532,7 @@ impl<'a> NameBinding<'a> {
}

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 {
Expand Down Expand Up @@ -3868,7 +3868,7 @@ impl<'a> Resolver<'a> {
"`{}` is {} {}, not a module",
ident,
res.article(),
res.kind_name(),
res.descr(),
);

return PathResult::Failed {
Expand Down Expand Up @@ -4220,7 +4220,7 @@ impl<'a> Resolver<'a> {
names.push(TypoSuggestion {
candidate: ident.name,
article: binding.res().article(),
kind: binding.res().kind_name(),
kind: binding.res().descr(),
});
}
}
Expand All @@ -4238,7 +4238,7 @@ impl<'a> Resolver<'a> {
names.push(TypoSuggestion {
candidate: ident.name,
article: res.article(),
kind: res.kind_name(),
kind: res.descr(),
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_resolve/macros.rs
Expand Up @@ -333,7 +333,7 @@ impl<'a> Resolver<'a> {
// Not only attributes, but anything in macro namespace can result in
// `Res::NonMacroAttr` definition (e.g., `inline!()`), so we must report
// 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);
return Err(Determinacy::Determined);
}
Expand Down Expand Up @@ -913,7 +913,7 @@ impl<'a> Resolver<'a> {
// (which is a best effort error recovery tool, basically), so we can't
// promise their resolution won't change later.
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);
} else {
span_bug!(span, "inconsistent resolution for a macro");
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_typeck/check/_match.rs
Expand Up @@ -884,7 +884,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
};
let report_unexpected_res = |res: Res| {
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)));
struct_span_err!(tcx.sess, pat.span, E0164, "{}", msg)
.span_label(pat.span, "not a tuple variant or struct").emit();
Expand Down Expand Up @@ -947,7 +947,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
let fields_ending = if variant.fields.len() == 1 { "" } else { "s" };
struct_span_err!(tcx.sess, pat.span, E0023,
"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)
.span_label(pat.span, format!("expected {} field{}, found {}",
variant.fields.len(), fields_ending, subpats.len()))
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/mod.rs
Expand Up @@ -1902,7 +1902,7 @@ fn report_unexpected_variant_res<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
qpath: &QPath) {
span_err!(tcx.sess, span, E0533,
"expected unit struct/variant or constant, found {} `{}`",
res.kind_name(),
res.descr(),
hir::print::to_string(tcx.hir(), |s| s.print_qpath(qpath, false)));
}

Expand Down
10 changes: 5 additions & 5 deletions src/librustdoc/passes/collect_intra_doc_links.rs
Expand Up @@ -513,18 +513,18 @@ fn ambiguity_error(
msg += &format!(
"both {} {} and {} {}",
first_def.article(),
first_def.kind_name(),
first_def.descr(),
second_def.article(),
second_def.kind_name(),
second_def.descr(),
);
}
_ => {
let mut candidates = candidates.iter().peekable();
while let Some((res, _)) = candidates.next() {
if candidates.peek().is_some() {
msg += &format!("{} {}, ", res.article(), res.kind_name());
msg += &format!("{} {}, ", res.article(), res.descr());
} else {
msg += &format!("and {} {}", res.article(), res.kind_name());
msg += &format!("and {} {}", res.article(), res.descr());
}
}
}
Expand Down Expand Up @@ -575,7 +575,7 @@ fn ambiguity_error(

diag.span_suggestion(
sp,
&format!("to link to the {}, {}", res.kind_name(), action),
&format!("to link to the {}, {}", res.descr(), action),
suggestion,
Applicability::MaybeIncorrect,
);
Expand Down

0 comments on commit 85ddd1d

Please sign in to comment.