diff options
| author | Bram van den Heuvel <bram@vandenheuvel.online> | 2021-08-31 11:03:49 +0200 |
|---|---|---|
| committer | Bram van den Heuvel <bram@vandenheuvel.online> | 2021-09-06 01:00:47 +0200 |
| commit | fe7bcd6e4044f760f90aa2309c76d3a75899126a (patch) | |
| tree | 35c5593abef6816b44bdae8dc9ede2bcd56f97ce | |
| parent | e2750baf53aaa60db95f10759f6cf9463dc5a6bd (diff) | |
| download | rust-fe7bcd6e4044f760f90aa2309c76d3a75899126a.tar.gz rust-fe7bcd6e4044f760f90aa2309c76d3a75899126a.zip | |
Add regression test for #74400
3 files changed, 54 insertions, 0 deletions
diff --git a/src/test/ui/lifetimes/lifetime-errors/issue_74400.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/issue_74400.nll.stderr new file mode 100644 index 00000000000..5a1294f948f --- /dev/null +++ b/src/test/ui/lifetimes/lifetime-errors/issue_74400.nll.stderr @@ -0,0 +1,30 @@ +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/issue_74400.rs:12:5 + | +LL | f(data, identity) + | ^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `T: 'static`... + +error[E0308]: mismatched types + --> $DIR/issue_74400.rs:12:5 + | +LL | f(data, identity) + | ^^^^^^^^^^^^^^^^^ one type is more general than the other + | + = note: expected type `for<'r> Fn<(&'r T,)>` + found type `Fn<(&T,)>` + +error: implementation of `FnOnce` is not general enough + --> $DIR/issue_74400.rs:12:5 + | +LL | f(data, identity) + | ^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough + | + = note: `fn(&'2 T) -> &'2 T {identity::<&'2 T>}` must implement `FnOnce<(&'1 T,)>`, for any lifetime `'1`... + = note: ...but it actually implements `FnOnce<(&'2 T,)>`, for some specific lifetime `'2` + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0308, E0310. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/lifetimes/lifetime-errors/issue_74400.rs b/src/test/ui/lifetimes/lifetime-errors/issue_74400.rs new file mode 100644 index 00000000000..f83384524f7 --- /dev/null +++ b/src/test/ui/lifetimes/lifetime-errors/issue_74400.rs @@ -0,0 +1,13 @@ +//! Regression test for #74400: Type mismatch in function arguments E0631, E0271 are falsely +//! recognized as E0308 mismatched types. + +use std::convert::identity; + +fn main() {} + +fn f<T, S>(data: &[T], key: impl Fn(&T) -> S) { +} + +fn g<T>(data: &[T]) { + f(data, identity) //~ ERROR implementation of `FnOnce` is not general +} diff --git a/src/test/ui/lifetimes/lifetime-errors/issue_74400.stderr b/src/test/ui/lifetimes/lifetime-errors/issue_74400.stderr new file mode 100644 index 00000000000..d972861a2b5 --- /dev/null +++ b/src/test/ui/lifetimes/lifetime-errors/issue_74400.stderr @@ -0,0 +1,11 @@ +error: implementation of `FnOnce` is not general enough + --> $DIR/issue_74400.rs:12:5 + | +LL | f(data, identity) + | ^ implementation of `FnOnce` is not general enough + | + = note: `fn(&'2 T) -> &'2 T {identity::<&'2 T>}` must implement `FnOnce<(&'1 T,)>`, for any lifetime `'1`... + = note: ...but it actually implements `FnOnce<(&'2 T,)>`, for some specific lifetime `'2` + +error: aborting due to previous error + |
