Skip to content

Commit abfa5c1

Browse files
Deeply normalize when computing implied outlives bounds
1 parent d49be02 commit abfa5c1

File tree

3 files changed

+51
-4
lines changed

3 files changed

+51
-4
lines changed

Diff for: compiler/rustc_trait_selection/src/traits/normalize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl<'tcx> At<'_, 'tcx> {
6666
let value = self
6767
.normalize(value)
6868
.into_value_registering_obligations(self.infcx, &mut *fulfill_cx);
69-
let errors = fulfill_cx.select_where_possible(self.infcx);
69+
let errors = fulfill_cx.select_all_or_error(self.infcx);
7070
let value = self.infcx.resolve_vars_if_possible(value);
7171
if errors.is_empty() { Ok(value) } else { Err(errors) }
7272
}

Diff for: compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ pub fn compute_implied_outlives_bounds_inner<'tcx>(
5959
param_env: ty::ParamEnv<'tcx>,
6060
ty: Ty<'tcx>,
6161
) -> Result<Vec<OutlivesBound<'tcx>>, NoSolution> {
62-
let normalize_op = |ty| {
63-
let ty = ocx.normalize(&ObligationCause::dummy(), param_env, ty);
62+
let normalize_op = |ty| -> Result<_, NoSolution> {
63+
let ty = ocx
64+
.deeply_normalize(&ObligationCause::dummy(), param_env, ty)
65+
.map_err(|_| NoSolution)?;
6466
if !ocx.select_all_or_error().is_empty() {
6567
return Err(NoSolution);
6668
}
67-
let ty = ocx.infcx.resolve_vars_if_possible(ty);
6869
let ty = OpportunisticRegionResolver::new(&ocx.infcx).fold_ty(ty);
6970
Ok(ty)
7071
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//@ check-pass
2+
//@ compile-flags: -Znext-solver
3+
4+
// Minimized example from `rustc_type_ir` that demonstrates a missing deep normalization
5+
// in the new solver when computing the implies outlives bounds of an impl.
6+
7+
use std::marker::PhantomData;
8+
use std::ops::Deref;
9+
10+
pub struct SearchGraph<D: Delegate, X = <D as Delegate>::Cx> {
11+
d: PhantomData<D>,
12+
x: PhantomData<X>,
13+
}
14+
15+
pub trait Delegate {
16+
type Cx;
17+
}
18+
19+
struct SearchGraphDelegate<D: SolverDelegate> {
20+
_marker: PhantomData<D>,
21+
}
22+
23+
impl<D> Delegate for SearchGraphDelegate<D>
24+
where
25+
D: SolverDelegate,
26+
{
27+
type Cx = D::Interner;
28+
}
29+
30+
pub trait SolverDelegate {
31+
type Interner;
32+
}
33+
34+
struct EvalCtxt<'a, D, I>
35+
where
36+
D: SolverDelegate<Interner = I>,
37+
{
38+
search_graph: &'a SearchGraph<SearchGraphDelegate<D>>,
39+
}
40+
41+
impl<'a, D, I> EvalCtxt<'a, D, <D as SolverDelegate>::Interner>
42+
where
43+
D: SolverDelegate<Interner = I>
44+
{}
45+
46+
fn main() {}

0 commit comments

Comments
 (0)