Require any function with a tait in its signature to actually constrain a hidden type

This commit is contained in:
Oli Scherer 2024-06-10 16:17:38 +00:00
parent 0eb782ba13
commit 4e0af7cc61

View File

@ -2,20 +2,23 @@
#![feature(type_alias_impl_trait)] #![feature(type_alias_impl_trait)]
trait T { mod helper {
type Item; pub trait T {
} type Item;
}
type Alias<'a> = impl T<Item = &'a ()>; pub type Alias<'a> = impl T<Item = &'a ()>;
struct S; struct S;
impl<'a> T for &'a S { impl<'a> T for &'a S {
type Item = &'a (); type Item = &'a ();
} }
fn filter_positive<'a>() -> Alias<'a> { pub fn filter_positive<'a>() -> Alias<'a> {
&S &S
}
} }
use helper::*;
fn with_positive(fun: impl Fn(Alias<'_>)) { fn with_positive(fun: impl Fn(Alias<'_>)) {
fun(filter_positive()); fun(filter_positive());