From 17d40c6057c88f4c432b0d7bac88e1b84cb7e67f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:03:36 +0200 Subject: Adding upstream version 1.65.0+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/traits/alias/cross-crate.stderr | 4 +-- src/test/ui/traits/alias/generic-default-in-dyn.rs | 10 ++++++ .../ui/traits/alias/generic-default-in-dyn.stderr | 39 ++++++++++++++++++++++ src/test/ui/traits/alias/self-in-const-generics.rs | 12 +++++++ .../ui/traits/alias/self-in-const-generics.stderr | 11 ++++++ src/test/ui/traits/alias/self-in-generics.rs | 15 +++++++++ src/test/ui/traits/alias/self-in-generics.stderr | 11 ++++++ 7 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 src/test/ui/traits/alias/generic-default-in-dyn.rs create mode 100644 src/test/ui/traits/alias/generic-default-in-dyn.stderr create mode 100644 src/test/ui/traits/alias/self-in-const-generics.rs create mode 100644 src/test/ui/traits/alias/self-in-const-generics.stderr create mode 100644 src/test/ui/traits/alias/self-in-generics.rs create mode 100644 src/test/ui/traits/alias/self-in-generics.stderr (limited to 'src/test/ui/traits/alias') diff --git a/src/test/ui/traits/alias/cross-crate.stderr b/src/test/ui/traits/alias/cross-crate.stderr index d0d00c97e..ae9d7d0a9 100644 --- a/src/test/ui/traits/alias/cross-crate.stderr +++ b/src/test/ui/traits/alias/cross-crate.stderr @@ -5,7 +5,7 @@ LL | use_alias::>(); | ^^^^^^^ `Rc` cannot be sent between threads safely | = help: the trait `Send` is not implemented for `Rc` - = note: required because of the requirements on the impl of `SendSync` for `Rc` + = note: required for `Rc` to implement `SendSync` note: required by a bound in `use_alias` --> $DIR/cross-crate.rs:10:17 | @@ -19,7 +19,7 @@ LL | use_alias::>(); | ^^^^^^^ `Rc` cannot be shared between threads safely | = help: the trait `Sync` is not implemented for `Rc` - = note: required because of the requirements on the impl of `SendSync` for `Rc` + = note: required for `Rc` to implement `SendSync` note: required by a bound in `use_alias` --> $DIR/cross-crate.rs:10:17 | diff --git a/src/test/ui/traits/alias/generic-default-in-dyn.rs b/src/test/ui/traits/alias/generic-default-in-dyn.rs new file mode 100644 index 000000000..d44e1c2a9 --- /dev/null +++ b/src/test/ui/traits/alias/generic-default-in-dyn.rs @@ -0,0 +1,10 @@ +trait SendEqAlias = PartialEq; +//~^ ERROR trait aliases are experimental + +struct Foo(dyn SendEqAlias); +//~^ ERROR the type parameter `Rhs` must be explicitly specified [E0393] + +struct Bar(dyn SendEqAlias, T); +//~^ ERROR the type parameter `Rhs` must be explicitly specified [E0393] + +fn main() {} diff --git a/src/test/ui/traits/alias/generic-default-in-dyn.stderr b/src/test/ui/traits/alias/generic-default-in-dyn.stderr new file mode 100644 index 000000000..76a068e86 --- /dev/null +++ b/src/test/ui/traits/alias/generic-default-in-dyn.stderr @@ -0,0 +1,39 @@ +error[E0658]: trait aliases are experimental + --> $DIR/generic-default-in-dyn.rs:1:1 + | +LL | trait SendEqAlias = PartialEq; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #41517 for more information + = help: add `#![feature(trait_alias)]` to the crate attributes to enable + +error[E0393]: the type parameter `Rhs` must be explicitly specified + --> $DIR/generic-default-in-dyn.rs:4:19 + | +LL | struct Foo(dyn SendEqAlias); + | ^^^^^^^^^^^^^^ missing reference to `Rhs` + | + ::: $SRC_DIR/core/src/cmp.rs:LL:COL + | +LL | pub trait PartialEq { + | --------------------------------------- type parameter `Rhs` must be specified for this + | + = note: because of the default `Self` reference, type parameters must be specified on object types + +error[E0393]: the type parameter `Rhs` must be explicitly specified + --> $DIR/generic-default-in-dyn.rs:7:19 + | +LL | struct Bar(dyn SendEqAlias, T); + | ^^^^^^^^^^^^^^ missing reference to `Rhs` + | + ::: $SRC_DIR/core/src/cmp.rs:LL:COL + | +LL | pub trait PartialEq { + | --------------------------------------- type parameter `Rhs` must be specified for this + | + = note: because of the default `Self` reference, type parameters must be specified on object types + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0393, E0658. +For more information about an error, try `rustc --explain E0393`. diff --git a/src/test/ui/traits/alias/self-in-const-generics.rs b/src/test/ui/traits/alias/self-in-const-generics.rs new file mode 100644 index 000000000..b0de8ccd6 --- /dev/null +++ b/src/test/ui/traits/alias/self-in-const-generics.rs @@ -0,0 +1,12 @@ +#![allow(incomplete_features)] +#![feature(generic_const_exprs)] +#![feature(trait_alias)] + +trait Bar {} + +trait BB = Bar<{ 2 + 1 }>; + +fn foo(x: &dyn BB) {} +//~^ ERROR the trait alias `BB` cannot be made into an object [E0038] + +fn main() {} diff --git a/src/test/ui/traits/alias/self-in-const-generics.stderr b/src/test/ui/traits/alias/self-in-const-generics.stderr new file mode 100644 index 000000000..61cc217cf --- /dev/null +++ b/src/test/ui/traits/alias/self-in-const-generics.stderr @@ -0,0 +1,11 @@ +error[E0038]: the trait alias `BB` cannot be made into an object + --> $DIR/self-in-const-generics.rs:9:16 + | +LL | fn foo(x: &dyn BB) {} + | ^^ + | + = note: it cannot use `Self` as a type parameter in a supertrait or `where`-clause + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/traits/alias/self-in-generics.rs b/src/test/ui/traits/alias/self-in-generics.rs new file mode 100644 index 000000000..0bb6335f9 --- /dev/null +++ b/src/test/ui/traits/alias/self-in-generics.rs @@ -0,0 +1,15 @@ +// 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)] + +pub trait SelfInput = Fn(&mut Self); + +pub fn f(_f: &dyn SelfInput) {} +//~^ ERROR the trait alias `SelfInput` cannot be made into an object [E0038] + +fn main() {} diff --git a/src/test/ui/traits/alias/self-in-generics.stderr b/src/test/ui/traits/alias/self-in-generics.stderr new file mode 100644 index 000000000..110d60e6e --- /dev/null +++ b/src/test/ui/traits/alias/self-in-generics.stderr @@ -0,0 +1,11 @@ +error[E0038]: the trait alias `SelfInput` cannot be made into an object + --> $DIR/self-in-generics.rs:12:19 + | +LL | pub fn f(_f: &dyn SelfInput) {} + | ^^^^^^^^^ + | + = note: it cannot use `Self` as a type parameter in a supertrait or `where`-clause + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0038`. -- cgit v1.2.3