Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/rustc_type_ir/src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ impl<I: Interner> FlagComputation<I> {

fn add_ty_pat(&mut self, pat: <I as Interner>::Pat) {
self.add_flags(pat.flags());
self.add_exclusive_binder(pat.outer_exclusive_binder());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the one line that actually fixes the issue. We didn't record the fact that pattern types might have bound variables inside them without this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without it, this:

fn outer_exclusive_binder(&self) -> rustc_type_ir::DebruijnIndex {
match &**self {
ty::PatternKind::Range { start, end } => {
start.outer_exclusive_binder().max(end.outer_exclusive_binder())
}
ty::PatternKind::Or(pats) => {
let mut idx = pats[0].outer_exclusive_binder();
for pat in pats[1..].iter() {
idx = idx.max(pat.outer_exclusive_binder());
}
idx
}
}
}

is actually dead code

}

fn add_predicate(&mut self, binder: ty::Binder<I, ty::PredicateKind<I>>) {
Expand Down
3 changes: 3 additions & 0 deletions tests/ui/type/pattern_types/const_generics.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
//@ check-pass
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver

#![feature(pattern_types, generic_pattern_types, pattern_type_macro)]
#![expect(incomplete_features)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute.rs:20:14
--> $DIR/transmute.rs:23:14
|
LL | unsafe { std::mem::transmute(x) }
| ^^^^^^^^^^^^^^^^^^^
Expand All @@ -8,7 +8,7 @@ LL | unsafe { std::mem::transmute(x) }
= note: target type: `u32` (32 bits)

error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute.rs:28:14
--> $DIR/transmute.rs:31:14
|
LL | unsafe { std::mem::transmute(x) }
| ^^^^^^^^^^^^^^^^^^^
Expand Down
21 changes: 21 additions & 0 deletions tests/ui/type/pattern_types/transmute.next.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute.rs:23:14
|
LL | unsafe { std::mem::transmute(x) }
| ^^^^^^^^^^^^^^^^^^^
|
= note: source type: `Option<(u32) is S..=E>` (size can vary because of u32)
= note: target type: `u32` (32 bits)

error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute.rs:31:14
|
LL | unsafe { std::mem::transmute(x) }
| ^^^^^^^^^^^^^^^^^^^
|
= note: source type: `Option<(u32) is S..=E>` (size can vary because of u32)
= note: target type: `Option<u32>` (64 bits)

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0512`.
3 changes: 3 additions & 0 deletions tests/ui/type/pattern_types/transmute.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver
#![feature(pattern_types, pattern_type_macro, generic_pattern_types)]
#![expect(incomplete_features)]

Expand Down
Loading