-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly downgrade inherited mutability
- Loading branch information
1 parent
2f730c1
commit e5b63c2
Showing
6 changed files
with
77 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
tests/ui/match/ref_pat_eat_one_layer_2024/ref_pat_eat_one_layer_2024_fail2.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//@ edition: 2024 | ||
//@ compile-flags: -Zunstable-options | ||
#![allow(incomplete_features)] | ||
#![feature(ref_pat_eat_one_layer_2024)] | ||
|
||
pub fn main() { | ||
if let Some(&Some(x)) = Some(&Some(&mut 0)) { | ||
//~^ ERROR: cannot move out of a shared reference [E0507] | ||
let _: &u32 = x; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
tests/ui/match/ref_pat_eat_one_layer_2024/ref_pat_eat_one_layer_2024_fail2.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error[E0507]: cannot move out of a shared reference | ||
--> $DIR/ref_pat_eat_one_layer_2024_fail2.rs:7:29 | ||
| | ||
LL | if let Some(&Some(x)) = Some(&Some(&mut 0)) { | ||
| - ^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| data moved here | ||
| move occurs because `x` has type `&mut u32`, which does not implement the `Copy` trait | ||
| | ||
help: consider borrowing the pattern binding | ||
| | ||
LL | if let Some(&Some(ref x)) = Some(&Some(&mut 0)) { | ||
| +++ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0507`. |