From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/traits/inductive-overflow/lifetime.rs | 32 ++++++++++++++++++++ .../ui/traits/inductive-overflow/lifetime.stderr | 22 ++++++++++++++ .../ui/traits/inductive-overflow/simultaneous.rs | 20 +++++++++++++ .../traits/inductive-overflow/simultaneous.stderr | 20 +++++++++++++ .../inductive-overflow/supertrait-auto-trait.rs | 18 +++++++++++ .../supertrait-auto-trait.stderr | 35 ++++++++++++++++++++++ .../ui/traits/inductive-overflow/supertrait.rs | 15 ++++++++++ .../ui/traits/inductive-overflow/supertrait.stderr | 20 +++++++++++++ .../ui/traits/inductive-overflow/two-traits.rs | 22 ++++++++++++++ .../ui/traits/inductive-overflow/two-traits.stderr | 32 ++++++++++++++++++++ 10 files changed, 236 insertions(+) create mode 100644 src/test/ui/traits/inductive-overflow/lifetime.rs create mode 100644 src/test/ui/traits/inductive-overflow/lifetime.stderr create mode 100644 src/test/ui/traits/inductive-overflow/simultaneous.rs create mode 100644 src/test/ui/traits/inductive-overflow/simultaneous.stderr create mode 100644 src/test/ui/traits/inductive-overflow/supertrait-auto-trait.rs create mode 100644 src/test/ui/traits/inductive-overflow/supertrait-auto-trait.stderr create mode 100644 src/test/ui/traits/inductive-overflow/supertrait.rs create mode 100644 src/test/ui/traits/inductive-overflow/supertrait.stderr create mode 100644 src/test/ui/traits/inductive-overflow/two-traits.rs create mode 100644 src/test/ui/traits/inductive-overflow/two-traits.stderr (limited to 'src/test/ui/traits/inductive-overflow') diff --git a/src/test/ui/traits/inductive-overflow/lifetime.rs b/src/test/ui/traits/inductive-overflow/lifetime.rs new file mode 100644 index 000000000..c36c17d3d --- /dev/null +++ b/src/test/ui/traits/inductive-overflow/lifetime.rs @@ -0,0 +1,32 @@ +// Test that we don't hit the recursion limit for short cycles involving lifetimes. + +// Shouldn't hit this, we should realize that we're in a cycle sooner. +#![recursion_limit="20"] + +trait NotAuto {} +trait Y { + type P; +} + +impl<'a> Y for C<'a> { + type P = Box>>; +} + +struct C<'a>(&'a ()); +struct X(T::P); + +impl NotAuto for Box {} //~ NOTE: required +impl NotAuto for X where T::P: NotAuto {} +impl<'a> NotAuto for C<'a> {} + +fn is_send() {} +//~^ NOTE: required +//~| NOTE: required + +fn main() { + // Should only be a few notes. + is_send::>>(); + //~^ ERROR overflow evaluating + //~| 3 redundant requirements hidden + //~| required because of +} diff --git a/src/test/ui/traits/inductive-overflow/lifetime.stderr b/src/test/ui/traits/inductive-overflow/lifetime.stderr new file mode 100644 index 000000000..9ca615aac --- /dev/null +++ b/src/test/ui/traits/inductive-overflow/lifetime.stderr @@ -0,0 +1,22 @@ +error[E0275]: overflow evaluating the requirement `X>: NotAuto` + --> $DIR/lifetime.rs:28:5 + | +LL | is_send::>>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: required because of the requirements on the impl of `NotAuto` for `Box>>` + --> $DIR/lifetime.rs:18:18 + | +LL | impl NotAuto for Box {} + | ^^^^^^^ ^^^^^^ + = note: 3 redundant requirements hidden + = note: required because of the requirements on the impl of `NotAuto` for `X>` +note: required by a bound in `is_send` + --> $DIR/lifetime.rs:22:15 + | +LL | fn is_send() {} + | ^^^^^^^ required by this bound in `is_send` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/traits/inductive-overflow/simultaneous.rs b/src/test/ui/traits/inductive-overflow/simultaneous.rs new file mode 100644 index 000000000..40ac92146 --- /dev/null +++ b/src/test/ui/traits/inductive-overflow/simultaneous.rs @@ -0,0 +1,20 @@ +// Regression test for #33344, initial version. This example allowed +// arbitrary trait bounds to be synthesized. + +trait Tweedledum: IntoIterator {} +trait Tweedledee: IntoIterator {} + +impl Tweedledee for T {} +impl Tweedledum for T {} + +trait Combo: IntoIterator {} +impl Combo for T {} + +fn is_ee(t: T) { + t.into_iter(); +} + +fn main() { + is_ee(4); + //~^ ERROR overflow evaluating the requirement `{integer}: Tweedle +} diff --git a/src/test/ui/traits/inductive-overflow/simultaneous.stderr b/src/test/ui/traits/inductive-overflow/simultaneous.stderr new file mode 100644 index 000000000..230c2638c --- /dev/null +++ b/src/test/ui/traits/inductive-overflow/simultaneous.stderr @@ -0,0 +1,20 @@ +error[E0275]: overflow evaluating the requirement `{integer}: Tweedledum` + --> $DIR/simultaneous.rs:18:5 + | +LL | is_ee(4); + | ^^^^^ + | +note: required because of the requirements on the impl of `Combo` for `{integer}` + --> $DIR/simultaneous.rs:11:34 + | +LL | impl Combo for T {} + | ^^^^^ ^ +note: required by a bound in `is_ee` + --> $DIR/simultaneous.rs:13:13 + | +LL | fn is_ee(t: T) { + | ^^^^^ required by this bound in `is_ee` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/traits/inductive-overflow/supertrait-auto-trait.rs b/src/test/ui/traits/inductive-overflow/supertrait-auto-trait.rs new file mode 100644 index 000000000..5fea47a1b --- /dev/null +++ b/src/test/ui/traits/inductive-overflow/supertrait-auto-trait.rs @@ -0,0 +1,18 @@ +// Auto-trait-based version of #29859, supertrait version. Test that using +// a simple auto trait `..` impl alone still doesn't allow arbitrary bounds +// to be synthesized. + +#![feature(auto_traits)] +#![feature(negative_impls)] + +auto trait Magic: Copy {} //~ ERROR E0568 + +fn copy(x: T) -> (T, T) { (x, x) } + +#[derive(Debug)] +struct NoClone; + +fn main() { + let (a, b) = copy(NoClone); //~ ERROR + println!("{:?} {:?}", a, b); +} diff --git a/src/test/ui/traits/inductive-overflow/supertrait-auto-trait.stderr b/src/test/ui/traits/inductive-overflow/supertrait-auto-trait.stderr new file mode 100644 index 000000000..d7697dcc6 --- /dev/null +++ b/src/test/ui/traits/inductive-overflow/supertrait-auto-trait.stderr @@ -0,0 +1,35 @@ +error[E0568]: auto traits cannot have super traits or lifetime bounds + --> $DIR/supertrait-auto-trait.rs:8:17 + | +LL | auto trait Magic: Copy {} + | -----^^^^^^ help: remove the super traits or lifetime bounds + | | + | auto trait cannot have super traits or lifetime bounds + +error[E0277]: the trait bound `NoClone: Copy` is not satisfied + --> $DIR/supertrait-auto-trait.rs:16:23 + | +LL | let (a, b) = copy(NoClone); + | ---- ^^^^^^^ the trait `Copy` is not implemented for `NoClone` + | | + | required by a bound introduced by this call + | +note: required because of the requirements on the impl of `Magic` for `NoClone` + --> $DIR/supertrait-auto-trait.rs:8:12 + | +LL | auto trait Magic: Copy {} + | ^^^^^ +note: required by a bound in `copy` + --> $DIR/supertrait-auto-trait.rs:10:12 + | +LL | fn copy(x: T) -> (T, T) { (x, x) } + | ^^^^^ required by this bound in `copy` +help: consider annotating `NoClone` with `#[derive(Copy)]` + | +LL | #[derive(Copy)] + | + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0277, E0568. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/traits/inductive-overflow/supertrait.rs b/src/test/ui/traits/inductive-overflow/supertrait.rs new file mode 100644 index 000000000..c7aa4d90f --- /dev/null +++ b/src/test/ui/traits/inductive-overflow/supertrait.rs @@ -0,0 +1,15 @@ +// Regression test for #29859, supertrait version. This example +// allowed arbitrary trait bounds to be synthesized. + +trait Magic: Copy {} +impl Magic for T {} + +fn copy(x: T) -> (T, T) { (x, x) } + +#[derive(Debug)] +struct NoClone; + +fn main() { + let (a, b) = copy(NoClone); //~ ERROR E0275 + println!("{:?} {:?}", a, b); +} diff --git a/src/test/ui/traits/inductive-overflow/supertrait.stderr b/src/test/ui/traits/inductive-overflow/supertrait.stderr new file mode 100644 index 000000000..95325a534 --- /dev/null +++ b/src/test/ui/traits/inductive-overflow/supertrait.stderr @@ -0,0 +1,20 @@ +error[E0275]: overflow evaluating the requirement `NoClone: Magic` + --> $DIR/supertrait.rs:13:18 + | +LL | let (a, b) = copy(NoClone); + | ^^^^ + | +note: required because of the requirements on the impl of `Magic` for `NoClone` + --> $DIR/supertrait.rs:5:16 + | +LL | impl Magic for T {} + | ^^^^^ ^ +note: required by a bound in `copy` + --> $DIR/supertrait.rs:7:12 + | +LL | fn copy(x: T) -> (T, T) { (x, x) } + | ^^^^^ required by this bound in `copy` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/traits/inductive-overflow/two-traits.rs b/src/test/ui/traits/inductive-overflow/two-traits.rs new file mode 100644 index 000000000..463b55d85 --- /dev/null +++ b/src/test/ui/traits/inductive-overflow/two-traits.rs @@ -0,0 +1,22 @@ +// Regression test for #29859, initial version. This example allowed +// arbitrary trait bounds to be synthesized. + +// Trait that you want all types to implement. +use std::marker::{Sync as Trait}; + +pub trait Magic { + type X: Trait; +} +impl Magic for T { + type X = Self; + //~^ ERROR E0277 +} + +fn check() {} + +fn wizard() { check::<::X>(); } + +fn main() { + wizard::<*mut ()>(); //~ ERROR E0275 + // check::<*mut ()>(); +} diff --git a/src/test/ui/traits/inductive-overflow/two-traits.stderr b/src/test/ui/traits/inductive-overflow/two-traits.stderr new file mode 100644 index 000000000..0d0bf8861 --- /dev/null +++ b/src/test/ui/traits/inductive-overflow/two-traits.stderr @@ -0,0 +1,32 @@ +error[E0277]: `T` cannot be shared between threads safely + --> $DIR/two-traits.rs:11:14 + | +LL | type X = Self; + | ^^^^ `T` cannot be shared between threads safely + | +note: required by a bound in `Magic::X` + --> $DIR/two-traits.rs:8:13 + | +LL | type X: Trait; + | ^^^^^ required by this bound in `Magic::X` +help: consider further restricting this bound + | +LL | impl Magic for T { + | +++++++++++++++++++ + +error[E0275]: overflow evaluating the requirement `*mut (): Magic` + --> $DIR/two-traits.rs:20:5 + | +LL | wizard::<*mut ()>(); + | ^^^^^^^^^^^^^^^^^ + | +note: required by a bound in `wizard` + --> $DIR/two-traits.rs:17:14 + | +LL | fn wizard() { check::<::X>(); } + | ^^^^^ required by this bound in `wizard` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0275, E0277. +For more information about an error, try `rustc --explain E0275`. -- cgit v1.2.3