Rollup merge of #121744 - oli-obk:eager_opaque_checks2, r=lcnr
Stop using Bubble in coherence and instead emulate it with an intercrate check r? `````@compiler-errors````` This change is kinda funny, because all I've done is reimplement `Bubble` behaviour for coherence without using `Bubble` explicitly.
This commit is contained in:
commit
e2e8405345
@ -101,6 +101,15 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||||||
let process = |a: Ty<'tcx>, b: Ty<'tcx>| match *a.kind() {
|
let process = |a: Ty<'tcx>, b: Ty<'tcx>| match *a.kind() {
|
||||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) if def_id.is_local() => {
|
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) if def_id.is_local() => {
|
||||||
let def_id = def_id.expect_local();
|
let def_id = def_id.expect_local();
|
||||||
|
if self.intercrate {
|
||||||
|
// See comment on `insert_hidden_type` for why this is sufficient in coherence
|
||||||
|
return Some(self.register_hidden_type(
|
||||||
|
OpaqueTypeKey { def_id, args },
|
||||||
|
cause.clone(),
|
||||||
|
param_env,
|
||||||
|
b,
|
||||||
|
));
|
||||||
|
}
|
||||||
match self.defining_use_anchor {
|
match self.defining_use_anchor {
|
||||||
DefiningAnchor::Bind(_) => {
|
DefiningAnchor::Bind(_) => {
|
||||||
// Check that this is `impl Trait` type is
|
// Check that this is `impl Trait` type is
|
||||||
@ -142,8 +151,10 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
DefiningAnchor::Bubble => {}
|
DefiningAnchor::Bubble => {}
|
||||||
DefiningAnchor::Error => return None,
|
DefiningAnchor::Error => {
|
||||||
};
|
return None;
|
||||||
|
}
|
||||||
|
}
|
||||||
if let ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }) = *b.kind() {
|
if let ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }) = *b.kind() {
|
||||||
// We could accept this, but there are various ways to handle this situation, and we don't
|
// We could accept this, but there are various ways to handle this situation, and we don't
|
||||||
// want to make a decision on it right now. Likely this case is so super rare anyway, that
|
// want to make a decision on it right now. Likely this case is so super rare anyway, that
|
||||||
|
@ -26,7 +26,6 @@ use rustc_infer::traits::{util, FulfillmentErrorCode, TraitEngine, TraitEngineEx
|
|||||||
use rustc_middle::traits::query::NoSolution;
|
use rustc_middle::traits::query::NoSolution;
|
||||||
use rustc_middle::traits::solve::{CandidateSource, Certainty, Goal};
|
use rustc_middle::traits::solve::{CandidateSource, Certainty, Goal};
|
||||||
use rustc_middle::traits::specialization_graph::OverlapMode;
|
use rustc_middle::traits::specialization_graph::OverlapMode;
|
||||||
use rustc_middle::traits::DefiningAnchor;
|
|
||||||
use rustc_middle::ty::fast_reject::{DeepRejectCtxt, TreatParams};
|
use rustc_middle::ty::fast_reject::{DeepRejectCtxt, TreatParams};
|
||||||
use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt};
|
use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt};
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor};
|
use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor};
|
||||||
@ -207,7 +206,6 @@ fn overlap<'tcx>(
|
|||||||
|
|
||||||
let infcx = tcx
|
let infcx = tcx
|
||||||
.infer_ctxt()
|
.infer_ctxt()
|
||||||
.with_opaque_type_inference(DefiningAnchor::Bubble)
|
|
||||||
.skip_leak_check(skip_leak_check.is_yes())
|
.skip_leak_check(skip_leak_check.is_yes())
|
||||||
.intercrate(true)
|
.intercrate(true)
|
||||||
.with_next_trait_solver(tcx.next_trait_solver_in_coherence())
|
.with_next_trait_solver(tcx.next_trait_solver_in_coherence())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user