diff options
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/borrowck/index-mut-help-with-impl.nll.stderr | 11 | ||||
| -rw-r--r-- | src/test/ui/borrowck/index-mut-help-with-impl.rs | 20 | ||||
| -rw-r--r-- | src/test/ui/borrowck/index-mut-help-with-impl.stderr | 9 | ||||
| -rw-r--r-- | src/test/ui/borrowck/index-mut-help.nll.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-41726.nll.stderr | 2 |
5 files changed, 46 insertions, 0 deletions
diff --git a/src/test/ui/borrowck/index-mut-help-with-impl.nll.stderr b/src/test/ui/borrowck/index-mut-help-with-impl.nll.stderr new file mode 100644 index 00000000000..8e7ffa67b06 --- /dev/null +++ b/src/test/ui/borrowck/index-mut-help-with-impl.nll.stderr @@ -0,0 +1,11 @@ +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/index-mut-help-with-impl.rs:19:5 + | +LL | Index::index(&v, 1..2).make_ascii_uppercase(); //~ ERROR + | ^^^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable + | + = help: trait `IndexMut` is required to modify indexed content + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/index-mut-help-with-impl.rs b/src/test/ui/borrowck/index-mut-help-with-impl.rs new file mode 100644 index 00000000000..a5bab48c5cc --- /dev/null +++ b/src/test/ui/borrowck/index-mut-help-with-impl.rs @@ -0,0 +1,20 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// When mutably indexing a type that implements `Index` and `IndexMut` but +// `Index::index` is being used specifically, the normal special help message +// should not mention a missing `IndexMut` impl. + +fn main() { + use std::ops::Index; + + let v = String::from("dinosaur"); + Index::index(&v, 1..2).make_ascii_uppercase(); //~ ERROR +} diff --git a/src/test/ui/borrowck/index-mut-help-with-impl.stderr b/src/test/ui/borrowck/index-mut-help-with-impl.stderr new file mode 100644 index 00000000000..9c28b86c45a --- /dev/null +++ b/src/test/ui/borrowck/index-mut-help-with-impl.stderr @@ -0,0 +1,9 @@ +error[E0596]: cannot borrow immutable borrowed content as mutable + --> $DIR/index-mut-help-with-impl.rs:19:5 + | +LL | Index::index(&v, 1..2).make_ascii_uppercase(); //~ ERROR + | ^^^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/index-mut-help.nll.stderr b/src/test/ui/borrowck/index-mut-help.nll.stderr index cc058f1fde5..a15f37684e7 100644 --- a/src/test/ui/borrowck/index-mut-help.nll.stderr +++ b/src/test/ui/borrowck/index-mut-help.nll.stderr @@ -3,6 +3,8 @@ error[E0596]: cannot borrow data in a `&` reference as mutable | LL | map["peter"].clear(); //~ ERROR | ^^^^^^^^^^^^ cannot borrow as mutable + | + = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `std::collections::HashMap<&str, std::string::String>` error[E0594]: cannot assign to data in a `&` reference --> $DIR/index-mut-help.rs:22:5 @@ -15,6 +17,8 @@ error[E0596]: cannot borrow data in a `&` reference as mutable | LL | let _ = &mut map["peter"]; //~ ERROR | ^^^^^^^^^^^^^^^^^ cannot borrow as mutable + | + = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `std::collections::HashMap<&str, std::string::String>` error: aborting due to 3 previous errors diff --git a/src/test/ui/issues/issue-41726.nll.stderr b/src/test/ui/issues/issue-41726.nll.stderr index 06ff743a0f5..9f727881bea 100644 --- a/src/test/ui/issues/issue-41726.nll.stderr +++ b/src/test/ui/issues/issue-41726.nll.stderr @@ -3,6 +3,8 @@ error[E0596]: cannot borrow data in a `&` reference as mutable | LL | things[src.as_str()].sort(); //~ ERROR cannot borrow immutable | ^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable + | + = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `std::collections::HashMap<std::string::String, std::vec::Vec<std::string::String>>` error: aborting due to previous error |
