Skip to content

Commit 7a25162

Browse files
authored
Rollup merge of rust-lang#63397 - JohnTitor:add-tests-for-ices, r=Centril
Add tests for some ICEs Closes rust-lang#43623 Closes rust-lang#44405 r? @Centril
2 parents 714c8ea + 55f15d7 commit 7a25162

File tree

4 files changed

+94
-0
lines changed

4 files changed

+94
-0
lines changed

src/test/ui/issues/issue-43623.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
pub trait Trait<'a> {
2+
type Assoc;
3+
}
4+
5+
pub struct Type;
6+
7+
impl<'a> Trait<'a> for Type {
8+
type Assoc = ();
9+
}
10+
11+
pub fn break_me<T, F>(f: F)
12+
where T: for<'b> Trait<'b>,
13+
F: for<'b> FnMut(<T as Trait<'b>>::Assoc) {
14+
break_me::<Type, fn(_)>;
15+
//~^ ERROR: type mismatch in function arguments
16+
//~| ERROR: type mismatch resolving
17+
}
18+
19+
fn main() {}

src/test/ui/issues/issue-43623.stderr

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
error[E0631]: type mismatch in function arguments
2+
--> $DIR/issue-43623.rs:14:5
3+
|
4+
LL | break_me::<Type, fn(_)>;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^
6+
| |
7+
| expected signature of `for<'b> fn(<Type as Trait<'b>>::Assoc) -> _`
8+
| found signature of `fn(_) -> _`
9+
|
10+
note: required by `break_me`
11+
--> $DIR/issue-43623.rs:11:1
12+
|
13+
LL | / pub fn break_me<T, F>(f: F)
14+
LL | | where T: for<'b> Trait<'b>,
15+
LL | | F: for<'b> FnMut(<T as Trait<'b>>::Assoc) {
16+
LL | | break_me::<Type, fn(_)>;
17+
LL | |
18+
LL | |
19+
LL | | }
20+
| |_^
21+
22+
error[E0271]: type mismatch resolving `for<'b> <fn(_) as std::ops::FnOnce<(<Type as Trait<'b>>::Assoc,)>>::Output == ()`
23+
--> $DIR/issue-43623.rs:14:5
24+
|
25+
LL | break_me::<Type, fn(_)>;
26+
| ^^^^^^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'b, found concrete lifetime
27+
|
28+
note: required by `break_me`
29+
--> $DIR/issue-43623.rs:11:1
30+
|
31+
LL | / pub fn break_me<T, F>(f: F)
32+
LL | | where T: for<'b> Trait<'b>,
33+
LL | | F: for<'b> FnMut(<T as Trait<'b>>::Assoc) {
34+
LL | | break_me::<Type, fn(_)>;
35+
LL | |
36+
LL | |
37+
LL | | }
38+
| |_^
39+
40+
error: aborting due to 2 previous errors
41+
42+
For more information about this error, try `rustc --explain E0271`.

src/test/ui/issues/issue-44405.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use std::ops::Index;
2+
3+
struct Test;
4+
struct Container(Test);
5+
6+
impl Test {
7+
fn test(&mut self) {}
8+
}
9+
10+
impl<'a> Index<&'a bool> for Container {
11+
type Output = Test;
12+
13+
fn index(&self, _index: &'a bool) -> &Test {
14+
&self.0
15+
}
16+
}
17+
18+
fn main() {
19+
let container = Container(Test);
20+
let mut val = true;
21+
container[&mut val].test(); //~ ERROR: cannot borrow data
22+
}

src/test/ui/issues/issue-44405.stderr

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0596]: cannot borrow data in an index of `Container` as mutable
2+
--> $DIR/issue-44405.rs:21:5
3+
|
4+
LL | container[&mut val].test();
5+
| ^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable
6+
|
7+
= help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `Container`
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0596`.

0 commit comments

Comments
 (0)