Skip to content

Commit

Permalink
Broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Apr 11, 2023
1 parent 25c342f commit 4560b61
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/ui/closures/self-supertrait-bounds.rs
Original file line number Diff line number Diff line change
@@ -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(|_| {}, |_| {});
}
15 changes: 15 additions & 0 deletions tests/ui/lint/unused/trait-alias-supertrait.rs
Original file line number Diff line number Diff line change
@@ -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<()>>();
}
10 changes: 10 additions & 0 deletions tests/ui/traits/alias/dont-elaborate-non-self.rs
Original file line number Diff line number Diff line change
@@ -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() {}
Original file line number Diff line number Diff line change
@@ -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 = &();
}

0 comments on commit 4560b61

Please sign in to comment.