rust/tests/ui/type-alias-impl-trait/param_mismatch3.rs

27 lines
669 B
Rust

//! This test checks that when checking for opaque types that
//! only differ in lifetimes, we handle the case of non-generic
//! regions correctly.
#![feature(type_alias_impl_trait)]
fn id2<'a, 'b>(s: (&'a str, &'b str)) -> (&'a str, &'b str) {
s
}
type Opaque<'a> = impl Sized + 'a;
fn test() -> impl for<'a, 'b> Fn((&'a str, &'b str)) -> (Opaque<'a>, Opaque<'b>) {
id2 //~ ERROR expected generic lifetime parameter, found `'a`
}
fn id(s: &str) -> &str {
s
}
type Opaque2<'a> = impl Sized + 'a;
fn test2(s: &str) -> (impl Fn(&str) -> Opaque2<'_>, Opaque2<'_>) {
(id, s) //~ ERROR: expected generic lifetime parameter, found `'_`
}
fn main() {}