Skip to content

Commit 25b6844

Browse files
committed
Add test that triggers ICE
1 parent 3dfbfd9 commit 25b6844

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ compile-flags: --edition 2024 -Z unstable-options
2+
3+
// This contains a binding in edition 2024, so if matched with a reference binding mode it will end
4+
// up with a `mut ref mut` binding mode. We use this to test the migration lint on patterns with
5+
// mixed editions.
6+
#[macro_export]
7+
macro_rules! mixed_edition_pat {
8+
() => {
9+
Some(mut _x)
10+
};
11+
}

tests/ui/pattern/match_ergonomics_2024.rs

+10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
//@ edition: 2021
22
//@ run-rustfix
3+
//@ aux-build:match_ergonomics_2024_macros.rs
34
#![feature(mut_preserve_binding_mode_2024, ref_pat_eat_one_layer_2024)]
45
#![allow(incomplete_features, unused)]
56
#![forbid(rust_2024_incompatible_pat)]
67

8+
extern crate match_ergonomics_2024_macros;
9+
710
struct Foo(u8);
811

912
fn main() {
@@ -38,4 +41,11 @@ fn main() {
3841
let s = Struct { a: 0, b: 0, c: 0 };
3942
let Struct { a, mut b, c } = &s;
4043
//~^ ERROR: the semantics of this pattern will change in edition 2024
44+
45+
match &(Some(0), Some(0)) {
46+
// The two patterns are the same syntactically, but because they're defined in different
47+
// editions they don't mean the same thing.
48+
(Some(mut _x), match_ergonomics_2024_macros::mixed_edition_pat!()) => {}
49+
_ => {}
50+
}
4151
}

0 commit comments

Comments
 (0)