diff --git a/src/test/ui/issues/issue-43623.rs b/src/test/ui/issues/issue-43623.rs new file mode 100644 index 0000000000000..b259e9e269d06 --- /dev/null +++ b/src/test/ui/issues/issue-43623.rs @@ -0,0 +1,19 @@ +pub trait Trait<'a> { + type Assoc; +} + +pub struct Type; + +impl<'a> Trait<'a> for Type { + type Assoc = (); +} + +pub fn break_me(f: F) +where T: for<'b> Trait<'b>, + F: for<'b> FnMut(>::Assoc) { + break_me::; + //~^ ERROR: type mismatch in function arguments + //~| ERROR: type mismatch resolving +} + +fn main() {} diff --git a/src/test/ui/issues/issue-43623.stderr b/src/test/ui/issues/issue-43623.stderr new file mode 100644 index 0000000000000..b5674105f75d2 --- /dev/null +++ b/src/test/ui/issues/issue-43623.stderr @@ -0,0 +1,42 @@ +error[E0631]: type mismatch in function arguments + --> $DIR/issue-43623.rs:14:5 + | +LL | break_me::; + | ^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected signature of `for<'b> fn(>::Assoc) -> _` + | found signature of `fn(_) -> _` + | +note: required by `break_me` + --> $DIR/issue-43623.rs:11:1 + | +LL | / pub fn break_me(f: F) +LL | | where T: for<'b> Trait<'b>, +LL | | F: for<'b> FnMut(>::Assoc) { +LL | | break_me::; +LL | | +LL | | +LL | | } + | |_^ + +error[E0271]: type mismatch resolving `for<'b> >::Assoc,)>>::Output == ()` + --> $DIR/issue-43623.rs:14:5 + | +LL | break_me::; + | ^^^^^^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'b, found concrete lifetime + | +note: required by `break_me` + --> $DIR/issue-43623.rs:11:1 + | +LL | / pub fn break_me(f: F) +LL | | where T: for<'b> Trait<'b>, +LL | | F: for<'b> FnMut(>::Assoc) { +LL | | break_me::; +LL | | +LL | | +LL | | } + | |_^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0271`. diff --git a/src/test/ui/issues/issue-44405.rs b/src/test/ui/issues/issue-44405.rs new file mode 100644 index 0000000000000..d404b9044dd6f --- /dev/null +++ b/src/test/ui/issues/issue-44405.rs @@ -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 +} diff --git a/src/test/ui/issues/issue-44405.stderr b/src/test/ui/issues/issue-44405.stderr new file mode 100644 index 0000000000000..1fd69f6e77799 --- /dev/null +++ b/src/test/ui/issues/issue-44405.stderr @@ -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`.