Skip to content

Commit f2db794

Browse files
ShE3pyBoxyUwU
andcommitted
deeply_normalize tys in check_tys_might_be_eq
Co-authored-by: Boxy <[email protected]>
1 parent 89b0410 commit f2db794

File tree

5 files changed

+42
-38
lines changed

5 files changed

+42
-38
lines changed

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,12 @@ pub fn check_tys_might_be_eq<'tcx>(
215215
let (infcx, key, _) = tcx.infer_ctxt().build_with_canonical(DUMMY_SP, &canonical);
216216
let (param_env, (ty_a, ty_b)) = key.into_parts();
217217
let ocx = ObligationCtxt::new(&infcx);
218+
let cause = ObligationCause::dummy();
219+
220+
let ty_a = ocx.deeply_normalize(&cause, param_env, ty_a).unwrap_or(ty_a);
221+
let ty_b = ocx.deeply_normalize(&cause, param_env, ty_b).unwrap_or(ty_b);
222+
let result = ocx.eq(&cause, param_env, ty_a, ty_b);
218223

219-
let result = ocx.eq(&ObligationCause::dummy(), param_env, ty_a, ty_b);
220224
// use `select_where_possible` instead of `select_all_or_error` so that
221225
// we don't get errors from obligations being ambiguous.
222226
let errors = ocx.select_where_possible();

Diff for: tests/crashes/114456-2.rs

-20
This file was deleted.

Diff for: tests/crashes/114456.rs

-17
This file was deleted.

Diff for: tests/ui/type-alias/normalize-const-tys-2.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//! Issue #114456: `deeply_normalize` tys in `check_tys_might_be_eq`
2+
//@ check-pass
3+
#![feature(adt_const_params)]
4+
#![allow(incomplete_features)]
5+
6+
enum Type {}
7+
trait Trait { type Matrix; }
8+
impl Trait for Type { type Matrix = [usize; 1]; }
9+
10+
struct Walk<const REMAINING: <Type as Trait>::Matrix> {}
11+
12+
impl Walk<{ [0; 1] }> {
13+
pub const fn new() -> Self {
14+
Self {}
15+
}
16+
}
17+
18+
fn main() {
19+
let _ = Walk::new();
20+
}

Diff for: tests/ui/type-alias/normalize-const-tys.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//! Issue #114456: `deeply_normalize` tys in `check_tys_might_be_eq`
2+
//@ check-pass
3+
#![feature(adt_const_params, lazy_type_alias)]
4+
#![allow(incomplete_features)]
5+
6+
type Matrix = [usize; 1];
7+
struct Walk<const REMAINING: Matrix> {}
8+
9+
impl Walk<{ [0; 1] }> {
10+
pub const fn new() -> Self {
11+
Self {}
12+
}
13+
}
14+
15+
fn main() {
16+
let _ = Walk::new();
17+
}

0 commit comments

Comments
 (0)