diff options
| author | bors <bors@rust-lang.org> | 2024-12-06 04:55:35 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-12-06 04:55:35 +0000 |
| commit | acf48426b64d24f372d534f634072de1f4c7e588 (patch) | |
| tree | 6bd232dc178f934a8845163d09b87031912380f3 /tests | |
| parent | 706141b8d9090228343340378b1d4a2b095fa1fb (diff) | |
| parent | 0cf93703a51f29660572cd680ab09b44255b37b4 (diff) | |
| download | rust-acf48426b64d24f372d534f634072de1f4c7e588.tar.gz rust-acf48426b64d24f372d534f634072de1f4c7e588.zip | |
Auto merge of #133559 - compiler-errors:structurally-resolve-adjust-for-branch, r=lcnr
Structurally resolve in `adjust_for_branches` r? lcnr
Diffstat (limited to 'tests')
4 files changed, 42 insertions, 34 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 index 5caf0eb2fd4..54ceec0aff5 100644 --- a/tests/ui/impl-trait/auto-trait-selection-freeze.next.stderr +++ b/tests/ui/impl-trait/auto-trait-selection-freeze.next.stderr @@ -1,22 +1,9 @@ -error[E0283]: type annotations needed - --> $DIR/auto-trait-selection-freeze.rs:19:16 +error[E0284]: type annotations needed: cannot satisfy `impl Sized == _` + --> $DIR/auto-trait-selection-freeze.rs:19:5 | 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:11: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() } - | ++++++++ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `impl Sized == _` error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0283`. +For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/impl-trait/auto-trait-selection.next.stderr b/tests/ui/impl-trait/auto-trait-selection.next.stderr index d34fdcc4496..7acb9fd41b7 100644 --- a/tests/ui/impl-trait/auto-trait-selection.next.stderr +++ b/tests/ui/impl-trait/auto-trait-selection.next.stderr @@ -1,22 +1,9 @@ -error[E0283]: type annotations needed - --> $DIR/auto-trait-selection.rs:15:16 +error[E0284]: type annotations needed: cannot satisfy `impl Sized == _` + --> $DIR/auto-trait-selection.rs:15:5 | 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:7: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() } - | ++++++++ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `impl Sized == _` error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0283`. +For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/traits/next-solver/typeck/resolve-expectations.rs b/tests/ui/traits/next-solver/typeck/resolve-expectations.rs new file mode 100644 index 00000000000..d6b3816b9eb --- /dev/null +++ b/tests/ui/traits/next-solver/typeck/resolve-expectations.rs @@ -0,0 +1,26 @@ +//@ check-pass +//@ compile-flags: -Znext-solver + +trait Mirror { + type Assoc; +} +impl<T> Mirror for T { + type Assoc = T; +} + +fn id<T>(t: T) -> T { t } + +trait Foo {} +impl Foo for i32 {} +impl Foo for u32 {} + +fn main() { + // Make sure we resolve expected pointee of addr-of. + id::<<&&dyn Foo as Mirror>::Assoc>(&id(&1)); + + // Make sure we resolve expected element of array. + id::<<[Box<dyn Foo>; 2] as Mirror>::Assoc>([Box::new(1i32), Box::new(1u32)]); + + // Make sure we resolve expected element of tuple. + id::<<(Box<dyn Foo>,) as Mirror>::Assoc>((Box::new(1i32),)); +} diff --git a/tests/ui/traits/next-solver/typeck/structurally-resolve-in-resolve_for_branch.rs b/tests/ui/traits/next-solver/typeck/structurally-resolve-in-resolve_for_branch.rs new file mode 100644 index 00000000000..d406f3949a2 --- /dev/null +++ b/tests/ui/traits/next-solver/typeck/structurally-resolve-in-resolve_for_branch.rs @@ -0,0 +1,8 @@ +//@ compile-flags: -Znext-solver +//@ check-pass + +pub fn repro() -> impl FnMut() { + if true { || () } else { || () } +} + +fn main() {} |
