Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_trait_selection/src/traits/query/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ impl<'a, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'a, 'tcx> {
// See note in `rustc_trait_selection::traits::project` about why we
// wait to fold the args.
let res = match data.kind {
ty::Opaque { .. } => {
ty::Opaque { def_id } => {
// Only normalize `impl Trait` outside of type inference, usually in codegen.
match self.infcx.typing_mode() {
TypingMode::Coherence
Expand All @@ -236,7 +236,7 @@ impl<'a, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'a, 'tcx> {
return Ok(Ty::new_error(self.cx(), guar));
}

let generic_ty = self.cx().type_of(data.kind.def_id());
let generic_ty = self.cx().type_of(def_id);
let mut concrete_ty = generic_ty.instantiate(self.cx(), args);
self.anon_depth += 1;
if concrete_ty == ty {
Expand Down
18 changes: 9 additions & 9 deletions compiler/rustc_ty_utils/src/opaque_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,14 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {

#[instrument(level = "debug", skip(self))]
fn visit_opaque_ty(&mut self, alias_ty: ty::AliasTy<'tcx>) {
if !self.seen.insert(alias_ty.kind.def_id().expect_local()) {
let ty::Opaque { def_id } = alias_ty.kind else { bug!("{alias_ty:?}") };

if !self.seen.insert(def_id.expect_local()) {
return;
}

// TAITs outside their defining scopes are ignored.
match self.tcx.local_opaque_ty_origin(alias_ty.kind.def_id().expect_local()) {
match self.tcx.local_opaque_ty_origin(def_id.expect_local()) {
rustc_hir::OpaqueTyOrigin::FnReturn { .. }
| rustc_hir::OpaqueTyOrigin::AsyncFn { .. } => {}
rustc_hir::OpaqueTyOrigin::TyAlias { in_assoc_ty, .. } => match self.mode {
Expand All @@ -122,9 +124,9 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
}

trace!(?alias_ty, "adding");
self.opaques.push(alias_ty.kind.def_id().expect_local());
self.opaques.push(def_id.expect_local());

let parent_count = self.tcx.generics_of(alias_ty.kind.def_id()).parent_count;
let parent_count = self.tcx.generics_of(def_id).parent_count;
// Only check that the parent generics of the TAIT/RPIT are unique.
// the args owned by the opaque are going to always be duplicate
// lifetime params for RPITs, and empty for TAITs.
Expand All @@ -140,9 +142,7 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
// Collect opaque types nested within the associated type bounds of this opaque type.
// We use identity args here, because we already know that the opaque type uses
// only generic parameters, and thus instantiating would not give us more information.
for (pred, span) in
self.tcx.explicit_item_bounds(alias_ty.kind.def_id()).iter_identity_copied()
{
for (pred, span) in self.tcx.explicit_item_bounds(def_id).iter_identity_copied() {
trace!(?pred);
self.visit_spanned(span, pred);
}
Expand All @@ -151,14 +151,14 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
self.tcx.dcx().emit_err(NotParam {
arg,
span: self.span(),
opaque_span: self.tcx.def_span(alias_ty.kind.def_id()),
opaque_span: self.tcx.def_span(def_id),
});
}
Err(NotUniqueParam::DuplicateParam(arg)) => {
self.tcx.dcx().emit_err(DuplicateArg {
arg,
span: self.span(),
opaque_span: self.tcx.def_span(alias_ty.kind.def_id()),
opaque_span: self.tcx.def_span(def_id),
});
}
}
Expand Down
Loading