Gate implicit mutable by-reference bindings behind mut ref
This commit is contained in:
parent
eb91f3b051
commit
0746577fa2
11 changed files with 61 additions and 65 deletions
|
@ -1,14 +0,0 @@
|
|||
//@ edition: 2024
|
||||
//@ compile-flags: -Zunstable-options
|
||||
|
||||
struct Foo(u8);
|
||||
|
||||
fn main() {
|
||||
let Foo(mut a) = &Foo(0);
|
||||
a = &42;
|
||||
//~^ ERROR: mismatched types
|
||||
|
||||
let Foo(mut a) = &mut Foo(0);
|
||||
a = &mut 42;
|
||||
//~^ ERROR: mismatched types
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/feature-gate-mut_preserve_binding_mode_2024.rs:8:9
|
||||
|
|
||||
LL | let Foo(mut a) = &Foo(0);
|
||||
| ----- expected due to the type of this binding
|
||||
LL | a = &42;
|
||||
| ^^^ expected `u8`, found `&{integer}`
|
||||
|
|
||||
help: consider removing the borrow
|
||||
|
|
||||
LL - a = &42;
|
||||
LL + a = 42;
|
||||
|
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/feature-gate-mut_preserve_binding_mode_2024.rs:12:9
|
||||
|
|
||||
LL | let Foo(mut a) = &mut Foo(0);
|
||||
| ----- expected due to the type of this binding
|
||||
LL | a = &mut 42;
|
||||
| ^^^^^^^ expected `u8`, found `&mut {integer}`
|
||||
|
|
||||
help: consider removing the borrow
|
||||
|
|
||||
LL - a = &mut 42;
|
||||
LL + a = 42;
|
||||
|
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
|
@ -2,7 +2,7 @@
|
|||
//@ run-rustfix
|
||||
//@ rustfix-only-machine-applicable
|
||||
//@ aux-build:match_ergonomics_2024_macros.rs
|
||||
#![feature(mut_preserve_binding_mode_2024, ref_pat_eat_one_layer_2024)]
|
||||
#![feature(mut_ref, ref_pat_eat_one_layer_2024)]
|
||||
#![allow(incomplete_features, unused)]
|
||||
#![deny(rust_2024_incompatible_pat)]
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//@ run-rustfix
|
||||
//@ rustfix-only-machine-applicable
|
||||
//@ aux-build:match_ergonomics_2024_macros.rs
|
||||
#![feature(mut_preserve_binding_mode_2024, ref_pat_eat_one_layer_2024)]
|
||||
#![feature(mut_ref, ref_pat_eat_one_layer_2024)]
|
||||
#![allow(incomplete_features, unused)]
|
||||
#![deny(rust_2024_incompatible_pat)]
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//@ edition: 2021
|
||||
//@ compile-flags: -Zunstable-options
|
||||
#![feature(mut_preserve_binding_mode_2024)]
|
||||
#![feature(ref_pat_eat_one_layer_2024)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
struct Foo(u8);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//@ run-pass
|
||||
//@ edition: 2024
|
||||
//@ compile-flags: -Zunstable-options
|
||||
#![feature(mut_preserve_binding_mode_2024)]
|
||||
#![feature(mut_ref, ref_pat_eat_one_layer_2024)]
|
||||
#![allow(incomplete_features, unused)]
|
||||
|
||||
struct Foo(u8);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue