Skip to content

Commit

Permalink
partially revert acba644
Browse files Browse the repository at this point in the history
This avoids the ICE in `tests/ui/type-alias-impl-trait/reveal_local.rs`.
  • Loading branch information
lqd committed Nov 5, 2024
1 parent d17ae64 commit 39592bc
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2362,17 +2362,18 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
}

ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => {
if self.infcx.can_define_opaque_ty(def_id) {
unreachable!()
} else {
// We can resolve the `impl Trait` to its concrete type,
// which enforces a DAG between the functions requiring
// the auto trait bounds in question.
match self.tcx().type_of_opaque(def_id) {
Ok(ty) => t.rebind(vec![ty.instantiate(self.tcx(), args)]),
Err(_) => {
return Err(SelectionError::OpaqueTypeAutoTraitLeakageUnknown(def_id));
}
// FIXME(new-solver): because we're still using the global cache
// when defining opaque types, we can reach here, but shouldn't.
// The test `type-alias-impl-trait/reveal_local.rs` is an
// example.

// We can resolve the `impl Trait` to its concrete type,
// which enforces a DAG between the functions requiring
// the auto trait bounds in question.
match self.tcx().type_of_opaque(def_id) {
Ok(ty) => t.rebind(vec![ty.instantiate(self.tcx(), args)]),
Err(_) => {
return Err(SelectionError::OpaqueTypeAutoTraitLeakageUnknown(def_id));
}
}
}
Expand Down

0 comments on commit 39592bc

Please sign in to comment.