blob: 1ec2b5a214bfa4110875e52080e814f0f0461997 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
//@ edition: 2021
//@ run-rustfix
//@ rustfix-only-machine-applicable
//@ aux-build:match_ergonomics_2024_macros.rs
#![feature(mut_ref, ref_pat_eat_one_layer_2024)]
#![allow(incomplete_features, unused)]
#![deny(rust_2024_incompatible_pat)]
extern crate match_ergonomics_2024_macros;
struct Foo(u8);
fn main() {
let &Foo(mut a) = &Foo(0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
a = 42;
let &mut Foo(mut a) = &mut Foo(0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
a = 42;
if let &&&&&Some(&_) = &&&&&Some(&0u8) {}
//~^ ERROR: the semantics of this pattern will change in edition 2024
if let &&&&&Some(&mut _) = &&&&&Some(&mut 0u8) {}
//~^ ERROR: the semantics of this pattern will change in edition 2024
if let &&&&&mut Some(&_) = &&&&&mut Some(&0u8) {}
//~^ ERROR: the semantics of this pattern will change in edition 2024
if let &mut Some(&mut Some(&mut Some(_))) = &mut Some(&mut Some(&mut Some(0u8))) {}
//~^ ERROR: the semantics of this pattern will change in edition 2024
if let &mut Some(&mut Some(&mut Some(ref mut _a))) = &mut Some(&mut Some(&mut Some(0u8))) {}
//~^ ERROR: the semantics of this pattern will change in edition 2024
struct Struct {
a: u32,
b: u32,
c: u32,
}
let s = Struct { a: 0, b: 0, c: 0 };
let &Struct { ref a, mut b, ref c } = &s;
//~^ ERROR: the semantics of this pattern will change in edition 2024
#[warn(rust_2024_incompatible_pat)]
match &(Some(0), Some(0)) {
// The two patterns are the same syntactically, but because they're defined in different
// editions they don't mean the same thing.
(Some(mut _x), match_ergonomics_2024_macros::mixed_edition_pat!(_y)) => {
//~^ WARN: the semantics of this pattern will change in edition 2024
_x = 4;
_y = &7;
}
_ => {}
}
}
|