-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
25c342f
commit 4560b61
Showing
4 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(|_| {}, |_| {}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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<()>>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} |
33 changes: 33 additions & 0 deletions
33
tests/ui/traits/trait-upcasting/alias-where-clause-isnt-supertrait.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = &(); | ||
} |