Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for some ICEs #63397

Merged
merged 2 commits into from
Aug 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/test/ui/issues/issue-43623.rs
Original file line number Diff line number Diff line change
@@ -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<T, F>(f: F)
where T: for<'b> Trait<'b>,
F: for<'b> FnMut(<T as Trait<'b>>::Assoc) {
break_me::<Type, fn(_)>;
//~^ ERROR: type mismatch in function arguments
//~| ERROR: type mismatch resolving
}

fn main() {}
42 changes: 42 additions & 0 deletions src/test/ui/issues/issue-43623.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
error[E0631]: type mismatch in function arguments
--> $DIR/issue-43623.rs:14:5
|
LL | break_me::<Type, fn(_)>;
| ^^^^^^^^^^^^^^^^^^^^^^^
| |
| expected signature of `for<'b> fn(<Type as Trait<'b>>::Assoc) -> _`
| found signature of `fn(_) -> _`
|
note: required by `break_me`
--> $DIR/issue-43623.rs:11:1
|
LL | / pub fn break_me<T, F>(f: F)
LL | | where T: for<'b> Trait<'b>,
LL | | F: for<'b> FnMut(<T as Trait<'b>>::Assoc) {
LL | | break_me::<Type, fn(_)>;
LL | |
LL | |
LL | | }
| |_^

error[E0271]: type mismatch resolving `for<'b> <fn(_) as std::ops::FnOnce<(<Type as Trait<'b>>::Assoc,)>>::Output == ()`
--> $DIR/issue-43623.rs:14:5
|
LL | break_me::<Type, fn(_)>;
| ^^^^^^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'b, found concrete lifetime
|
note: required by `break_me`
--> $DIR/issue-43623.rs:11:1
|
LL | / pub fn break_me<T, F>(f: F)
LL | | where T: for<'b> Trait<'b>,
LL | | F: for<'b> FnMut(<T as Trait<'b>>::Assoc) {
LL | | break_me::<Type, fn(_)>;
LL | |
LL | |
LL | | }
| |_^

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0271`.
22 changes: 22 additions & 0 deletions src/test/ui/issues/issue-44405.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 11 additions & 0 deletions src/test/ui/issues/issue-44405.stderr
Original file line number Diff line number Diff line change
@@ -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`.