diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
commit | 4f9fe856a25ab29345b90e7725509e9ee38a37be (patch) | |
tree | e4ffd8a9374cae7b21f7cbfb352927e0e074aff6 /tests/ui/traits/alias | |
parent | Adding upstream version 1.68.2+dfsg1. (diff) | |
download | rustc-upstream/1.69.0+dfsg1.tar.xz rustc-upstream/1.69.0+dfsg1.zip |
Adding upstream version 1.69.0+dfsg1.upstream/1.69.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/traits/alias')
9 files changed, 106 insertions, 7 deletions
diff --git a/tests/ui/traits/alias/ambiguous.stderr b/tests/ui/traits/alias/ambiguous.stderr index 0fe1a7967..203bdc526 100644 --- a/tests/ui/traits/alias/ambiguous.stderr +++ b/tests/ui/traits/alias/ambiguous.stderr @@ -14,11 +14,11 @@ note: candidate #2 is defined in an impl of the trait `B` for the type `u8` | LL | fn foo(&self) {} | ^^^^^^^^^^^^^ -help: disambiguate the associated function for candidate #1 +help: disambiguate the method for candidate #1 | LL | A::foo(&t); | ~~~~~~~~~~ -help: disambiguate the associated function for candidate #2 +help: disambiguate the method for candidate #2 | LL | B::foo(&t); | ~~~~~~~~~~ diff --git a/tests/ui/traits/alias/issue-107747-do-not-assemble-supertraits.rs b/tests/ui/traits/alias/issue-107747-do-not-assemble-supertraits.rs new file mode 100644 index 000000000..9b41a8096 --- /dev/null +++ b/tests/ui/traits/alias/issue-107747-do-not-assemble-supertraits.rs @@ -0,0 +1,21 @@ +// Regression test for #107747: methods from trait alias supertraits were brought into scope +// +// check-pass + +#![feature(trait_alias)] + +use std::fmt; + +trait Foo: fmt::Debug {} +trait Bar = Foo; + +#[derive(Debug)] +struct Qux(bool); + +impl fmt::Display for Qux { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.0.fmt(f) + } +} + +fn main() {} diff --git a/tests/ui/traits/alias/issue-108072-unmet-trait-alias-bound.rs b/tests/ui/traits/alias/issue-108072-unmet-trait-alias-bound.rs new file mode 100644 index 000000000..d254c0ae3 --- /dev/null +++ b/tests/ui/traits/alias/issue-108072-unmet-trait-alias-bound.rs @@ -0,0 +1,11 @@ +// Regression test for #108072: do not ICE upon unmet trait alias constraint + +#![feature(trait_alias)] + +trait IteratorAlias = Iterator; + +fn f(_: impl IteratorAlias) {} + +fn main() { + f(()) //~ `()` is not an iterator +} diff --git a/tests/ui/traits/alias/issue-108072-unmet-trait-alias-bound.stderr b/tests/ui/traits/alias/issue-108072-unmet-trait-alias-bound.stderr new file mode 100644 index 000000000..39f974f96 --- /dev/null +++ b/tests/ui/traits/alias/issue-108072-unmet-trait-alias-bound.stderr @@ -0,0 +1,19 @@ +error[E0277]: `()` is not an iterator + --> $DIR/issue-108072-unmet-trait-alias-bound.rs:10:7 + | +LL | f(()) + | - ^^ `()` is not an iterator + | | + | required by a bound introduced by this call + | + = help: the trait `Iterator` is not implemented for `()` + = note: required for `()` to implement `IteratorAlias` +note: required by a bound in `f` + --> $DIR/issue-108072-unmet-trait-alias-bound.rs:7:14 + | +LL | fn f(_: impl IteratorAlias) {} + | ^^^^^^^^^^^^^ required by this bound in `f` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/alias/issue-108132-unmet-trait-alias-bound-on-generic-impl.rs b/tests/ui/traits/alias/issue-108132-unmet-trait-alias-bound-on-generic-impl.rs new file mode 100644 index 000000000..0b1f9ab57 --- /dev/null +++ b/tests/ui/traits/alias/issue-108132-unmet-trait-alias-bound-on-generic-impl.rs @@ -0,0 +1,15 @@ +// Regression test for #108132: do not ICE upon unmet trait alias constraint in generic impl + +#![feature(trait_alias)] + +trait IteratorAlias = Iterator; + +struct Foo<I>(I); + +impl<I: IteratorAlias> Foo<I> { + fn f() {} +} + +fn main() { + Foo::<()>::f() //~ trait bounds were not satisfied +} diff --git a/tests/ui/traits/alias/issue-108132-unmet-trait-alias-bound-on-generic-impl.stderr b/tests/ui/traits/alias/issue-108132-unmet-trait-alias-bound-on-generic-impl.stderr new file mode 100644 index 000000000..f1b259d5a --- /dev/null +++ b/tests/ui/traits/alias/issue-108132-unmet-trait-alias-bound-on-generic-impl.stderr @@ -0,0 +1,25 @@ +error[E0599]: the function or associated item `f` exists for struct `Foo<()>`, but its trait bounds were not satisfied + --> $DIR/issue-108132-unmet-trait-alias-bound-on-generic-impl.rs:14:16 + | +LL | struct Foo<I>(I); + | ------------- function or associated item `f` not found for this struct +... +LL | Foo::<()>::f() + | ^ function or associated item cannot be called on `Foo<()>` due to unsatisfied trait bounds + | +note: trait bound `(): Iterator` was not satisfied + --> $DIR/issue-108132-unmet-trait-alias-bound-on-generic-impl.rs:5:23 + | +LL | trait IteratorAlias = Iterator; + | ------------- ^^^^^^^^ unsatisfied trait bound introduced here +note: trait bound `(): IteratorAlias` was not satisfied + --> $DIR/issue-108132-unmet-trait-alias-bound-on-generic-impl.rs:9:9 + | +LL | impl<I: IteratorAlias> Foo<I> { + | ^^^^^^^^^^^^^ ------ + | | + | unsatisfied trait bound introduced here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/traits/alias/issue-60755.rs b/tests/ui/traits/alias/issue-60755.rs new file mode 100644 index 000000000..6b955a752 --- /dev/null +++ b/tests/ui/traits/alias/issue-60755.rs @@ -0,0 +1,12 @@ +// check-pass + +#![feature(trait_alias)] + +struct MyStruct {} +trait MyFn = Fn(&MyStruct); + +fn foo(_: impl MyFn) {} + +fn main() { + foo(|_| {}); +} diff --git a/tests/ui/traits/alias/self-in-generics.rs b/tests/ui/traits/alias/self-in-generics.rs index 0bb6335f9..dcb33b7a9 100644 --- a/tests/ui/traits/alias/self-in-generics.rs +++ b/tests/ui/traits/alias/self-in-generics.rs @@ -1,9 +1,5 @@ // astconv uses `FreshTy(0)` as a dummy `Self` type when instanciating trait objects. // This `FreshTy(0)` can leak into substs, causing ICEs in several places. -// Using `save-analysis` triggers type-checking `f` that would be normally skipped -// as `type_of` emitted an error. -// -// compile-flags: -Zsave-analysis #![feature(trait_alias)] diff --git a/tests/ui/traits/alias/self-in-generics.stderr b/tests/ui/traits/alias/self-in-generics.stderr index 110d60e6e..80af4e5aa 100644 --- a/tests/ui/traits/alias/self-in-generics.stderr +++ b/tests/ui/traits/alias/self-in-generics.stderr @@ -1,5 +1,5 @@ error[E0038]: the trait alias `SelfInput` cannot be made into an object - --> $DIR/self-in-generics.rs:12:19 + --> $DIR/self-in-generics.rs:8:19 | LL | pub fn f(_f: &dyn SelfInput) {} | ^^^^^^^^^ |