Skip to content

Commit 4fb0084

Browse files
authored
Rollup merge of #88541 - vandenheuvel:regression_test_74400, r=Mark-Simulacrum
Add regression test for #74400 Closes #74400 by adding a regression test.
2 parents 2f2aed1 + fe7bcd6 commit 4fb0084

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
error[E0310]: the parameter type `T` may not live long enough
2+
--> $DIR/issue_74400.rs:12:5
3+
|
4+
LL | f(data, identity)
5+
| ^^^^^^^^^^^^^^^^^
6+
|
7+
= help: consider adding an explicit lifetime bound `T: 'static`...
8+
9+
error[E0308]: mismatched types
10+
--> $DIR/issue_74400.rs:12:5
11+
|
12+
LL | f(data, identity)
13+
| ^^^^^^^^^^^^^^^^^ one type is more general than the other
14+
|
15+
= note: expected type `for<'r> Fn<(&'r T,)>`
16+
found type `Fn<(&T,)>`
17+
18+
error: implementation of `FnOnce` is not general enough
19+
--> $DIR/issue_74400.rs:12:5
20+
|
21+
LL | f(data, identity)
22+
| ^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough
23+
|
24+
= note: `fn(&'2 T) -> &'2 T {identity::<&'2 T>}` must implement `FnOnce<(&'1 T,)>`, for any lifetime `'1`...
25+
= note: ...but it actually implements `FnOnce<(&'2 T,)>`, for some specific lifetime `'2`
26+
27+
error: aborting due to 3 previous errors
28+
29+
Some errors have detailed explanations: E0308, E0310.
30+
For more information about an error, try `rustc --explain E0308`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//! Regression test for #74400: Type mismatch in function arguments E0631, E0271 are falsely
2+
//! recognized as E0308 mismatched types.
3+
4+
use std::convert::identity;
5+
6+
fn main() {}
7+
8+
fn f<T, S>(data: &[T], key: impl Fn(&T) -> S) {
9+
}
10+
11+
fn g<T>(data: &[T]) {
12+
f(data, identity) //~ ERROR implementation of `FnOnce` is not general
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error: implementation of `FnOnce` is not general enough
2+
--> $DIR/issue_74400.rs:12:5
3+
|
4+
LL | f(data, identity)
5+
| ^ implementation of `FnOnce` is not general enough
6+
|
7+
= note: `fn(&'2 T) -> &'2 T {identity::<&'2 T>}` must implement `FnOnce<(&'1 T,)>`, for any lifetime `'1`...
8+
= note: ...but it actually implements `FnOnce<(&'2 T,)>`, for some specific lifetime `'2`
9+
10+
error: aborting due to previous error
11+

0 commit comments

Comments
 (0)