From f8eb9a685cb58aeea3b25cecf7a510f6ba5c92d5 Mon Sep 17 00:00:00 2001 From: ashtneoi Date: Tue, 10 Jul 2018 21:31:07 -0700 Subject: [PATCH] Add `ref mut` suggestion test --- src/test/ui/suggestions/suggest-ref-mut.rs | 31 +++++++++++++++++++ .../ui/suggestions/suggest-ref-mut.stderr | 21 +++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 src/test/ui/suggestions/suggest-ref-mut.rs create mode 100644 src/test/ui/suggestions/suggest-ref-mut.stderr diff --git a/src/test/ui/suggestions/suggest-ref-mut.rs b/src/test/ui/suggestions/suggest-ref-mut.rs new file mode 100644 index 00000000000..1f5c5b03328 --- /dev/null +++ b/src/test/ui/suggestions/suggest-ref-mut.rs @@ -0,0 +1,31 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(nll)] + +fn main() { + let ref foo = 16; + //~^ HELP + //~| SUGGESTION ref mut foo + *foo = 32; + //~^ ERROR + if let Some(ref bar) = Some(16) { + //~^ HELP + //~| SUGGESTION ref mut bar + *bar = 32; + //~^ ERROR + } + match 16 { + ref quo => { *quo = 32; }, + //~^ ERROR + //~| HELP + //~| SUGGESTION ref mut quo + } +} diff --git a/src/test/ui/suggestions/suggest-ref-mut.stderr b/src/test/ui/suggestions/suggest-ref-mut.stderr new file mode 100644 index 00000000000..6e151a995b8 --- /dev/null +++ b/src/test/ui/suggestions/suggest-ref-mut.stderr @@ -0,0 +1,21 @@ +error[E0594]: cannot assign to `*foo` which is behind a `&` reference + --> $DIR/suggest-ref-mut.rs:17:5 + | +LL | *foo = 32; + | ^^^^^^^^^ cannot assign + +error[E0594]: cannot assign to `*bar` which is behind a `&` reference + --> $DIR/suggest-ref-mut.rs:22:9 + | +LL | *bar = 32; + | ^^^^^^^^^ cannot assign + +error[E0594]: cannot assign to `*quo` which is behind a `&` reference + --> $DIR/suggest-ref-mut.rs:26:22 + | +LL | ref quo => { *quo = 32; }, + | ^^^^^^^^^ cannot assign + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0594`.