forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#68992 - matthewjasper:imm-binding-after-at,…
… r=Centril Correctly parse `mut a @ b` r? @Centril Closes rust-lang#67861 Closes rust-lang#67926
- Loading branch information
Showing
6 changed files
with
82 additions
and
4 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
13 changes: 13 additions & 0 deletions
13
src/test/ui/pattern/bindings-after-at/nested-binding-mode-lint.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,13 @@ | ||
// check-pass | ||
|
||
#![feature(bindings_after_at)] | ||
#![deny(unused_mut)] | ||
|
||
fn main() { | ||
let mut is_mut @ not_mut = 42; | ||
&mut is_mut; | ||
¬_mut; | ||
let not_mut @ mut is_mut = 42; | ||
&mut is_mut; | ||
¬_mut; | ||
} |
13 changes: 13 additions & 0 deletions
13
src/test/ui/pattern/bindings-after-at/nested-binding-modes-mut.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,13 @@ | ||
#![feature(bindings_after_at)] | ||
|
||
fn main() { | ||
let mut is_mut @ not_mut = 42; | ||
&mut is_mut; | ||
&mut not_mut; | ||
//~^ ERROR cannot borrow | ||
|
||
let not_mut @ mut is_mut = 42; | ||
&mut is_mut; | ||
&mut not_mut; | ||
//~^ ERROR cannot borrow | ||
} |
21 changes: 21 additions & 0 deletions
21
src/test/ui/pattern/bindings-after-at/nested-binding-modes-mut.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,21 @@ | ||
error[E0596]: cannot borrow `not_mut` as mutable, as it is not declared as mutable | ||
--> $DIR/nested-binding-modes-mut.rs:6:5 | ||
| | ||
LL | let mut is_mut @ not_mut = 42; | ||
| ------- help: consider changing this to be mutable: `mut not_mut` | ||
LL | &mut is_mut; | ||
LL | &mut not_mut; | ||
| ^^^^^^^^^^^^ cannot borrow as mutable | ||
|
||
error[E0596]: cannot borrow `not_mut` as mutable, as it is not declared as mutable | ||
--> $DIR/nested-binding-modes-mut.rs:11:5 | ||
| | ||
LL | let not_mut @ mut is_mut = 42; | ||
| -------------------- help: consider changing this to be mutable: `mut not_mut` | ||
LL | &mut is_mut; | ||
LL | &mut not_mut; | ||
| ^^^^^^^^^^^^ cannot borrow as mutable | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0596`. |
13 changes: 13 additions & 0 deletions
13
src/test/ui/pattern/bindings-after-at/nested-binding-modes-ref.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,13 @@ | ||
#![feature(bindings_after_at)] | ||
|
||
fn main() { | ||
let ref is_ref @ is_val = 42; | ||
*is_ref; | ||
*is_val; | ||
//~^ ERROR cannot be dereferenced | ||
|
||
let is_val @ ref is_ref = 42; | ||
*is_ref; | ||
*is_val; | ||
//~^ ERROR cannot be dereferenced | ||
} |
15 changes: 15 additions & 0 deletions
15
src/test/ui/pattern/bindings-after-at/nested-binding-modes-ref.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,15 @@ | ||
error[E0614]: type `{integer}` cannot be dereferenced | ||
--> $DIR/nested-binding-modes-ref.rs:6:5 | ||
| | ||
LL | *is_val; | ||
| ^^^^^^^ | ||
|
||
error[E0614]: type `{integer}` cannot be dereferenced | ||
--> $DIR/nested-binding-modes-ref.rs:11:5 | ||
| | ||
LL | *is_val; | ||
| ^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0614`. |