diff --git a/src/librustc/hir/def.rs b/src/librustc/hir/def.rs index 6ff0c0fbb5008..87af450451e7e 100644 --- a/src/librustc/hir/def.rs +++ b/src/librustc/hir/def.rs @@ -370,7 +370,7 @@ impl Res { } /// 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", diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs index b08499b981cd7..ed183acc93b74 100644 --- a/src/librustc_mir/hair/pattern/check_match.rs +++ b/src/librustc_mir/hair/pattern/check_match.rs @@ -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), }; diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index bbfc39fc6eaf0..509aa95bb61df 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -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 { diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 131f26663c70b..88465535c2cb6 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -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 { @@ -3868,7 +3868,7 @@ impl<'a> Resolver<'a> { "`{}` is {} {}, not a module", ident, res.article(), - res.kind_name(), + res.descr(), ); return PathResult::Failed { @@ -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(), }); } } @@ -4238,7 +4238,7 @@ impl<'a> Resolver<'a> { names.push(TypoSuggestion { candidate: ident.name, article: res.article(), - kind: res.kind_name(), + kind: res.descr(), }); } } diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 18573a4594f4c..f1706a4616b06 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -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); } @@ -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"); diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 62afbc44d07b6..e9e202ce37996 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -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(); @@ -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())) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 4ae75511322b6..e404a8e6972c8 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -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))); } diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 705b222efe805..abf19a0a5efa4 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -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()); } } } @@ -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, );