Auto merge of #93095 - Aaron1011:remove-assoc-ident, r=cjgillot
Store a `Symbol` instead of an `Ident` in `AssocItem` This is the same idea as #92533, but for `AssocItem` instead of `VariantDef`/`FieldDef`. With this change, we no longer have any uses of `#[stable_hasher(project(...))]`
This commit is contained in:
commit
8cdb3cd94e
28 changed files with 100 additions and 92 deletions
|
@ -1353,6 +1353,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
|||
.map(|id| (trait_assoc_item, id))
|
||||
})
|
||||
.and_then(|(trait_assoc_item, id)| {
|
||||
let trait_assoc_ident = trait_assoc_item.ident(self.tcx);
|
||||
self.tcx.find_map_relevant_impl(
|
||||
id,
|
||||
proj.projection_ty.self_ty(),
|
||||
|
@ -1360,7 +1361,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
|||
self.tcx
|
||||
.associated_items(did)
|
||||
.in_definition_order()
|
||||
.filter(|assoc| assoc.ident == trait_assoc_item.ident)
|
||||
.filter(|assoc| assoc.ident(self.tcx) == trait_assoc_ident)
|
||||
.next()
|
||||
},
|
||||
)
|
||||
|
|
|
@ -1367,7 +1367,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
err.span_suggestion(
|
||||
span,
|
||||
"use the fully qualified path to an implementation",
|
||||
format!("<Type as {}>::{}", self.tcx.def_path_str(trait_ref), assoc_item.ident),
|
||||
format!("<Type as {}>::{}", self.tcx.def_path_str(trait_ref), assoc_item.name),
|
||||
Applicability::HasPlaceholders,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ fn object_safety_violations_for_trait(
|
|||
.filter(|item| item.kind == ty::AssocKind::Fn)
|
||||
.filter_map(|item| {
|
||||
object_safety_violation_for_method(tcx, trait_def_id, &item)
|
||||
.map(|(code, span)| ObjectSafetyViolation::Method(item.ident.name, code, span))
|
||||
.map(|(code, span)| ObjectSafetyViolation::Method(item.name, code, span))
|
||||
})
|
||||
.filter(|violation| {
|
||||
if let ObjectSafetyViolation::Method(
|
||||
|
@ -125,7 +125,10 @@ fn object_safety_violations_for_trait(
|
|||
tcx.associated_items(trait_def_id)
|
||||
.in_definition_order()
|
||||
.filter(|item| item.kind == ty::AssocKind::Const)
|
||||
.map(|item| ObjectSafetyViolation::AssocConst(item.ident.name, item.ident.span)),
|
||||
.map(|item| {
|
||||
let ident = item.ident(tcx);
|
||||
ObjectSafetyViolation::AssocConst(ident.name, ident.span)
|
||||
}),
|
||||
);
|
||||
|
||||
violations.extend(
|
||||
|
@ -133,7 +136,10 @@ fn object_safety_violations_for_trait(
|
|||
.in_definition_order()
|
||||
.filter(|item| item.kind == ty::AssocKind::Type)
|
||||
.filter(|item| !tcx.generics_of(item.def_id).params.is_empty())
|
||||
.map(|item| ObjectSafetyViolation::GAT(item.ident.name, item.ident.span)),
|
||||
.map(|item| {
|
||||
let ident = item.ident(tcx);
|
||||
ObjectSafetyViolation::GAT(ident.name, ident.span)
|
||||
}),
|
||||
);
|
||||
|
||||
debug!(
|
||||
|
@ -367,15 +373,15 @@ fn object_safety_violation_for_method(
|
|||
(MethodViolationCode::ReferencesSelfInput(arg), Some(node)) => node
|
||||
.fn_decl()
|
||||
.and_then(|decl| decl.inputs.get(arg + 1))
|
||||
.map_or(method.ident.span, |arg| arg.span),
|
||||
.map_or(method.ident(tcx).span, |arg| arg.span),
|
||||
(MethodViolationCode::UndispatchableReceiver, Some(node)) => node
|
||||
.fn_decl()
|
||||
.and_then(|decl| decl.inputs.get(0))
|
||||
.map_or(method.ident.span, |arg| arg.span),
|
||||
.map_or(method.ident(tcx).span, |arg| arg.span),
|
||||
(MethodViolationCode::ReferencesSelfOutput, Some(node)) => {
|
||||
node.fn_decl().map_or(method.ident.span, |decl| decl.output.span())
|
||||
node.fn_decl().map_or(method.ident(tcx).span, |decl| decl.output.span())
|
||||
}
|
||||
_ => method.ident.span,
|
||||
_ => method.ident(tcx).span,
|
||||
};
|
||||
(v, span)
|
||||
})
|
||||
|
@ -404,10 +410,10 @@ fn virtual_call_violation_for_method<'tcx>(
|
|||
);
|
||||
// Get the span pointing at where the `self` receiver should be.
|
||||
let sm = tcx.sess.source_map();
|
||||
let self_span = method.ident.span.to(tcx
|
||||
let self_span = method.ident(tcx).span.to(tcx
|
||||
.hir()
|
||||
.span_if_local(method.def_id)
|
||||
.unwrap_or_else(|| sm.next_point(method.ident.span))
|
||||
.unwrap_or_else(|| sm.next_point(method.ident(tcx).span))
|
||||
.shrink_to_hi());
|
||||
let self_span = sm.span_through_char(self_span, '(').shrink_to_hi();
|
||||
return Some(MethodViolationCode::StaticMethod(
|
||||
|
|
|
@ -1600,7 +1600,7 @@ fn confirm_generator_candidate<'cx, 'tcx>(
|
|||
gen_sig,
|
||||
)
|
||||
.map_bound(|(trait_ref, yield_ty, return_ty)| {
|
||||
let name = tcx.associated_item(obligation.predicate.item_def_id).ident.name;
|
||||
let name = tcx.associated_item(obligation.predicate.item_def_id).name;
|
||||
let ty = if name == sym::Return {
|
||||
return_ty
|
||||
} else if name == sym::Yield {
|
||||
|
@ -1842,7 +1842,7 @@ fn confirm_impl_candidate<'cx, 'tcx>(
|
|||
// just return Error.
|
||||
debug!(
|
||||
"confirm_impl_candidate: no associated type {:?} for {:?}",
|
||||
assoc_ty.item.ident, obligation.predicate
|
||||
assoc_ty.item.name, obligation.predicate
|
||||
);
|
||||
return Progress { ty: tcx.ty_error(), obligations: nested };
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue