use rustc_hir::def_id::LocalDefId;
use rustc_middle::ty::query::Providers;
use rustc_middle::ty::{self, TyCtxt, TypeVisitable};
-use rustc_span::Span;
+use rustc_span::{Span, Symbol};
use std::collections::hash_map::Entry::{Occupied, Vacant};
let item = tcx.associated_item(def_id);
match item.kind {
ty::AssocKind::Type => {
- if item.defaultness.has_value() {
+ if item.defaultness(tcx).has_value() {
cgp::parameters_for(&tcx.type_of(def_id), true)
} else {
Vec::new()
ty::GenericParamDefKind::Type { .. } => {
let param_ty = ty::ParamTy::for_def(param);
if !input_parameters.contains(&cgp::Parameter::from(param_ty)) {
- report_unused_parameter(
- tcx,
- tcx.def_span(param.def_id),
- "type",
- ¶m_ty.to_string(),
- );
+ report_unused_parameter(tcx, tcx.def_span(param.def_id), "type", param_ty.name);
}
}
ty::GenericParamDefKind::Lifetime => {
tcx,
tcx.def_span(param.def_id),
"lifetime",
- ¶m.name.to_string(),
+ param.name,
);
}
}
tcx,
tcx.def_span(param.def_id),
"const",
- ¶m_ct.to_string(),
+ param_ct.name,
);
}
}
// used elsewhere are not projected back out.
}
-fn report_unused_parameter(tcx: TyCtxt<'_>, span: Span, kind: &str, name: &str) {
+fn report_unused_parameter(tcx: TyCtxt<'_>, span: Span, kind: &str, name: Symbol) {
let mut err = struct_span_err!(
tcx.sess,
span,