diff options
| author | lcnr <rust@lcnr.de> | 2024-05-02 15:44:05 +0000 |
|---|---|---|
| committer | lcnr <rust@lcnr.de> | 2024-05-02 15:44:05 +0000 |
| commit | c4e882fd993d575d65e841da02161263c0ff2d16 (patch) | |
| tree | c49538af77086f9702c3ecae390d755d4f03be76 /compiler/rustc_trait_selection/src/solve | |
| parent | 80451a485b006bd32732c003a54ee7de457d8266 (diff) | |
shallow resolve in orphan check
Diffstat (limited to 'compiler/rustc_trait_selection/src/solve')
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/assembly/mod.rs | 12 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs | 12 |
2 files changed, 16 insertions, 8 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/assembly/mod.rs b/compiler/rustc_trait_selection/src/solve/assembly/mod.rs index b082b0bd4c8..280975f63bd 100644 --- a/compiler/rustc_trait_selection/src/solve/assembly/mod.rs +++ b/compiler/rustc_trait_selection/src/solve/assembly/mod.rs @@ -2,7 +2,6 @@ use crate::solve::GoalSource; use crate::solve::{inspect, EvalCtxt, SolverMode}; -use crate::traits::coherence; use rustc_hir::def_id::DefId; use rustc_infer::traits::query::NoSolution; use rustc_middle::traits::solve::inspect::ProbeKind; @@ -769,13 +768,10 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { candidates.extend(self.probe_trait_candidate(CandidateSource::CoherenceUnknowable).enter( |ecx| { let trait_ref = goal.predicate.trait_ref(tcx); - let lazily_normalize_ty = |ty| ecx.structurally_normalize_ty(goal.param_env, ty); - - match coherence::trait_ref_is_knowable(tcx, trait_ref, lazily_normalize_ty)? { - Ok(()) => Err(NoSolution), - Err(_) => { - ecx.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS) - } + if ecx.trait_ref_is_knowable(goal.param_env, trait_ref)? { + Err(NoSolution) + } else { + ecx.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS) } }, )) diff --git a/compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs b/compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs index 8425d68ab59..1710746ae50 100644 --- a/compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs +++ b/compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs @@ -27,6 +27,7 @@ use rustc_span::DUMMY_SP; use std::io::Write; use std::ops::ControlFlow; +use crate::traits::coherence; use crate::traits::vtable::{count_own_vtable_entries, prepare_vtable_segments, VtblSegment}; use super::inspect::ProofTreeBuilder; @@ -942,6 +943,17 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { } } + pub(super) fn trait_ref_is_knowable( + &mut self, + param_env: ty::ParamEnv<'tcx>, + trait_ref: ty::TraitRef<'tcx>, + ) -> Result<bool, NoSolution> { + let infcx = self.infcx; + let lazily_normalize_ty = |ty| self.structurally_normalize_ty(param_env, ty); + coherence::trait_ref_is_knowable(infcx, trait_ref, lazily_normalize_ty) + .map(|is_knowable| is_knowable.is_ok()) + } + pub(super) fn can_define_opaque_ty(&self, def_id: impl Into<DefId>) -> bool { self.infcx.can_define_opaque_ty(def_id) } |
