Broken tests

This commit is contained in:
Michael Goulet 2023-01-31 21:22:11 +00:00
parent 25c342f30a
commit 4560b61cd1
4 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,14 @@
// check-pass
// Makes sure that we only consider `Self` supertrait predicates while
// elaborating during closure signature deduction.
#![feature(trait_alias)]
trait Confusing<F> = Fn(i32) where F: Fn(u32);
fn alias<T: Confusing<F>, F>(_: T, _: F) {}
fn main() {
alias(|_| {}, |_| {});
}

View File

@ -0,0 +1,15 @@
// check-pass
// Make sure that we only consider *Self* supertrait predicates
// in the `unused_must_use` lint.
#![feature(trait_alias)]
#![deny(unused_must_use)]
trait Foo<T> = Sized where T: Iterator;
fn test<T: Iterator>() -> impl Foo<T> {}
fn main() {
test::<std::iter::Once<()>>();
}

View File

@ -0,0 +1,10 @@
#![feature(trait_alias)]
use std::future::Future;
trait F<Fut: Future<Output = usize>> = Fn() -> Fut;
fn f<Fut>(a: dyn F<Fut>) {}
//~^ ERROR the size for values of type `(dyn Fn() -> Fut + 'static)` cannot be known at compilation time
fn main() {}

View File

@ -0,0 +1,33 @@
#![feature(trait_upcasting)]
#![feature(trait_alias)]
// Although we *elaborate* `T: Alias` to `i32: B`, we should
// not consider `B` to be a supertrait of the type.
trait Alias = A where i32: B;
trait A {}
trait B {
fn test(&self);
}
trait C: Alias {}
impl A for () {}
impl C for () {}
impl B for i32 {
fn test(&self) {
println!("hi {self}");
}
}
fn test(x: &dyn C) -> &dyn B {
x
//~^ ERROR mismatched types
}
fn main() {
let x: &dyn C = &();
}