diff options
| author | Matthew Jasper <mjjasper1@gmail.com> | 2020-02-09 13:19:06 +0000 |
|---|---|---|
| committer | Matthew Jasper <mjjasper1@gmail.com> | 2020-02-09 13:19:06 +0000 |
| commit | fa5a3c35dcda3c82d0c10837cdcbf747e833eabd (patch) | |
| tree | 15770b9480c8ec601784f6ac3c54b4b9673228e9 /src/test/ui/pattern | |
| parent | 64ea639c12df0594dd891b1ba0b439c8c5eacd83 (diff) | |
| download | rust-fa5a3c35dcda3c82d0c10837cdcbf747e833eabd.tar.gz rust-fa5a3c35dcda3c82d0c10837cdcbf747e833eabd.zip | |
Don't parse `mut a @ b` as `mut a @ mut b`
Diffstat (limited to 'src/test/ui/pattern')
5 files changed, 75 insertions, 0 deletions
diff --git a/src/test/ui/pattern/bindings-after-at/nested-binding-mode-lint.rs b/src/test/ui/pattern/bindings-after-at/nested-binding-mode-lint.rs new file mode 100644 index 00000000000..497d94a3db0 --- /dev/null +++ b/src/test/ui/pattern/bindings-after-at/nested-binding-mode-lint.rs @@ -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; +} diff --git a/src/test/ui/pattern/bindings-after-at/nested-binding-modes-mut.rs b/src/test/ui/pattern/bindings-after-at/nested-binding-modes-mut.rs new file mode 100644 index 00000000000..54f04117f7d --- /dev/null +++ b/src/test/ui/pattern/bindings-after-at/nested-binding-modes-mut.rs @@ -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 +} diff --git a/src/test/ui/pattern/bindings-after-at/nested-binding-modes-mut.stderr b/src/test/ui/pattern/bindings-after-at/nested-binding-modes-mut.stderr new file mode 100644 index 00000000000..a8d5e4c4c69 --- /dev/null +++ b/src/test/ui/pattern/bindings-after-at/nested-binding-modes-mut.stderr @@ -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`. diff --git a/src/test/ui/pattern/bindings-after-at/nested-binding-modes-ref.rs b/src/test/ui/pattern/bindings-after-at/nested-binding-modes-ref.rs new file mode 100644 index 00000000000..d5086aec93e --- /dev/null +++ b/src/test/ui/pattern/bindings-after-at/nested-binding-modes-ref.rs @@ -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 +} diff --git a/src/test/ui/pattern/bindings-after-at/nested-binding-modes-ref.stderr b/src/test/ui/pattern/bindings-after-at/nested-binding-modes-ref.stderr new file mode 100644 index 00000000000..9cc928d2149 --- /dev/null +++ b/src/test/ui/pattern/bindings-after-at/nested-binding-modes-ref.stderr @@ -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`. |
