diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-06-04 13:55:15 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-07-24 16:00:48 +0000 |
| commit | 548c44760f14c4547971e0359715f871ce9867bd (patch) | |
| tree | 411cae2ec902daba289473357a9b4fd420ee8ad6 | |
| parent | acba6449f8597c85b450d96eccda31025cdc0049 (diff) | |
| download | rust-548c44760f14c4547971e0359715f871ce9867bd.tar.gz rust-548c44760f14c4547971e0359715f871ce9867bd.zip | |
Add regression tests
| -rw-r--r-- | tests/ui/impl-trait/auto-trait-selection-freeze.next.stderr | 22 | ||||
| -rw-r--r-- | tests/ui/impl-trait/auto-trait-selection-freeze.rs | 24 | ||||
| -rw-r--r-- | tests/ui/impl-trait/auto-trait-selection.next.stderr | 22 | ||||
| -rw-r--r-- | tests/ui/impl-trait/auto-trait-selection.rs | 20 |
4 files changed, 88 insertions, 0 deletions
diff --git a/tests/ui/impl-trait/auto-trait-selection-freeze.next.stderr b/tests/ui/impl-trait/auto-trait-selection-freeze.next.stderr new file mode 100644 index 00000000000..d9192e85497 --- /dev/null +++ b/tests/ui/impl-trait/auto-trait-selection-freeze.next.stderr @@ -0,0 +1,22 @@ +error[E0283]: type annotations needed + --> $DIR/auto-trait-selection-freeze.rs:20:16 + | +LL | if false { is_trait(foo()) } else { Default::default() } + | ^^^^^^^^ ----- type must be known at this point + | | + | cannot infer type of the type parameter `T` declared on the function `is_trait` + | + = note: cannot satisfy `_: Trait<_>` +note: required by a bound in `is_trait` + --> $DIR/auto-trait-selection-freeze.rs:12:16 + | +LL | fn is_trait<T: Trait<U>, U: Default>(_: T) -> U { + | ^^^^^^^^ required by this bound in `is_trait` +help: consider specifying the generic arguments + | +LL | if false { is_trait::<T, U>(foo()) } else { Default::default() } + | ++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0283`. diff --git a/tests/ui/impl-trait/auto-trait-selection-freeze.rs b/tests/ui/impl-trait/auto-trait-selection-freeze.rs new file mode 100644 index 00000000000..72c24c51962 --- /dev/null +++ b/tests/ui/impl-trait/auto-trait-selection-freeze.rs @@ -0,0 +1,24 @@ +//! This test shows how we fail selection in a way that can influence +//! selection in a code path that succeeds. + +//@ revisions: next old +//@[next] compile-flags: -Znext-solver +//@[old]check-pass + +#![feature(freeze)] + +use std::marker::Freeze; + +fn is_trait<T: Trait<U>, U: Default>(_: T) -> U { + Default::default() +} + +trait Trait<T> {} +impl<T: Freeze> Trait<u32> for T {} +impl<T> Trait<i32> for T {} +fn foo() -> impl Sized { + if false { is_trait(foo()) } else { Default::default() } + //[next]~^ ERROR: type annotations needed +} + +fn main() {} diff --git a/tests/ui/impl-trait/auto-trait-selection.next.stderr b/tests/ui/impl-trait/auto-trait-selection.next.stderr new file mode 100644 index 00000000000..2e8d7ad99b2 --- /dev/null +++ b/tests/ui/impl-trait/auto-trait-selection.next.stderr @@ -0,0 +1,22 @@ +error[E0283]: type annotations needed + --> $DIR/auto-trait-selection.rs:16:16 + | +LL | if false { is_trait(foo()) } else { Default::default() } + | ^^^^^^^^ ----- type must be known at this point + | | + | cannot infer type of the type parameter `T` declared on the function `is_trait` + | + = note: cannot satisfy `_: Trait<_>` +note: required by a bound in `is_trait` + --> $DIR/auto-trait-selection.rs:8:16 + | +LL | fn is_trait<T: Trait<U>, U: Default>(_: T) -> U { + | ^^^^^^^^ required by this bound in `is_trait` +help: consider specifying the generic arguments + | +LL | if false { is_trait::<T, U>(foo()) } else { Default::default() } + | ++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0283`. diff --git a/tests/ui/impl-trait/auto-trait-selection.rs b/tests/ui/impl-trait/auto-trait-selection.rs new file mode 100644 index 00000000000..beb0b189fd7 --- /dev/null +++ b/tests/ui/impl-trait/auto-trait-selection.rs @@ -0,0 +1,20 @@ +//! This test shows how we fail selection in a way that can influence +//! selection in a code path that succeeds. + +//@ revisions: next old +//@[next] compile-flags: -Znext-solver +//@[old]check-pass + +fn is_trait<T: Trait<U>, U: Default>(_: T) -> U { + Default::default() +} + +trait Trait<T> {} +impl<T: Send> Trait<u32> for T {} +impl<T> Trait<i32> for T {} +fn foo() -> impl Sized { + if false { is_trait(foo()) } else { Default::default() } + //[next]~^ ERROR: type annotations needed +} + +fn main() {} |
