Add test for issue-44405
This commit is contained in:
parent
642ee70942
commit
55f15d7655
2 changed files with 33 additions and 0 deletions
22
src/test/ui/issues/issue-44405.rs
Normal file
22
src/test/ui/issues/issue-44405.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
use std::ops::Index;
|
||||
|
||||
struct Test;
|
||||
struct Container(Test);
|
||||
|
||||
impl Test {
|
||||
fn test(&mut self) {}
|
||||
}
|
||||
|
||||
impl<'a> Index<&'a bool> for Container {
|
||||
type Output = Test;
|
||||
|
||||
fn index(&self, _index: &'a bool) -> &Test {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let container = Container(Test);
|
||||
let mut val = true;
|
||||
container[&mut val].test(); //~ ERROR: cannot borrow data
|
||||
}
|
11
src/test/ui/issues/issue-44405.stderr
Normal file
11
src/test/ui/issues/issue-44405.stderr
Normal file
|
@ -0,0 +1,11 @@
|
|||
error[E0596]: cannot borrow data in an index of `Container` as mutable
|
||||
--> $DIR/issue-44405.rs:21:5
|
||||
|
|
||||
LL | container[&mut val].test();
|
||||
| ^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable
|
||||
|
|
||||
= help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `Container`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
Loading…
Add table
Reference in a new issue