Skip to content

Commit

Permalink
deeply_normalize tys in check_tys_might_be_eq
Browse files Browse the repository at this point in the history
Co-authored-by: Boxy <[email protected]>
  • Loading branch information
ShE3py and BoxyUwU committed May 3, 2024
1 parent 89b0410 commit f2db794
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 38 deletions.
6 changes: 5 additions & 1 deletion compiler/rustc_trait_selection/src/traits/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,12 @@ pub fn check_tys_might_be_eq<'tcx>(
let (infcx, key, _) = tcx.infer_ctxt().build_with_canonical(DUMMY_SP, &canonical);
let (param_env, (ty_a, ty_b)) = key.into_parts();
let ocx = ObligationCtxt::new(&infcx);
let cause = ObligationCause::dummy();

let ty_a = ocx.deeply_normalize(&cause, param_env, ty_a).unwrap_or(ty_a);
let ty_b = ocx.deeply_normalize(&cause, param_env, ty_b).unwrap_or(ty_b);
let result = ocx.eq(&cause, param_env, ty_a, ty_b);

let result = ocx.eq(&ObligationCause::dummy(), param_env, ty_a, ty_b);
// use `select_where_possible` instead of `select_all_or_error` so that
// we don't get errors from obligations being ambiguous.
let errors = ocx.select_where_possible();
Expand Down
20 changes: 0 additions & 20 deletions tests/crashes/114456-2.rs

This file was deleted.

17 changes: 0 additions & 17 deletions tests/crashes/114456.rs

This file was deleted.

20 changes: 20 additions & 0 deletions tests/ui/type-alias/normalize-const-tys-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//! Issue #114456: `deeply_normalize` tys in `check_tys_might_be_eq`
//@ check-pass
#![feature(adt_const_params)]
#![allow(incomplete_features)]

enum Type {}
trait Trait { type Matrix; }
impl Trait for Type { type Matrix = [usize; 1]; }

struct Walk<const REMAINING: <Type as Trait>::Matrix> {}

impl Walk<{ [0; 1] }> {
pub const fn new() -> Self {
Self {}
}
}

fn main() {
let _ = Walk::new();
}
17 changes: 17 additions & 0 deletions tests/ui/type-alias/normalize-const-tys.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//! Issue #114456: `deeply_normalize` tys in `check_tys_might_be_eq`
//@ check-pass
#![feature(adt_const_params, lazy_type_alias)]
#![allow(incomplete_features)]

type Matrix = [usize; 1];
struct Walk<const REMAINING: Matrix> {}

impl Walk<{ [0; 1] }> {
pub const fn new() -> Self {
Self {}
}
}

fn main() {
let _ = Walk::new();
}

0 comments on commit f2db794

Please sign in to comment.