Split impl_(opt_)trait_ref
This commit is contained in:
parent
ae8ff943c1
commit
e60e9f0826
41 changed files with 95 additions and 111 deletions
|
|
@ -46,7 +46,7 @@ fn assumed_wf_types<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx [(Ty<'
|
|||
// Trait arguments and the self type for trait impls or only the self type for
|
||||
// inherent impls.
|
||||
let tys = if of_trait {
|
||||
let trait_ref = tcx.impl_trait_ref(def_id).unwrap();
|
||||
let trait_ref = tcx.impl_trait_ref(def_id);
|
||||
trait_ref.skip_binder().args.types().collect()
|
||||
} else {
|
||||
vec![tcx.type_of(def_id).instantiate_identity()]
|
||||
|
|
@ -113,7 +113,7 @@ fn assumed_wf_types<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx [(Ty<'
|
|||
let args = ty::GenericArgs::identity_for_item(tcx, def_id).rebase_onto(
|
||||
tcx,
|
||||
impl_def_id.to_def_id(),
|
||||
tcx.impl_trait_ref(impl_def_id).unwrap().instantiate_identity().args,
|
||||
tcx.impl_trait_ref(impl_def_id).instantiate_identity().args,
|
||||
);
|
||||
tcx.arena.alloc_from_iter(
|
||||
ty::EarlyBinder::bind(tcx.assumed_wf_types_for_rpitit(rpitit_def_id))
|
||||
|
|
|
|||
|
|
@ -219,8 +219,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector<'tcx> {
|
|||
// supporting the case of a method defining opaque types from assoc types
|
||||
// in the same impl block.
|
||||
if let Some(parent) = self.tcx.trait_impl_of_assoc(self.item.to_def_id()) {
|
||||
let impl_trait_ref =
|
||||
self.tcx.impl_trait_ref(parent).unwrap().instantiate_identity();
|
||||
let impl_trait_ref = self.tcx.impl_trait_ref(parent).instantiate_identity();
|
||||
// If the trait ref of the associated item and the impl differs,
|
||||
// then we can't use the impl's identity args below, so
|
||||
// just skip.
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ pub fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>(
|
|||
DefKind::Impl { of_trait } => {
|
||||
if of_trait {
|
||||
let span = tcx.hir_node_by_def_id(item).expect_item().expect_impl().of_trait.unwrap().trait_ref.path.span;
|
||||
let args = &tcx.impl_trait_ref(item).unwrap().instantiate_identity().args[1..];
|
||||
let args = &tcx.impl_trait_ref(item).instantiate_identity().args[1..];
|
||||
try_visit!(visitor.visit(span, args));
|
||||
}
|
||||
let span = match tcx.hir_node_by_def_id(item).ty() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue