From 527cfb1f0eb63332ecf796bfedbcae962a9f0893 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Mon, 20 Nov 2023 20:29:38 +0000 Subject: [PATCH] Add new solver / old solver opaque type tests When considering an opaque type within a body that is permitted to define the hidden type for that opaque, we're expecting the new trait solver to sometimes produce different results. Sometimes this is due to the fact that the new trait solver considers more cases to be defining, such as when defining the hidden type allows an impl for some wrapper type to be matched. In other cases, this is due to lazy normalization, which e.g. allows the new trait solver to more consistently handle as a concrete type the return value of... ```rust id2(_: T, x: T ) -> T { x } ``` ...when it is called with a value of the opaque type and a value of the corresponding hidden type. However, the new trait solver is not yet done, and it does not consistently produce the results we expect that it will once complete. As we work toward stabilizing type alias impl Trait (TAIT), we need to plan for what the behavior of the new trait solver will be. Similarly, since return position impl Trait (RPIT) is already stable but will see inference differences with the new trait solver, we need to begin to plan for that also. To help enable this planning, let's add test cases that define what the correct inference behavior should be when handling opaue types. The goal of this commit is to prompt discussion and ensure there is a consensus on this behavior, then to document that behavior in these tests. Where the correct behavior does not match the behavior of either the new or the old trait solver, we've chosen to mark that as a known bug. For the new solver, we've done this since it is still a work in progress and is expected to eventually model the correct behavior. For the old solver, we've done this since the behavior is inconsistent and often surprising, and since we may need to add future-incompat lints or take other steps to prepare the ecosystem for the transition to the new solver. --- tests/ui/impl-trait/inference/README.md | 43 +++++++++++++ ...uto-trait-notsend-inner-id-left.old.stderr | 23 +++++++ ...reveal-auto-trait-notsend-inner-id-left.rs | 37 +++++++++++ ...eveal-auto-trait-notsend-inner-id-right.rs | 36 +++++++++++ ...uto-trait-notsend-outer-id-left.old.stderr | 23 +++++++ ...reveal-auto-trait-notsend-outer-id-left.rs | 37 +++++++++++ ...eveal-auto-trait-notsend-outer-id-right.rs | 36 +++++++++++ .../reveal-auto-trait-notsend.old.stderr | 23 +++++++ .../reveal-auto-trait-notsend.rs | 33 ++++++++++ ...l-auto-trait-send-inner-id-left.old.stderr | 32 ++++++++++ .../reveal-auto-trait-send-inner-id-left.rs | 36 +++++++++++ .../reveal-auto-trait-send-inner-id-right.rs | 35 +++++++++++ ...l-auto-trait-send-outer-id-left.old.stderr | 32 ++++++++++ .../reveal-auto-trait-send-outer-id-left.rs | 36 +++++++++++ .../reveal-auto-trait-send-outer-id-right.rs | 35 +++++++++++ .../reveal-auto-trait-send.old.stderr | 32 ++++++++++ .../reveal-auto-trait-send.rs | 32 ++++++++++ ...hidden-via-field-access-id-left.new.stderr | 9 +++ ...hidden-via-field-access-id-left.old.stderr | 9 +++ .../reveal-hidden-via-field-access-id-left.rs | 22 +++++++ ...reveal-hidden-via-field-access-id-right.rs | 22 +++++++ .../reveal-hidden-via-field-access.new.stderr | 9 +++ .../reveal-hidden-via-field-access.old.stderr | 9 +++ .../reveal-hidden-via-field-access.rs | 18 ++++++ ...ch-at-binding-unwrapped-id-left.new.stderr | 9 +++ ...ch-at-binding-unwrapped-id-left.old.stderr | 9 +++ ...-via-match-at-binding-unwrapped-id-left.rs | 37 +++++++++++ ...via-match-at-binding-unwrapped-id-right.rs | 36 +++++++++++ ...-via-match-at-binding-unwrapped.new.stderr | 9 +++ ...-via-match-at-binding-unwrapped.old.stderr | 9 +++ ...l-hidden-via-match-at-binding-unwrapped.rs | 33 ++++++++++ ...-at-binding-wrapped-onw-id-left.old.stderr | 9 +++ ...ia-match-at-binding-wrapped-onw-id-left.rs | 38 +++++++++++ ...a-match-at-binding-wrapped-onw-id-right.rs | 37 +++++++++++ ...ia-match-at-binding-wrapped-onw.old.stderr | 9 +++ ...hidden-via-match-at-binding-wrapped-onw.rs | 34 ++++++++++ ...t-binding-wrapped-wonly-id-left.old.stderr | 36 +++++++++++ ...-match-at-binding-wrapped-wonly-id-left.rs | 28 +++++++++ ...match-at-binding-wrapped-wonly-id-right.rs | 27 ++++++++ ...-match-at-binding-wrapped-wonly.old.stderr | 36 +++++++++++ ...dden-via-match-at-binding-wrapped-wonly.rs | 28 +++++++++ ...ch-exhaustiveness-empty-id-left.new.stderr | 17 +++++ ...ch-exhaustiveness-empty-id-left.old.stderr | 17 +++++ ...-via-match-exhaustiveness-empty-id-left.rs | 19 ++++++ ...h-exhaustiveness-empty-id-right.new.stderr | 17 +++++ ...h-exhaustiveness-empty-id-right.old.stderr | 17 +++++ ...via-match-exhaustiveness-empty-id-right.rs | 19 ++++++ ...-via-match-exhaustiveness-empty.new.stderr | 17 +++++ ...-via-match-exhaustiveness-empty.old.stderr | 17 +++++ ...l-hidden-via-match-exhaustiveness-empty.rs | 19 ++++++ ...n-via-match-exhaustiveness-unit-id-left.rs | 18 ++++++ ...-via-match-exhaustiveness-unit-id-right.rs | 18 ++++++ ...al-hidden-via-match-exhaustiveness-unit.rs | 18 ++++++ .../reveal-hidden-via-match-tuple-id-left.rs | 35 +++++++++++ .../reveal-hidden-via-match-tuple-id-right.rs | 35 +++++++++++ .../reveal-hidden-via-match-tuple.rs | 35 +++++++++++ ...-via-unwrapped-receiver-id-left.new.stderr | 11 ++++ ...-via-unwrapped-receiver-id-left.old.stderr | 11 ++++ ...l-hidden-via-unwrapped-receiver-id-left.rs | 34 ++++++++++ ...-hidden-via-unwrapped-receiver-id-right.rs | 33 ++++++++++ ...l-hidden-via-unwrapped-receiver.new.stderr | 11 ++++ ...l-hidden-via-unwrapped-receiver.old.stderr | 11 ++++ .../reveal-hidden-via-unwrapped-receiver.rs | 30 +++++++++ ...-wrapped-receiver-inner-id-left.old.stderr | 11 ++++ ...dden-via-wrapped-receiver-inner-id-left.rs | 33 ++++++++++ ...den-via-wrapped-receiver-inner-id-right.rs | 32 ++++++++++ ...-wrapped-receiver-outer-id-left.old.stderr | 11 ++++ ...dden-via-wrapped-receiver-outer-id-left.rs | 33 ++++++++++ ...den-via-wrapped-receiver-outer-id-right.rs | 32 ++++++++++ ...eal-hidden-via-wrapped-receiver.old.stderr | 11 ++++ .../reveal-hidden-via-wrapped-receiver.rs | 29 +++++++++ ...uto-trait-notsend-inner-id-left.old.stderr | 23 +++++++ ...reveal-auto-trait-notsend-inner-id-left.rs | 41 ++++++++++++ ...eveal-auto-trait-notsend-inner-id-right.rs | 40 ++++++++++++ ...uto-trait-notsend-outer-id-left.old.stderr | 23 +++++++ ...reveal-auto-trait-notsend-outer-id-left.rs | 41 ++++++++++++ ...eveal-auto-trait-notsend-outer-id-right.rs | 40 ++++++++++++ .../reveal-auto-trait-notsend.new.stderr | 11 ++++ .../reveal-auto-trait-notsend.old.stderr | 23 +++++++ .../reveal-auto-trait-notsend.rs | 40 ++++++++++++ ...l-auto-trait-send-inner-id-left.new.stderr | 63 +++++++++++++++++++ ...l-auto-trait-send-inner-id-left.old.stderr | 32 ++++++++++ .../reveal-auto-trait-send-inner-id-left.rs | 40 ++++++++++++ .../reveal-auto-trait-send-inner-id-right.rs | 40 ++++++++++++ ...l-auto-trait-send-outer-id-left.new.stderr | 63 +++++++++++++++++++ ...l-auto-trait-send-outer-id-left.old.stderr | 32 ++++++++++ .../reveal-auto-trait-send-outer-id-left.rs | 40 ++++++++++++ .../reveal-auto-trait-send-outer-id-right.rs | 40 ++++++++++++ .../reveal-auto-trait-send.new.stderr | 12 ++++ .../reveal-auto-trait-send.old.stderr | 32 ++++++++++ .../reveal-auto-trait-send.rs | 40 ++++++++++++ ...-via-unwrapped-receiver-id-left.new.stderr | 11 ++++ ...-via-unwrapped-receiver-id-left.old.stderr | 37 +++++++++++ ...l-hidden-via-unwrapped-receiver-id-left.rs | 40 ++++++++++++ ...-hidden-via-unwrapped-receiver-id-right.rs | 39 ++++++++++++ ...l-hidden-via-unwrapped-receiver.new.stderr | 11 ++++ ...l-hidden-via-unwrapped-receiver.old.stderr | 37 +++++++++++ .../reveal-hidden-via-unwrapped-receiver.rs | 36 +++++++++++ ...-wrapped-receiver-inner-id-left.old.stderr | 11 ++++ ...dden-via-wrapped-receiver-inner-id-left.rs | 38 +++++++++++ ...den-via-wrapped-receiver-inner-id-right.rs | 37 +++++++++++ ...-wrapped-receiver-outer-id-left.old.stderr | 11 ++++ ...dden-via-wrapped-receiver-outer-id-left.rs | 38 +++++++++++ ...den-via-wrapped-receiver-outer-id-right.rs | 37 +++++++++++ ...eal-hidden-via-wrapped-receiver.old.stderr | 11 ++++ .../reveal-hidden-via-wrapped-receiver.rs | 34 ++++++++++ 106 files changed, 2878 insertions(+) create mode 100644 tests/ui/impl-trait/inference/README.md create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend-inner-id-left.old.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend-inner-id-left.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend-inner-id-right.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend-outer-id-left.old.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend-outer-id-left.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend-outer-id-right.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend.old.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send-inner-id-left.old.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send-inner-id-left.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send-inner-id-right.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send-outer-id-left.old.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send-outer-id-left.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send-outer-id-right.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send.old.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access-id-left.new.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access-id-left.old.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access-id-left.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access-id-right.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access.new.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access.old.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped-id-left.new.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped-id-left.old.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped-id-left.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped-id-right.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped.new.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped.old.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-onw-id-left.old.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-onw-id-left.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-onw-id-right.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-onw.old.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-onw.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-wonly-id-left.old.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-wonly-id-left.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-wonly-id-right.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-wonly.old.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-wonly.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty-id-left.new.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty-id-left.old.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty-id-left.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty-id-right.new.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty-id-right.old.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty-id-right.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty.new.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty.old.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-unit-id-left.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-unit-id-right.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-unit.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-tuple-id-left.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-tuple-id-right.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-tuple.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver-id-left.new.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver-id-left.old.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver-id-left.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver-id-right.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver.new.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver.old.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver-inner-id-left.old.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver-inner-id-left.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver-inner-id-right.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver-outer-id-left.old.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver-outer-id-left.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver-outer-id-right.rs create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver.old.stderr create mode 100644 tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver.rs create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend-inner-id-left.old.stderr create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend-inner-id-left.rs create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend-inner-id-right.rs create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend-outer-id-left.old.stderr create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend-outer-id-left.rs create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend-outer-id-right.rs create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend.new.stderr create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend.old.stderr create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend.rs create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-inner-id-left.new.stderr create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-inner-id-left.old.stderr create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-inner-id-left.rs create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-inner-id-right.rs create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-outer-id-left.new.stderr create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-outer-id-left.old.stderr create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-outer-id-left.rs create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-outer-id-right.rs create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send.new.stderr create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send.old.stderr create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send.rs create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver-id-left.new.stderr create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver-id-left.old.stderr create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver-id-left.rs create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver-id-right.rs create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver.new.stderr create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver.old.stderr create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver.rs create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver-inner-id-left.old.stderr create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver-inner-id-left.rs create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver-inner-id-right.rs create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver-outer-id-left.old.stderr create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver-outer-id-left.rs create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver-outer-id-right.rs create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver.old.stderr create mode 100644 tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver.rs diff --git a/tests/ui/impl-trait/inference/README.md b/tests/ui/impl-trait/inference/README.md new file mode 100644 index 0000000000000..f8573d984bdd0 --- /dev/null +++ b/tests/ui/impl-trait/inference/README.md @@ -0,0 +1,43 @@ +# Inference tests on opaque types in defining items + +When considering an opaque type within a body that is permitted to +define the hidden type for that opaque, we're expecting the new trait +solver to sometimes produce different results. + +Sometimes this is due to the fact that the new trait solver considers +more cases to be defining, such as when defining the hidden type +allows an impl for some wrapper type to be matched. + +In other cases, this is due to lazy normalization, which e.g. allows +the new trait solver to more consistently handle as a concrete type +the return value of... + +```rust +id2(_: T, x: T ) -> T { x } +``` + +...when it is called with a value of the opaque type and a value of +the corresponding hidden type. + +However, the new trait solver is not yet done, and it does not +consistently produce the results we expect that it will once +complete. + +As we work toward stabilizing type alias impl Trait (TAIT), we need to +plan for what the behavior of the new trait solver will be. +Similarly, since return position impl Trait (RPIT) is already stable +but will see inference differences with the new trait solver, we need +to begin to plan for that also. + +To help enable this planning, this directory contains test cases that +define what the correct inference behavior should be when handling +opaue types. + +Where the correct behavior does not match the behavior of either the +new or the old trait solver, we've chosen to mark that as a known +bug. For the new solver, we've done this since it is still a work in +progress and is expected to eventually model the correct behavior. +For the old solver, we've done this since the behavior is inconsistent +and often surprising, and since we may need to add future-incompat +lints or take other steps to prepare the ecosystem for the transition +to the new solver. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend-inner-id-left.old.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend-inner-id-left.old.stderr new file mode 100644 index 0000000000000..e0bdbffdab978 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend-inner-id-left.old.stderr @@ -0,0 +1,23 @@ +error[E0391]: cycle detected when computing type of opaque `test::{opaque#0}` + --> $DIR/reveal-auto-trait-notsend-inner-id-left.rs:31:21 + | +LL | fn test(n: bool) -> impl Sized { + | ^^^^^^^^^^ + | +note: ...which requires type-checking `test`... + --> $DIR/reveal-auto-trait-notsend-inner-id-left.rs:33:61 + | +LL | let _: OnWShow = (&&W(id2(test(!n), &() as *const ()))).show(); + | ^^^^ + = note: ...which requires evaluating trait selection obligation `&'a W: OnWSend`... + = note: ...which again requires computing type of opaque `test::{opaque#0}`, completing the cycle +note: cycle used when computing type of `test::{opaque#0}` + --> $DIR/reveal-auto-trait-notsend-inner-id-left.rs:31:21 + | +LL | fn test(n: bool) -> impl Sized { + | ^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend-inner-id-left.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend-inner-id-left.rs new file mode 100644 index 0000000000000..cbbfd4a66945c --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend-inner-id-left.rs @@ -0,0 +1,37 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// [new]check-pass +// [old]known-bug: unknown + +struct W(T); + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} + +struct OnWSendShow; +trait OnWSend { + fn show(&self) -> OnWSendShow { + OnWSendShow + } +} + +impl OnW for W {} +impl OnWSend for &W {} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return &() as *const () }; + let _: OnWShow = (&&W(id2(test(!n), &() as *const ()))).show(); + &() as *const () +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend-inner-id-right.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend-inner-id-right.rs new file mode 100644 index 0000000000000..a404eab612e25 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend-inner-id-right.rs @@ -0,0 +1,36 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// check-pass + +struct W(T); + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} + +struct OnWSendShow; +trait OnWSend { + fn show(&self) -> OnWSendShow { + OnWSendShow + } +} + +impl OnW for W {} +impl OnWSend for &W {} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return &() as *const () }; + let _: OnWShow = (&&W(id2(&() as *const (), test(!n)))).show(); + &() as *const () +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend-outer-id-left.old.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend-outer-id-left.old.stderr new file mode 100644 index 0000000000000..d22b9314499c4 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend-outer-id-left.old.stderr @@ -0,0 +1,23 @@ +error[E0391]: cycle detected when computing type of opaque `test::{opaque#0}` + --> $DIR/reveal-auto-trait-notsend-outer-id-left.rs:31:21 + | +LL | fn test(n: bool) -> impl Sized { + | ^^^^^^^^^^ + | +note: ...which requires type-checking `test`... + --> $DIR/reveal-auto-trait-notsend-outer-id-left.rs:33:64 + | +LL | let _: OnWShow = id2(&&W(test(!n)), &&W(&() as *const ())).show(); + | ^^^^ + = note: ...which requires evaluating trait selection obligation `&'a W: OnWSend`... + = note: ...which again requires computing type of opaque `test::{opaque#0}`, completing the cycle +note: cycle used when computing type of `test::{opaque#0}` + --> $DIR/reveal-auto-trait-notsend-outer-id-left.rs:31:21 + | +LL | fn test(n: bool) -> impl Sized { + | ^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend-outer-id-left.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend-outer-id-left.rs new file mode 100644 index 0000000000000..d1d0c88f08033 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend-outer-id-left.rs @@ -0,0 +1,37 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// [new]check-pass +// [old]known-bug: unknown + +struct W(T); + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} + +struct OnWSendShow; +trait OnWSend { + fn show(&self) -> OnWSendShow { + OnWSendShow + } +} + +impl OnW for W {} +impl OnWSend for &W {} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return &() as *const () }; + let _: OnWShow = id2(&&W(test(!n)), &&W(&() as *const ())).show(); + &() as *const () +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend-outer-id-right.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend-outer-id-right.rs new file mode 100644 index 0000000000000..17d6ff251fe6e --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend-outer-id-right.rs @@ -0,0 +1,36 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// check-pass + +struct W(T); + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} + +struct OnWSendShow; +trait OnWSend { + fn show(&self) -> OnWSendShow { + OnWSendShow + } +} + +impl OnW for W {} +impl OnWSend for &W {} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return &() as *const () }; + let _: OnWShow = id2(&&W(&() as *const ()), &&W(test(!n))).show(); + &() as *const () +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend.old.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend.old.stderr new file mode 100644 index 0000000000000..653e3b2275f24 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend.old.stderr @@ -0,0 +1,23 @@ +error[E0391]: cycle detected when computing type of opaque `test::{opaque#0}` + --> $DIR/reveal-auto-trait-notsend.rs:27:21 + | +LL | fn test(n: bool) -> impl Sized { + | ^^^^^^^^^^ + | +note: ...which requires type-checking `test`... + --> $DIR/reveal-auto-trait-notsend.rs:29:38 + | +LL | let _: OnWShow = (&&W(test(!n))).show(); + | ^^^^ + = note: ...which requires evaluating trait selection obligation `&'a W: OnWSend`... + = note: ...which again requires computing type of opaque `test::{opaque#0}`, completing the cycle +note: cycle used when computing type of `test::{opaque#0}` + --> $DIR/reveal-auto-trait-notsend.rs:27:21 + | +LL | fn test(n: bool) -> impl Sized { + | ^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend.rs new file mode 100644 index 0000000000000..51d5cce29b8a5 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-notsend.rs @@ -0,0 +1,33 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// [new]check-pass +// [old]known-bug: unknown + +struct W(T); + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} + +struct OnWSendShow; +trait OnWSend { + fn show(&self) -> OnWSendShow { + OnWSendShow + } +} + +impl OnW for W {} +impl OnWSend for &W {} + +fn test(n: bool) -> impl Sized { + let true = n else { return &() as *const () }; + let _: OnWShow = (&&W(test(!n))).show(); + &() as *const () +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send-inner-id-left.old.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send-inner-id-left.old.stderr new file mode 100644 index 0000000000000..347b1ea09ccd7 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send-inner-id-left.old.stderr @@ -0,0 +1,32 @@ +error[E0308]: mismatched types + --> $DIR/reveal-auto-trait-send-inner-id-left.rs:33:26 + | +LL | let _: OnWSendShow = (&&W(id2(test(!n), ()))).show(); + | ----------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `OnWSendShow`, found `OnWShow` + | | + | expected due to this + +error[E0391]: cycle detected when computing type of opaque `test::{opaque#0}` + --> $DIR/reveal-auto-trait-send-inner-id-left.rs:31:21 + | +LL | fn test(n: bool) -> impl Sized { + | ^^^^^^^^^^ + | +note: ...which requires type-checking `test`... + --> $DIR/reveal-auto-trait-send-inner-id-left.rs:33:51 + | +LL | let _: OnWSendShow = (&&W(id2(test(!n), ()))).show(); + | ^^^^ + = note: ...which requires evaluating trait selection obligation `&'a W: OnWSend`... + = note: ...which again requires computing type of opaque `test::{opaque#0}`, completing the cycle +note: cycle used when computing type of `test::{opaque#0}` + --> $DIR/reveal-auto-trait-send-inner-id-left.rs:31:21 + | +LL | fn test(n: bool) -> impl Sized { + | ^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0308, E0391. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send-inner-id-left.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send-inner-id-left.rs new file mode 100644 index 0000000000000..bab63d324665f --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send-inner-id-left.rs @@ -0,0 +1,36 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// [new]check-pass +// [old]known-bug: unknown + +struct W(T); + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} + +struct OnWSendShow; +trait OnWSend { + fn show(&self) -> OnWSendShow { + OnWSendShow + } +} + +impl OnW for W {} +impl OnWSend for &W {} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return }; + let _: OnWSendShow = (&&W(id2(test(!n), ()))).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send-inner-id-right.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send-inner-id-right.rs new file mode 100644 index 0000000000000..906cba692827e --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send-inner-id-right.rs @@ -0,0 +1,35 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// check-pass + +struct W(T); + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} + +struct OnWSendShow; +trait OnWSend { + fn show(&self) -> OnWSendShow { + OnWSendShow + } +} + +impl OnW for W {} +impl OnWSend for &W {} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return }; + let _: OnWSendShow = (&&W(id2((), test(!n)))).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send-outer-id-left.old.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send-outer-id-left.old.stderr new file mode 100644 index 0000000000000..bd6eb1614af16 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send-outer-id-left.old.stderr @@ -0,0 +1,32 @@ +error[E0308]: mismatched types + --> $DIR/reveal-auto-trait-send-outer-id-left.rs:33:26 + | +LL | let _: OnWSendShow = id2(&&W(test(!n)), &&W(())).show(); + | ----------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `OnWSendShow`, found `OnWShow` + | | + | expected due to this + +error[E0391]: cycle detected when computing type of opaque `test::{opaque#0}` + --> $DIR/reveal-auto-trait-send-outer-id-left.rs:31:21 + | +LL | fn test(n: bool) -> impl Sized { + | ^^^^^^^^^^ + | +note: ...which requires type-checking `test`... + --> $DIR/reveal-auto-trait-send-outer-id-left.rs:33:54 + | +LL | let _: OnWSendShow = id2(&&W(test(!n)), &&W(())).show(); + | ^^^^ + = note: ...which requires evaluating trait selection obligation `&'a W: OnWSend`... + = note: ...which again requires computing type of opaque `test::{opaque#0}`, completing the cycle +note: cycle used when computing type of `test::{opaque#0}` + --> $DIR/reveal-auto-trait-send-outer-id-left.rs:31:21 + | +LL | fn test(n: bool) -> impl Sized { + | ^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0308, E0391. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send-outer-id-left.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send-outer-id-left.rs new file mode 100644 index 0000000000000..b1223277f9370 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send-outer-id-left.rs @@ -0,0 +1,36 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// [new]check-pass +// [old]known-bug: unknown + +struct W(T); + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} + +struct OnWSendShow; +trait OnWSend { + fn show(&self) -> OnWSendShow { + OnWSendShow + } +} + +impl OnW for W {} +impl OnWSend for &W {} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return }; + let _: OnWSendShow = id2(&&W(test(!n)), &&W(())).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send-outer-id-right.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send-outer-id-right.rs new file mode 100644 index 0000000000000..e85c588dc7ef7 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send-outer-id-right.rs @@ -0,0 +1,35 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// check-pass + +struct W(T); + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} + +struct OnWSendShow; +trait OnWSend { + fn show(&self) -> OnWSendShow { + OnWSendShow + } +} + +impl OnW for W {} +impl OnWSend for &W {} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return }; + let _: OnWSendShow = id2(&&W(()), &&W(test(!n))).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send.old.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send.old.stderr new file mode 100644 index 0000000000000..88cbe8125a3b8 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send.old.stderr @@ -0,0 +1,32 @@ +error[E0308]: mismatched types + --> $DIR/reveal-auto-trait-send.rs:29:26 + | +LL | let _: OnWSendShow = (&&W(test(!n))).show(); + | ----------- ^^^^^^^^^^^^^^^^^^^^^^ expected `OnWSendShow`, found `OnWShow` + | | + | expected due to this + +error[E0391]: cycle detected when computing type of opaque `test::{opaque#0}` + --> $DIR/reveal-auto-trait-send.rs:27:21 + | +LL | fn test(n: bool) -> impl Sized { + | ^^^^^^^^^^ + | +note: ...which requires type-checking `test`... + --> $DIR/reveal-auto-trait-send.rs:29:42 + | +LL | let _: OnWSendShow = (&&W(test(!n))).show(); + | ^^^^ + = note: ...which requires evaluating trait selection obligation `&'a W: OnWSend`... + = note: ...which again requires computing type of opaque `test::{opaque#0}`, completing the cycle +note: cycle used when computing type of `test::{opaque#0}` + --> $DIR/reveal-auto-trait-send.rs:27:21 + | +LL | fn test(n: bool) -> impl Sized { + | ^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0308, E0391. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send.rs new file mode 100644 index 0000000000000..df51418fd6611 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-auto-trait-send.rs @@ -0,0 +1,32 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// [new]check-pass +// [old]known-bug: unknown + +struct W(T); + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} + +struct OnWSendShow; +trait OnWSend { + fn show(&self) -> OnWSendShow { + OnWSendShow + } +} + +impl OnW for W {} +impl OnWSend for &W {} + +fn test(n: bool) -> impl Sized { + let true = n else { return }; + let _: OnWSendShow = (&&W(test(!n))).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access-id-left.new.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access-id-left.new.stderr new file mode 100644 index 0000000000000..4e09fdab6b72a --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access-id-left.new.stderr @@ -0,0 +1,9 @@ +error[E0609]: no field `field` on type `impl Sized` + --> $DIR/reveal-hidden-via-field-access-id-left.rs:18:34 + | +LL | let _: () = id2(test(!n), I).field; + | ^^^^^ unknown field + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0609`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access-id-left.old.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access-id-left.old.stderr new file mode 100644 index 0000000000000..4e09fdab6b72a --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access-id-left.old.stderr @@ -0,0 +1,9 @@ +error[E0609]: no field `field` on type `impl Sized` + --> $DIR/reveal-hidden-via-field-access-id-left.rs:18:34 + | +LL | let _: () = id2(test(!n), I).field; + | ^^^^^ unknown field + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0609`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access-id-left.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access-id-left.rs new file mode 100644 index 0000000000000..881a447f51946 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access-id-left.rs @@ -0,0 +1,22 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// known-bug: unknown + +struct I { + field: (), +} +const I: I = I { field: () }; + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return I }; + let _: () = id2(test(!n), I).field; + I +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access-id-right.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access-id-right.rs new file mode 100644 index 0000000000000..f5020dcccaeda --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access-id-right.rs @@ -0,0 +1,22 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// check-pass + +struct I { + field: (), +} +const I: I = I { field: () }; + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return I }; + let _: () = id2(I, test(!n)).field; + I +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access.new.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access.new.stderr new file mode 100644 index 0000000000000..158a570b45e12 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access.new.stderr @@ -0,0 +1,9 @@ +error[E0609]: no field `field` on type `impl Sized` + --> $DIR/reveal-hidden-via-field-access.rs:14:26 + | +LL | let _: () = test(!n).field; + | ^^^^^ unknown field + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0609`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access.old.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access.old.stderr new file mode 100644 index 0000000000000..158a570b45e12 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access.old.stderr @@ -0,0 +1,9 @@ +error[E0609]: no field `field` on type `impl Sized` + --> $DIR/reveal-hidden-via-field-access.rs:14:26 + | +LL | let _: () = test(!n).field; + | ^^^^^ unknown field + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0609`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access.rs new file mode 100644 index 0000000000000..08636d7c94840 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-field-access.rs @@ -0,0 +1,18 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// known-bug: unknown + +struct I { + field: (), +} +const I: I = I { field: () }; + +fn test(n: bool) -> impl Sized { + let true = n else { return I }; + let _: () = test(!n).field; + I +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped-id-left.new.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped-id-left.new.stderr new file mode 100644 index 0000000000000..f8917b2d7930a --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped-id-left.new.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/reveal-hidden-via-match-at-binding-unwrapped-id-left.rs:32:18 + | +LL | x @ I => x.show(), + | ^^^^^^^^ expected `IShow`, found `OnIShow` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped-id-left.old.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped-id-left.old.stderr new file mode 100644 index 0000000000000..f8917b2d7930a --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped-id-left.old.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/reveal-hidden-via-match-at-binding-unwrapped-id-left.rs:32:18 + | +LL | x @ I => x.show(), + | ^^^^^^^^ expected `IShow`, found `OnIShow` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped-id-left.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped-id-left.rs new file mode 100644 index 0000000000000..8ed481603e32c --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped-id-left.rs @@ -0,0 +1,37 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// known-bug: unknown + +struct I; +struct IShow; +impl I { + #[allow(dead_code)] + pub fn show(&self) -> IShow { + IShow + } +} + +struct OnIShow; +trait OnI { + fn show(&self) -> OnIShow { + OnIShow + } +} +impl OnI for I {} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl OnI { + let true = n else { return I }; + // This should be a defining use, but is not currently. + let _: IShow = match id2(test(!n), I) { + x @ I => x.show(), + }; + I +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped-id-right.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped-id-right.rs new file mode 100644 index 0000000000000..d05fa30076a9d --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped-id-right.rs @@ -0,0 +1,36 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// check-pass + +struct I; +struct IShow; +impl I { + #[allow(dead_code)] + pub fn show(&self) -> IShow { + IShow + } +} + +struct OnIShow; +trait OnI { + fn show(&self) -> OnIShow { + OnIShow + } +} +impl OnI for I {} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl OnI { + let true = n else { return I }; + let _: IShow = match id2(I, test(!n)) { + x @ I => x.show(), + }; + I +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped.new.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped.new.stderr new file mode 100644 index 0000000000000..204453880c0bf --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped.new.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/reveal-hidden-via-match-at-binding-unwrapped.rs:28:18 + | +LL | x @ I => x.show(), + | ^^^^^^^^ expected `IShow`, found `OnIShow` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped.old.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped.old.stderr new file mode 100644 index 0000000000000..204453880c0bf --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped.old.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/reveal-hidden-via-match-at-binding-unwrapped.rs:28:18 + | +LL | x @ I => x.show(), + | ^^^^^^^^ expected `IShow`, found `OnIShow` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped.rs new file mode 100644 index 0000000000000..00d164575a12e --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-unwrapped.rs @@ -0,0 +1,33 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// known-bug: unknown + +struct I; +struct IShow; +impl I { + #[allow(dead_code)] + pub fn show(&self) -> IShow { + IShow + } +} + +struct OnIShow; +trait OnI { + fn show(&self) -> OnIShow { + OnIShow + } +} +impl OnI for I {} + +fn test(n: bool) -> impl OnI { + let true = n else { return I }; + // This should be a defining use, but is not currently. + let _: IShow = match test(!n) { + x @ I => x.show(), + }; + I +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-onw-id-left.old.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-onw-id-left.old.stderr new file mode 100644 index 0000000000000..6d7333e0ccf2a --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-onw-id-left.old.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/reveal-hidden-via-match-at-binding-wrapped-onw-id-left.rs:33:21 + | +LL | x @ W(I) => x.show(), + | ^^^^^^^^ expected `WIShow`, found `OnWShow` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-onw-id-left.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-onw-id-left.rs new file mode 100644 index 0000000000000..d016b9af0c4d1 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-onw-id-left.rs @@ -0,0 +1,38 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// [new]check-pass +// [old]known-bug: unknown + +struct I; + +struct W(T); +struct WIShow; +impl W { + pub fn show(&self) -> WIShow { + WIShow + } +} + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} +impl OnW for W {} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return I }; + let _: WIShow = match W(id2(test(!n), I)) { + x @ W(I) => x.show(), + }; + I +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-onw-id-right.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-onw-id-right.rs new file mode 100644 index 0000000000000..fdc7bb8bfcf89 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-onw-id-right.rs @@ -0,0 +1,37 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// check-pass + +struct I; + +struct W(T); +struct WIShow; +impl W { + pub fn show(&self) -> WIShow { + WIShow + } +} + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} +impl OnW for W {} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return I }; + let _: WIShow = match W(id2(I, test(!n))) { + x @ W(I) => x.show(), + }; + I +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-onw.old.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-onw.old.stderr new file mode 100644 index 0000000000000..6b70f3ee01933 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-onw.old.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/reveal-hidden-via-match-at-binding-wrapped-onw.rs:29:21 + | +LL | x @ W(I) => x.show(), + | ^^^^^^^^ expected `WIShow`, found `OnWShow` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-onw.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-onw.rs new file mode 100644 index 0000000000000..c594fd669674b --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-onw.rs @@ -0,0 +1,34 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// [new]check-pass +// [old]known-bug: unknown + +struct I; + +struct W(T); +struct WIShow; +impl W { + pub fn show(&self) -> WIShow { + WIShow + } +} + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} +impl OnW for W {} + +fn test(n: bool) -> impl Sized { + let true = n else { return I }; + let _: WIShow = match W(test(!n)) { + x @ W(I) => x.show(), + }; + I +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-wonly-id-left.old.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-wonly-id-left.old.stderr new file mode 100644 index 0000000000000..88aecb386053a --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-wonly-id-left.old.stderr @@ -0,0 +1,36 @@ +error[E0599]: no method named `show` found for struct `W` in the current scope + --> $DIR/reveal-hidden-via-match-at-binding-wrapped-wonly-id-left.rs:24:24 + | +LL | struct W(T); + | ----------- method `show` not found for this struct +... +LL | x @ W(()) => x.show(), + | ^^^^ method not found in `W` + | + = note: the method was found for + - `W<()>` + +error[E0391]: cycle detected when computing type of opaque `test::{opaque#0}` + --> $DIR/reveal-hidden-via-match-at-binding-wrapped-wonly-id-left.rs:21:21 + | +LL | fn test(n: bool) -> impl Sized { + | ^^^^^^^^^^ + | +note: ...which requires type-checking `test`... + --> $DIR/reveal-hidden-via-match-at-binding-wrapped-wonly-id-left.rs:24:22 + | +LL | x @ W(()) => x.show(), + | ^ + = note: ...which requires evaluating trait selection obligation `W: core::marker::Unpin`... + = note: ...which again requires computing type of opaque `test::{opaque#0}`, completing the cycle +note: cycle used when computing type of `test::{opaque#0}` + --> $DIR/reveal-hidden-via-match-at-binding-wrapped-wonly-id-left.rs:21:21 + | +LL | fn test(n: bool) -> impl Sized { + | ^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0391, E0599. +For more information about an error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-wonly-id-left.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-wonly-id-left.rs new file mode 100644 index 0000000000000..9bad97638352c --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-wonly-id-left.rs @@ -0,0 +1,28 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// [new]check-pass +// [old]known-bug: unknown + +struct W(T); +struct WShow; +impl W<()> { + #[allow(dead_code)] + pub fn show(&self) -> WShow { + WShow + } +} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return }; + let _: WShow = match W(id2(test(!n), ())) { + x @ W(()) => x.show(), + }; +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-wonly-id-right.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-wonly-id-right.rs new file mode 100644 index 0000000000000..5b48b49c63d87 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-wonly-id-right.rs @@ -0,0 +1,27 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// check-pass + +struct W(T); +struct WShow; +impl W<()> { + #[allow(dead_code)] + pub fn show(&self) -> WShow { + WShow + } +} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return }; + let _: WShow = match W(id2((), test(!n))) { + x @ W(()) => x.show(), + }; +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-wonly.old.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-wonly.old.stderr new file mode 100644 index 0000000000000..412715e6f1b80 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-wonly.old.stderr @@ -0,0 +1,36 @@ +error[E0599]: no method named `show` found for struct `W` in the current scope + --> $DIR/reveal-hidden-via-match-at-binding-wrapped-wonly.rs:24:24 + | +LL | struct W(T); + | ----------- method `show` not found for this struct +... +LL | x @ W(()) => x.show(), + | ^^^^ method not found in `W` + | + = note: the method was found for + - `W<()>` + +error[E0391]: cycle detected when computing type of opaque `test::{opaque#0}` + --> $DIR/reveal-hidden-via-match-at-binding-wrapped-wonly.rs:21:21 + | +LL | fn test(n: bool) -> impl Sized { + | ^^^^^^^^^^ + | +note: ...which requires type-checking `test`... + --> $DIR/reveal-hidden-via-match-at-binding-wrapped-wonly.rs:24:22 + | +LL | x @ W(()) => x.show(), + | ^ + = note: ...which requires evaluating trait selection obligation `W: core::marker::Unpin`... + = note: ...which again requires computing type of opaque `test::{opaque#0}`, completing the cycle +note: cycle used when computing type of `test::{opaque#0}` + --> $DIR/reveal-hidden-via-match-at-binding-wrapped-wonly.rs:21:21 + | +LL | fn test(n: bool) -> impl Sized { + | ^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0391, E0599. +For more information about an error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-wonly.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-wonly.rs new file mode 100644 index 0000000000000..aac9ef4f88a83 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-at-binding-wrapped-wonly.rs @@ -0,0 +1,28 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// [new]check-pass +// [old]known-bug: unknown + +struct W(T); +struct WShow; +impl W<()> { + #[allow(dead_code)] + pub fn show(&self) -> WShow { + WShow + } +} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return }; + let _: WShow = match W(test(!n)) { + x @ W(()) => x.show(), + }; +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty-id-left.new.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty-id-left.new.stderr new file mode 100644 index 0000000000000..4d80f779d584e --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty-id-left.new.stderr @@ -0,0 +1,17 @@ +error[E0004]: non-exhaustive patterns: type `impl Sized` is non-empty + --> $DIR/reveal-hidden-via-match-exhaustiveness-empty-id-left.rs:15:11 + | +LL | match id2(test(!n, e), panic!()) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the matched value is of type `impl Sized` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match id2(test(!n, e), panic!()) { +LL + _ => todo!(), +LL + } + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty-id-left.old.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty-id-left.old.stderr new file mode 100644 index 0000000000000..4d80f779d584e --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty-id-left.old.stderr @@ -0,0 +1,17 @@ +error[E0004]: non-exhaustive patterns: type `impl Sized` is non-empty + --> $DIR/reveal-hidden-via-match-exhaustiveness-empty-id-left.rs:15:11 + | +LL | match id2(test(!n, e), panic!()) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the matched value is of type `impl Sized` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match id2(test(!n, e), panic!()) { +LL + _ => todo!(), +LL + } + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty-id-left.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty-id-left.rs new file mode 100644 index 0000000000000..8a2c1741fd258 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty-id-left.rs @@ -0,0 +1,19 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// known-bug: #116821 + +enum E {} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool, e: E) -> impl Sized { + let true = n else { return e }; + match id2(test(!n, e), panic!()) {} + e +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty-id-right.new.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty-id-right.new.stderr new file mode 100644 index 0000000000000..1ffde11db35bc --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty-id-right.new.stderr @@ -0,0 +1,17 @@ +error[E0004]: non-exhaustive patterns: type `impl Sized` is non-empty + --> $DIR/reveal-hidden-via-match-exhaustiveness-empty-id-right.rs:15:11 + | +LL | match id2(panic!(), test(!n, e)) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the matched value is of type `impl Sized` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match id2(panic!(), test(!n, e)) { +LL + _ => todo!(), +LL + } + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty-id-right.old.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty-id-right.old.stderr new file mode 100644 index 0000000000000..1ffde11db35bc --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty-id-right.old.stderr @@ -0,0 +1,17 @@ +error[E0004]: non-exhaustive patterns: type `impl Sized` is non-empty + --> $DIR/reveal-hidden-via-match-exhaustiveness-empty-id-right.rs:15:11 + | +LL | match id2(panic!(), test(!n, e)) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the matched value is of type `impl Sized` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match id2(panic!(), test(!n, e)) { +LL + _ => todo!(), +LL + } + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty-id-right.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty-id-right.rs new file mode 100644 index 0000000000000..e8ff93ad56b19 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty-id-right.rs @@ -0,0 +1,19 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// known-bug: #116821 + +enum E {} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool, e: E) -> impl Sized { + let true = n else { return e }; + match id2(panic!(), test(!n, e)) {} + e +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty.new.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty.new.stderr new file mode 100644 index 0000000000000..354ea6115c8bc --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty.new.stderr @@ -0,0 +1,17 @@ +error[E0004]: non-exhaustive patterns: type `impl Sized` is non-empty + --> $DIR/reveal-hidden-via-match-exhaustiveness-empty.rs:15:11 + | +LL | match test(!n, e) {} + | ^^^^^^^^^^^ + | + = note: the matched value is of type `impl Sized` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match test(!n, e) { +LL + _ => todo!(), +LL + } + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty.old.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty.old.stderr new file mode 100644 index 0000000000000..354ea6115c8bc --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty.old.stderr @@ -0,0 +1,17 @@ +error[E0004]: non-exhaustive patterns: type `impl Sized` is non-empty + --> $DIR/reveal-hidden-via-match-exhaustiveness-empty.rs:15:11 + | +LL | match test(!n, e) {} + | ^^^^^^^^^^^ + | + = note: the matched value is of type `impl Sized` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match test(!n, e) { +LL + _ => todo!(), +LL + } + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty.rs new file mode 100644 index 0000000000000..c2d3f744eed93 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-empty.rs @@ -0,0 +1,19 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// known-bug: #116821 + +enum E {} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool, e: E) -> impl Sized { + let true = n else { return e }; + match test(!n, e) {} + e +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-unit-id-left.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-unit-id-left.rs new file mode 100644 index 0000000000000..5f74442e5f3aa --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-unit-id-left.rs @@ -0,0 +1,18 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// check-pass + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return }; + match id2(test(!n), ()) { + () => (), + }; +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-unit-id-right.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-unit-id-right.rs new file mode 100644 index 0000000000000..e4c0fb3b9d4c2 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-unit-id-right.rs @@ -0,0 +1,18 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// check-pass + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return }; + match id2((), test(!n)) { + () => (), + }; +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-unit.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-unit.rs new file mode 100644 index 0000000000000..772d3b5b49005 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-exhaustiveness-unit.rs @@ -0,0 +1,18 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// check-pass + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return }; + match test(!n) { + () => (), + }; +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-tuple-id-left.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-tuple-id-left.rs new file mode 100644 index 0000000000000..8b699ab15c9b8 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-tuple-id-left.rs @@ -0,0 +1,35 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// check-pass + +struct I; +struct IShow; +impl I { + pub fn show(&self) -> IShow { + IShow + } +} + +struct OnIShow; +trait OnI { + fn show(&self) -> OnIShow { + OnIShow + } +} +impl OnI for I {} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return (I,) }; + let _: IShow = match id2(test(!n), (I,)) { + (x,) => x.show(), + }; + (I,) +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-tuple-id-right.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-tuple-id-right.rs new file mode 100644 index 0000000000000..2f1de79a4af40 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-tuple-id-right.rs @@ -0,0 +1,35 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// check-pass + +struct I; +struct IShow; +impl I { + pub fn show(&self) -> IShow { + IShow + } +} + +struct OnIShow; +trait OnI { + fn show(&self) -> OnIShow { + OnIShow + } +} +impl OnI for I {} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return (I,) }; + let _: IShow = match id2((I,), test(!n)) { + (x,) => x.show(), + }; + (I,) +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-tuple.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-tuple.rs new file mode 100644 index 0000000000000..36d0edf7185c4 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-match-tuple.rs @@ -0,0 +1,35 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// check-pass + +struct I; +struct IShow; +impl I { + pub fn show(&self) -> IShow { + IShow + } +} + +struct OnIShow; +trait OnI { + fn show(&self) -> OnIShow { + OnIShow + } +} +impl OnI for I {} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return (I,) }; + let _: IShow = match test(!n) { + (x,) => x.show(), + }; + (I,) +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver-id-left.new.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver-id-left.new.stderr new file mode 100644 index 0000000000000..00e5954e87bef --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver-id-left.new.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/reveal-hidden-via-unwrapped-receiver-id-left.rs:30:20 + | +LL | let _: IShow = id2(test(!n), I).show(); + | ----- ^^^^^^^^^^^^^^^^^^^^^^^ expected `IShow`, found `OnIShow` + | | + | expected due to this + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver-id-left.old.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver-id-left.old.stderr new file mode 100644 index 0000000000000..00e5954e87bef --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver-id-left.old.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/reveal-hidden-via-unwrapped-receiver-id-left.rs:30:20 + | +LL | let _: IShow = id2(test(!n), I).show(); + | ----- ^^^^^^^^^^^^^^^^^^^^^^^ expected `IShow`, found `OnIShow` + | | + | expected due to this + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver-id-left.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver-id-left.rs new file mode 100644 index 0000000000000..84a0ef8ca3e69 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver-id-left.rs @@ -0,0 +1,34 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// known-bug: unknown + +struct I; +struct IShow; +impl I { + #[allow(dead_code)] + pub fn show(&self) -> IShow { + IShow + } +} + +struct OnIShow; +trait OnI { + fn show(&self) -> OnIShow { + OnIShow + } +} +impl OnI for I {} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl OnI { + let true = n else { return I }; + let _: IShow = id2(test(!n), I).show(); + I +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver-id-right.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver-id-right.rs new file mode 100644 index 0000000000000..ee32f00b32fa5 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver-id-right.rs @@ -0,0 +1,33 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// check-pass + +struct I; +struct IShow; +impl I { + pub fn show(&self) -> IShow { + IShow + } +} + +struct OnIShow; +trait OnI { + fn show(&self) -> OnIShow { + OnIShow + } +} +impl OnI for I {} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl OnI { + let true = n else { return I }; + let _: IShow = id2(I, test(!n)).show(); + I +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver.new.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver.new.stderr new file mode 100644 index 0000000000000..df1301a2ae66d --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver.new.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/reveal-hidden-via-unwrapped-receiver.rs:26:20 + | +LL | let _: IShow = test(!n).show(); + | ----- ^^^^^^^^^^^^^^^ expected `IShow`, found `OnIShow` + | | + | expected due to this + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver.old.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver.old.stderr new file mode 100644 index 0000000000000..df1301a2ae66d --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver.old.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/reveal-hidden-via-unwrapped-receiver.rs:26:20 + | +LL | let _: IShow = test(!n).show(); + | ----- ^^^^^^^^^^^^^^^ expected `IShow`, found `OnIShow` + | | + | expected due to this + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver.rs new file mode 100644 index 0000000000000..0d9249dfd8b1e --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-unwrapped-receiver.rs @@ -0,0 +1,30 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// known-bug: unknown + +struct I; +struct IShow; +impl I { + #[allow(dead_code)] + pub fn show(&self) -> IShow { + IShow + } +} + +struct OnIShow; +trait OnI { + fn show(&self) -> OnIShow { + OnIShow + } +} +impl OnI for I {} + +fn test(n: bool) -> impl OnI { + let true = n else { return I }; + let _: IShow = test(!n).show(); + I +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver-inner-id-left.old.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver-inner-id-left.old.stderr new file mode 100644 index 0000000000000..0f62fadb971bd --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver-inner-id-left.old.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/reveal-hidden-via-wrapped-receiver-inner-id-left.rs:30:20 + | +LL | let _: WShow = W(id2(test(!n), ())).show(); + | ----- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `WShow`, found `OnWShow` + | | + | expected due to this + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver-inner-id-left.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver-inner-id-left.rs new file mode 100644 index 0000000000000..4905256e96011 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver-inner-id-left.rs @@ -0,0 +1,33 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// [new]check-pass +// [old]known-bug: unknown + +struct W(T); +struct WShow; +impl W<()> { + pub fn show(&self) -> WShow { + WShow + } +} + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} +impl OnW for W {} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return }; + let _: WShow = W(id2(test(!n), ())).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver-inner-id-right.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver-inner-id-right.rs new file mode 100644 index 0000000000000..b54ade01b16ee --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver-inner-id-right.rs @@ -0,0 +1,32 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// check-pass + +struct W(T); +struct WShow; +impl W<()> { + pub fn show(&self) -> WShow { + WShow + } +} + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} +impl OnW for W {} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return }; + let _: WShow = W(id2((), test(!n))).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver-outer-id-left.old.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver-outer-id-left.old.stderr new file mode 100644 index 0000000000000..331fc95e355d4 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver-outer-id-left.old.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/reveal-hidden-via-wrapped-receiver-outer-id-left.rs:30:20 + | +LL | let _: WShow = id2(W(test(!n)), W(())).show(); + | ----- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `WShow`, found `OnWShow` + | | + | expected due to this + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver-outer-id-left.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver-outer-id-left.rs new file mode 100644 index 0000000000000..21d8bdc009a24 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver-outer-id-left.rs @@ -0,0 +1,33 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// [new]check-pass +// [old]known-bug: unknown + +struct W(T); +struct WShow; +impl W<()> { + pub fn show(&self) -> WShow { + WShow + } +} + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} +impl OnW for W {} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return }; + let _: WShow = id2(W(test(!n)), W(())).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver-outer-id-right.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver-outer-id-right.rs new file mode 100644 index 0000000000000..8f8ce05090810 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver-outer-id-right.rs @@ -0,0 +1,32 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// check-pass + +struct W(T); +struct WShow; +impl W<()> { + pub fn show(&self) -> WShow { + WShow + } +} + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} +impl OnW for W {} + +fn id2(_: T, x: T) -> T { + x +} + +fn test(n: bool) -> impl Sized { + let true = n else { return }; + let _: WShow = id2(W(()), W(test(!n))).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver.old.stderr b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver.old.stderr new file mode 100644 index 0000000000000..cb0ed265b9dc8 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver.old.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/reveal-hidden-via-wrapped-receiver.rs:26:20 + | +LL | let _: WShow = W(test(!n)).show(); + | ----- ^^^^^^^^^^^^^^^^^^ expected `WShow`, found `OnWShow` + | | + | expected due to this + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver.rs b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver.rs new file mode 100644 index 0000000000000..625f04e7bc040 --- /dev/null +++ b/tests/ui/impl-trait/inference/in-defining-item/reveal-hidden-via-wrapped-receiver.rs @@ -0,0 +1,29 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// [new]check-pass +// [old]known-bug: unknown + +struct W(T); +struct WShow; +impl W<()> { + pub fn show(&self) -> WShow { + WShow + } +} + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} +impl OnW for W {} + +fn test(n: bool) -> impl Sized { + let true = n else { return }; + let _: WShow = W(test(!n)).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend-inner-id-left.old.stderr b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend-inner-id-left.old.stderr new file mode 100644 index 0000000000000..036f21e81e81c --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend-inner-id-left.old.stderr @@ -0,0 +1,23 @@ +error[E0391]: cycle detected when computing type of opaque `Test::{opaque#0}` + --> $DIR/reveal-auto-trait-notsend-inner-id-left.rs:33:13 + | +LL | type Test = impl Sized; + | ^^^^^^^^^^ + | +note: ...which requires type-checking `test`... + --> $DIR/reveal-auto-trait-notsend-inner-id-left.rs:38:54 + | +LL | let _: OnWShow = (&&W(id2(x, &() as *const ()))).show(); + | ^^^^ + = note: ...which requires evaluating trait selection obligation `&'a W: OnWSend`... + = note: ...which again requires computing type of opaque `Test::{opaque#0}`, completing the cycle +note: cycle used when computing type of `Test::{opaque#0}` + --> $DIR/reveal-auto-trait-notsend-inner-id-left.rs:33:13 + | +LL | type Test = impl Sized; + | ^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend-inner-id-left.rs b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend-inner-id-left.rs new file mode 100644 index 0000000000000..ed06ab6b15b61 --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend-inner-id-left.rs @@ -0,0 +1,41 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// [new]check-pass +// [old]known-bug: unknown + +#![feature(type_alias_impl_trait)] + +struct W(T); + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} + +struct OnWSendShow; +trait OnWSend { + fn show(&self) -> OnWSendShow { + OnWSendShow + } +} + +impl OnW for W {} +impl OnWSend for &W {} + +fn id2(_: T, x: T) -> T { + x +} + +type Test = impl Sized; + +fn define() -> Test { &() as *const () } + +fn test(x: Test) { + let _: OnWShow = (&&W(id2(x, &() as *const ()))).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend-inner-id-right.rs b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend-inner-id-right.rs new file mode 100644 index 0000000000000..10be288b3f227 --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend-inner-id-right.rs @@ -0,0 +1,40 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// check-pass + +#![feature(type_alias_impl_trait)] + +struct W(T); + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} + +struct OnWSendShow; +trait OnWSend { + fn show(&self) -> OnWSendShow { + OnWSendShow + } +} + +impl OnW for W {} +impl OnWSend for &W {} + +fn id2(_: T, x: T) -> T { + x +} + +type Test = impl Sized; + +fn define() -> Test { &() as *const () } + +fn test(x: Test) { + let _: OnWShow = (&&W(id2(&() as *const (), x))).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend-outer-id-left.old.stderr b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend-outer-id-left.old.stderr new file mode 100644 index 0000000000000..7db9d085a70f4 --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend-outer-id-left.old.stderr @@ -0,0 +1,23 @@ +error[E0391]: cycle detected when computing type of opaque `Test::{opaque#0}` + --> $DIR/reveal-auto-trait-notsend-outer-id-left.rs:33:13 + | +LL | type Test = impl Sized; + | ^^^^^^^^^^ + | +note: ...which requires type-checking `test`... + --> $DIR/reveal-auto-trait-notsend-outer-id-left.rs:38:57 + | +LL | let _: OnWShow = id2(&&W(x), &&W(&() as *const ())).show(); + | ^^^^ + = note: ...which requires evaluating trait selection obligation `&'a W: OnWSend`... + = note: ...which again requires computing type of opaque `Test::{opaque#0}`, completing the cycle +note: cycle used when computing type of `Test::{opaque#0}` + --> $DIR/reveal-auto-trait-notsend-outer-id-left.rs:33:13 + | +LL | type Test = impl Sized; + | ^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend-outer-id-left.rs b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend-outer-id-left.rs new file mode 100644 index 0000000000000..390b82a609cf4 --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend-outer-id-left.rs @@ -0,0 +1,41 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// [new]check-pass +// [old]known-bug: unknown + +#![feature(type_alias_impl_trait)] + +struct W(T); + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} + +struct OnWSendShow; +trait OnWSend { + fn show(&self) -> OnWSendShow { + OnWSendShow + } +} + +impl OnW for W {} +impl OnWSend for &W {} + +fn id2(_: T, x: T) -> T { + x +} + +type Test = impl Sized; + +fn define() -> Test { &() as *const ()} + +fn test(x: Test) { + let _: OnWShow = id2(&&W(x), &&W(&() as *const ())).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend-outer-id-right.rs b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend-outer-id-right.rs new file mode 100644 index 0000000000000..5cbdd107c3946 --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend-outer-id-right.rs @@ -0,0 +1,40 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// check-pass + +#![feature(type_alias_impl_trait)] + +struct W(T); + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} + +struct OnWSendShow; +trait OnWSend { + fn show(&self) -> OnWSendShow { + OnWSendShow + } +} + +impl OnW for W {} +impl OnWSend for &W {} + +fn id2(_: T, x: T) -> T { + x +} + +type Test = impl Sized; + +fn define() -> Test { &() as *const ()} + +fn test(x: Test) { + let _: OnWShow = id2(&&W(&() as *const ()), &&W(x)).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend.new.stderr b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend.new.stderr new file mode 100644 index 0000000000000..84cbe138ce917 --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend.new.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/reveal-auto-trait-notsend.rs:37:22 + | +LL | let _: OnWShow = (&&W(x)).show(); + | ------- ^^^^^^^^^^^^^^^ expected `OnWShow`, found `OnWSendShow` + | | + | expected due to this + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend.old.stderr b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend.old.stderr new file mode 100644 index 0000000000000..6b7727e3ad449 --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend.old.stderr @@ -0,0 +1,23 @@ +error[E0391]: cycle detected when computing type of opaque `Test::{opaque#0}` + --> $DIR/reveal-auto-trait-notsend.rs:32:13 + | +LL | type Test = impl Sized; + | ^^^^^^^^^^ + | +note: ...which requires type-checking `test`... + --> $DIR/reveal-auto-trait-notsend.rs:37:31 + | +LL | let _: OnWShow = (&&W(x)).show(); + | ^^^^ + = note: ...which requires evaluating trait selection obligation `&'a W: OnWSend`... + = note: ...which again requires computing type of opaque `Test::{opaque#0}`, completing the cycle +note: cycle used when computing type of `Test::{opaque#0}` + --> $DIR/reveal-auto-trait-notsend.rs:32:13 + | +LL | type Test = impl Sized; + | ^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend.rs b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend.rs new file mode 100644 index 0000000000000..58a411d992d10 --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-notsend.rs @@ -0,0 +1,40 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// known-bug: unknown + +#![feature(type_alias_impl_trait)] + +struct W(T); + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} + +struct OnWSendShow; +trait OnWSend { + fn show(&self) -> OnWSendShow { + OnWSendShow + } +} + +impl OnW for W {} +impl OnWSend for &W {} + +fn id2(_: T, x: T) -> T { + x +} + +type Test = impl Sized; + +fn define() -> Test { &() as *const () } + +fn test(x: Test) { + let _: OnWShow = (&&W(x)).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-inner-id-left.new.stderr b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-inner-id-left.new.stderr new file mode 100644 index 0000000000000..5941f01391d64 --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-inner-id-left.new.stderr @@ -0,0 +1,63 @@ +error[E0391]: cycle detected when computing type of `Test::{opaque#0}` + --> $DIR/reveal-auto-trait-send-inner-id-left.rs:32:13 + | +LL | type Test = impl Sized; + | ^^^^^^^^^^ + | +note: ...which requires computing type of opaque `Test::{opaque#0}`... + --> $DIR/reveal-auto-trait-send-inner-id-left.rs:32:13 + | +LL | type Test = impl Sized; + | ^^^^^^^^^^ +note: ...which requires borrow-checking `test`... + --> $DIR/reveal-auto-trait-send-inner-id-left.rs:36:1 + | +LL | fn test(x: Test) { + | ^^^^^^^^^^^^^^^^ +note: ...which requires promoting constants in MIR for `test`... + --> $DIR/reveal-auto-trait-send-inner-id-left.rs:36:1 + | +LL | fn test(x: Test) { + | ^^^^^^^^^^^^^^^^ +note: ...which requires preparing `test` for borrow checking... + --> $DIR/reveal-auto-trait-send-inner-id-left.rs:36:1 + | +LL | fn test(x: Test) { + | ^^^^^^^^^^^^^^^^ +note: ...which requires unsafety-checking `test`... + --> $DIR/reveal-auto-trait-send-inner-id-left.rs:36:1 + | +LL | fn test(x: Test) { + | ^^^^^^^^^^^^^^^^ +note: ...which requires building MIR for `test`... + --> $DIR/reveal-auto-trait-send-inner-id-left.rs:36:1 + | +LL | fn test(x: Test) { + | ^^^^^^^^^^^^^^^^ +note: ...which requires resolving instance `<&W as OnWSend>::show`... + --> $DIR/reveal-auto-trait-send-inner-id-left.rs:20:5 + | +LL | fn show(&self) -> OnWSendShow { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires computing candidate for `<&W as OnWSend>`... + --> $DIR/reveal-auto-trait-send-inner-id-left.rs:19:1 + | +LL | trait OnWSend { + | ^^^^^^^^^^^^^ + = note: ...which again requires computing type of `Test::{opaque#0}`, completing the cycle +note: cycle used when checking item types in top-level module + --> $DIR/reveal-auto-trait-send-inner-id-left.rs:7:1 + | +LL | / #![feature(type_alias_impl_trait)] +LL | | +LL | | struct W(T); +LL | | +... | +LL | | +LL | | fn main() {} + | |____________^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-inner-id-left.old.stderr b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-inner-id-left.old.stderr new file mode 100644 index 0000000000000..2d2f75d675d56 --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-inner-id-left.old.stderr @@ -0,0 +1,32 @@ +error[E0308]: mismatched types + --> $DIR/reveal-auto-trait-send-inner-id-left.rs:37:26 + | +LL | let _: OnWSendShow = (&&W(id2(x, ()))).show(); + | ----------- ^^^^^^^^^^^^^^^^^^^^^^^^ expected `OnWSendShow`, found `OnWShow` + | | + | expected due to this + +error[E0391]: cycle detected when computing type of opaque `Test::{opaque#0}` + --> $DIR/reveal-auto-trait-send-inner-id-left.rs:32:13 + | +LL | type Test = impl Sized; + | ^^^^^^^^^^ + | +note: ...which requires type-checking `test`... + --> $DIR/reveal-auto-trait-send-inner-id-left.rs:37:44 + | +LL | let _: OnWSendShow = (&&W(id2(x, ()))).show(); + | ^^^^ + = note: ...which requires evaluating trait selection obligation `&'a W: OnWSend`... + = note: ...which again requires computing type of opaque `Test::{opaque#0}`, completing the cycle +note: cycle used when computing type of `Test::{opaque#0}` + --> $DIR/reveal-auto-trait-send-inner-id-left.rs:32:13 + | +LL | type Test = impl Sized; + | ^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0308, E0391. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-inner-id-left.rs b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-inner-id-left.rs new file mode 100644 index 0000000000000..2c425f9103cfe --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-inner-id-left.rs @@ -0,0 +1,40 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// known-bug: unknown + +#![feature(type_alias_impl_trait)] + +struct W(T); + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} + +struct OnWSendShow; +trait OnWSend { + fn show(&self) -> OnWSendShow { + OnWSendShow + } +} + +impl OnW for W {} +impl OnWSend for &W {} + +fn id2(_: T, x: T) -> T { + x +} + +type Test = impl Sized; + +fn define() -> Test {} + +fn test(x: Test) { + let _: OnWSendShow = (&&W(id2(x, ()))).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-inner-id-right.rs b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-inner-id-right.rs new file mode 100644 index 0000000000000..e116e09fd80ad --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-inner-id-right.rs @@ -0,0 +1,40 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// check-pass + +#![feature(type_alias_impl_trait)] + +struct W(T); + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} + +struct OnWSendShow; +trait OnWSend { + fn show(&self) -> OnWSendShow { + OnWSendShow + } +} + +impl OnW for W {} +impl OnWSend for &W {} + +fn id2(_: T, x: T) -> T { + x +} + +type Test = impl Sized; + +fn define() -> Test {} + +fn test(x: Test) { + let _: OnWSendShow = (&&W(id2((), x))).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-outer-id-left.new.stderr b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-outer-id-left.new.stderr new file mode 100644 index 0000000000000..06b560dddbb32 --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-outer-id-left.new.stderr @@ -0,0 +1,63 @@ +error[E0391]: cycle detected when computing type of `Test::{opaque#0}` + --> $DIR/reveal-auto-trait-send-outer-id-left.rs:32:13 + | +LL | type Test = impl Sized; + | ^^^^^^^^^^ + | +note: ...which requires computing type of opaque `Test::{opaque#0}`... + --> $DIR/reveal-auto-trait-send-outer-id-left.rs:32:13 + | +LL | type Test = impl Sized; + | ^^^^^^^^^^ +note: ...which requires borrow-checking `test`... + --> $DIR/reveal-auto-trait-send-outer-id-left.rs:36:1 + | +LL | fn test(x: Test) { + | ^^^^^^^^^^^^^^^^ +note: ...which requires promoting constants in MIR for `test`... + --> $DIR/reveal-auto-trait-send-outer-id-left.rs:36:1 + | +LL | fn test(x: Test) { + | ^^^^^^^^^^^^^^^^ +note: ...which requires preparing `test` for borrow checking... + --> $DIR/reveal-auto-trait-send-outer-id-left.rs:36:1 + | +LL | fn test(x: Test) { + | ^^^^^^^^^^^^^^^^ +note: ...which requires unsafety-checking `test`... + --> $DIR/reveal-auto-trait-send-outer-id-left.rs:36:1 + | +LL | fn test(x: Test) { + | ^^^^^^^^^^^^^^^^ +note: ...which requires building MIR for `test`... + --> $DIR/reveal-auto-trait-send-outer-id-left.rs:36:1 + | +LL | fn test(x: Test) { + | ^^^^^^^^^^^^^^^^ +note: ...which requires resolving instance `<&W as OnWSend>::show`... + --> $DIR/reveal-auto-trait-send-outer-id-left.rs:20:5 + | +LL | fn show(&self) -> OnWSendShow { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires computing candidate for `<&W as OnWSend>`... + --> $DIR/reveal-auto-trait-send-outer-id-left.rs:19:1 + | +LL | trait OnWSend { + | ^^^^^^^^^^^^^ + = note: ...which again requires computing type of `Test::{opaque#0}`, completing the cycle +note: cycle used when checking item types in top-level module + --> $DIR/reveal-auto-trait-send-outer-id-left.rs:7:1 + | +LL | / #![feature(type_alias_impl_trait)] +LL | | +LL | | struct W(T); +LL | | +... | +LL | | +LL | | fn main() {} + | |____________^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-outer-id-left.old.stderr b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-outer-id-left.old.stderr new file mode 100644 index 0000000000000..c4ed046889911 --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-outer-id-left.old.stderr @@ -0,0 +1,32 @@ +error[E0308]: mismatched types + --> $DIR/reveal-auto-trait-send-outer-id-left.rs:37:26 + | +LL | let _: OnWSendShow = id2(&&W(x), &&W(())).show(); + | ----------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `OnWSendShow`, found `OnWShow` + | | + | expected due to this + +error[E0391]: cycle detected when computing type of opaque `Test::{opaque#0}` + --> $DIR/reveal-auto-trait-send-outer-id-left.rs:32:13 + | +LL | type Test = impl Sized; + | ^^^^^^^^^^ + | +note: ...which requires type-checking `test`... + --> $DIR/reveal-auto-trait-send-outer-id-left.rs:37:47 + | +LL | let _: OnWSendShow = id2(&&W(x), &&W(())).show(); + | ^^^^ + = note: ...which requires evaluating trait selection obligation `&'a W: OnWSend`... + = note: ...which again requires computing type of opaque `Test::{opaque#0}`, completing the cycle +note: cycle used when computing type of `Test::{opaque#0}` + --> $DIR/reveal-auto-trait-send-outer-id-left.rs:32:13 + | +LL | type Test = impl Sized; + | ^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0308, E0391. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-outer-id-left.rs b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-outer-id-left.rs new file mode 100644 index 0000000000000..2ec081e077510 --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-outer-id-left.rs @@ -0,0 +1,40 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// known-bug: unknown + +#![feature(type_alias_impl_trait)] + +struct W(T); + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} + +struct OnWSendShow; +trait OnWSend { + fn show(&self) -> OnWSendShow { + OnWSendShow + } +} + +impl OnW for W {} +impl OnWSend for &W {} + +fn id2(_: T, x: T) -> T { + x +} + +type Test = impl Sized; + +fn define() -> Test {} + +fn test(x: Test) { + let _: OnWSendShow = id2(&&W(x), &&W(())).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-outer-id-right.rs b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-outer-id-right.rs new file mode 100644 index 0000000000000..2e771fbf41bc3 --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send-outer-id-right.rs @@ -0,0 +1,40 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// check-pass + +#![feature(type_alias_impl_trait)] + +struct W(T); + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} + +struct OnWSendShow; +trait OnWSend { + fn show(&self) -> OnWSendShow { + OnWSendShow + } +} + +impl OnW for W {} +impl OnWSend for &W {} + +fn id2(_: T, x: T) -> T { + x +} + +type Test = impl Sized; + +fn define() -> Test {} + +fn test(x: Test) { + let _: OnWSendShow = id2(&&W(()), &&W(x)).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send.new.stderr b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send.new.stderr new file mode 100644 index 0000000000000..3fe0e72d57f20 --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send.new.stderr @@ -0,0 +1,12 @@ +error[E0283]: type annotations needed: cannot satisfy `&W: OnWSend` + --> $DIR/reveal-auto-trait-send.rs:37:35 + | +LL | let _: OnWSendShow = (&&W(x)).show(); + | ^^^^ + | + = note: cannot satisfy `&W: OnWSend` + = help: the trait `OnWSend` is implemented for `&W` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0283`. diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send.old.stderr b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send.old.stderr new file mode 100644 index 0000000000000..e8bdc6ac0291a --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send.old.stderr @@ -0,0 +1,32 @@ +error[E0308]: mismatched types + --> $DIR/reveal-auto-trait-send.rs:37:26 + | +LL | let _: OnWSendShow = (&&W(x)).show(); + | ----------- ^^^^^^^^^^^^^^^ expected `OnWSendShow`, found `OnWShow` + | | + | expected due to this + +error[E0391]: cycle detected when computing type of opaque `Test::{opaque#0}` + --> $DIR/reveal-auto-trait-send.rs:32:13 + | +LL | type Test = impl Sized; + | ^^^^^^^^^^ + | +note: ...which requires type-checking `test`... + --> $DIR/reveal-auto-trait-send.rs:37:35 + | +LL | let _: OnWSendShow = (&&W(x)).show(); + | ^^^^ + = note: ...which requires evaluating trait selection obligation `&'a W: OnWSend`... + = note: ...which again requires computing type of opaque `Test::{opaque#0}`, completing the cycle +note: cycle used when computing type of `Test::{opaque#0}` + --> $DIR/reveal-auto-trait-send.rs:32:13 + | +LL | type Test = impl Sized; + | ^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0308, E0391. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send.rs b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send.rs new file mode 100644 index 0000000000000..a6578eead6a2c --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-auto-trait-send.rs @@ -0,0 +1,40 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// known-bug: unknown + +#![feature(type_alias_impl_trait)] + +struct W(T); + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} + +struct OnWSendShow; +trait OnWSend { + fn show(&self) -> OnWSendShow { + OnWSendShow + } +} + +impl OnW for W {} +impl OnWSend for &W {} + +fn id2(_: T, x: T) -> T { + x +} + +type Test = impl Sized; + +fn define() -> Test {} + +fn test(x: Test) { + let _: OnWSendShow = (&&W(x)).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver-id-left.new.stderr b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver-id-left.new.stderr new file mode 100644 index 0000000000000..23aa33884f1a1 --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver-id-left.new.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/reveal-hidden-via-unwrapped-receiver-id-left.rs:37:20 + | +LL | let _: IShow = id2(x, I).show(); + | ----- ^^^^^^^^^^^^^^^^ expected `IShow`, found `OnIShow` + | | + | expected due to this + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver-id-left.old.stderr b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver-id-left.old.stderr new file mode 100644 index 0000000000000..c48df2d9bc4e6 --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver-id-left.old.stderr @@ -0,0 +1,37 @@ +error[E0599]: no method named `show` found for opaque type `Test` in the current scope + --> $DIR/reveal-hidden-via-unwrapped-receiver-id-left.rs:37:30 + | +LL | let _: IShow = id2(x, I).show(); + | ^^^^ method not found in `Test` + | + = help: items from traits can only be used if the trait is implemented and in scope +note: `OnI` defines an item `show`, perhaps you need to implement it + --> $DIR/reveal-hidden-via-unwrapped-receiver-id-left.rs:19:1 + | +LL | trait OnI { + | ^^^^^^^^^ + +error[E0391]: cycle detected when computing type of opaque `Test::{opaque#0}` + --> $DIR/reveal-hidden-via-unwrapped-receiver-id-left.rs:30:13 + | +LL | type Test = impl Sized; + | ^^^^^^^^^^ + | +note: ...which requires type-checking `test`... + --> $DIR/reveal-hidden-via-unwrapped-receiver-id-left.rs:37:20 + | +LL | let _: IShow = id2(x, I).show(); + | ^^^^^^^^^ + = note: ...which requires evaluating trait selection obligation `Test: core::marker::Unpin`... + = note: ...which again requires computing type of opaque `Test::{opaque#0}`, completing the cycle +note: cycle used when computing type of `Test::{opaque#0}` + --> $DIR/reveal-hidden-via-unwrapped-receiver-id-left.rs:30:13 + | +LL | type Test = impl Sized; + | ^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0391, E0599. +For more information about an error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver-id-left.rs b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver-id-left.rs new file mode 100644 index 0000000000000..7e41afce9faa4 --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver-id-left.rs @@ -0,0 +1,40 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// known-bug: unknown + +#![feature(type_alias_impl_trait)] + +struct I; +struct IShow; +impl I { + #[allow(dead_code)] + pub fn show(&self) -> IShow { + IShow + } +} + +struct OnIShow; +trait OnI { + fn show(&self) -> OnIShow { + OnIShow + } +} +impl OnI for I {} + +fn id2(_: T, x: T) -> T { + x +} + +type Test = impl Sized; + +fn define() -> Test { + I +} + +fn test(x: Test) { + let _: IShow = id2(x, I).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver-id-right.rs b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver-id-right.rs new file mode 100644 index 0000000000000..5655e3ed9ba1d --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver-id-right.rs @@ -0,0 +1,39 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// check-pass + +#![feature(type_alias_impl_trait)] + +struct I; +struct IShow; +impl I { + pub fn show(&self) -> IShow { + IShow + } +} + +struct OnIShow; +trait OnI { + fn show(&self) -> OnIShow { + OnIShow + } +} +impl OnI for I {} + +fn id2(_: T, x: T) -> T { + x +} + +type Test = impl Sized; + +fn define() -> Test { + I +} + +fn test(x: Test) { + let _: IShow = id2(I, x).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver.new.stderr b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver.new.stderr new file mode 100644 index 0000000000000..e5c441647f1fc --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver.new.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/reveal-hidden-via-unwrapped-receiver.rs:33:20 + | +LL | let _: IShow = x.show(); + | ----- ^^^^^^^^ expected `IShow`, found `OnIShow` + | | + | expected due to this + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver.old.stderr b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver.old.stderr new file mode 100644 index 0000000000000..fa4081fc54efe --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver.old.stderr @@ -0,0 +1,37 @@ +error[E0599]: no method named `show` found for opaque type `Test` in the current scope + --> $DIR/reveal-hidden-via-unwrapped-receiver.rs:33:22 + | +LL | let _: IShow = x.show(); + | ^^^^ method not found in `Test` + | + = help: items from traits can only be used if the trait is implemented and in scope +note: `OnI` defines an item `show`, perhaps you need to implement it + --> $DIR/reveal-hidden-via-unwrapped-receiver.rs:19:1 + | +LL | trait OnI { + | ^^^^^^^^^ + +error[E0391]: cycle detected when computing type of opaque `Test::{opaque#0}` + --> $DIR/reveal-hidden-via-unwrapped-receiver.rs:26:13 + | +LL | type Test = impl Sized; + | ^^^^^^^^^^ + | +note: ...which requires type-checking `test`... + --> $DIR/reveal-hidden-via-unwrapped-receiver.rs:33:20 + | +LL | let _: IShow = x.show(); + | ^ + = note: ...which requires evaluating trait selection obligation `Test: core::marker::Unpin`... + = note: ...which again requires computing type of opaque `Test::{opaque#0}`, completing the cycle +note: cycle used when computing type of `Test::{opaque#0}` + --> $DIR/reveal-hidden-via-unwrapped-receiver.rs:26:13 + | +LL | type Test = impl Sized; + | ^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0391, E0599. +For more information about an error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver.rs b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver.rs new file mode 100644 index 0000000000000..b503f7ad4f93b --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-unwrapped-receiver.rs @@ -0,0 +1,36 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// known-bug: unknown + +#![feature(type_alias_impl_trait)] + +struct I; +struct IShow; +impl I { + #[allow(dead_code)] + pub fn show(&self) -> IShow { + IShow + } +} + +struct OnIShow; +trait OnI { + fn show(&self) -> OnIShow { + OnIShow + } +} +impl OnI for I {} + +type Test = impl Sized; + +fn define() -> Test { + I +} + +fn test(x: Test) { + let _: IShow = x.show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver-inner-id-left.old.stderr b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver-inner-id-left.old.stderr new file mode 100644 index 0000000000000..dbed9592a2e7e --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver-inner-id-left.old.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/reveal-hidden-via-wrapped-receiver-inner-id-left.rs:35:20 + | +LL | let _: WShow = W(id2(x, ())).show(); + | ----- ^^^^^^^^^^^^^^^^^^^^ expected `WShow`, found `OnWShow` + | | + | expected due to this + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver-inner-id-left.rs b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver-inner-id-left.rs new file mode 100644 index 0000000000000..a809a5ecf59a6 --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver-inner-id-left.rs @@ -0,0 +1,38 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// [new]check-pass +// [old]known-bug: unknown + +#![feature(type_alias_impl_trait)] + +struct W(T); +struct WShow; +impl W<()> { + pub fn show(&self) -> WShow { + WShow + } +} + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} +impl OnW for W {} + +fn id2(_: T, x: T) -> T { + x +} + +type Test = impl Sized; + +fn define() -> Test {} + +fn test(x: Test) { + let _: WShow = W(id2(x, ())).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver-inner-id-right.rs b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver-inner-id-right.rs new file mode 100644 index 0000000000000..b31783587b909 --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver-inner-id-right.rs @@ -0,0 +1,37 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// check-pass + +#![feature(type_alias_impl_trait)] + +struct W(T); +struct WShow; +impl W<()> { + pub fn show(&self) -> WShow { + WShow + } +} + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} +impl OnW for W {} + +fn id2(_: T, x: T) -> T { + x +} + +type Test = impl Sized; + +fn define() -> Test {} + +fn test(x: Test) { + let _: WShow = W(id2((), x)).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver-outer-id-left.old.stderr b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver-outer-id-left.old.stderr new file mode 100644 index 0000000000000..67990705593ca --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver-outer-id-left.old.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/reveal-hidden-via-wrapped-receiver-outer-id-left.rs:35:20 + | +LL | let _: WShow = id2(W(x), W(())).show(); + | ----- ^^^^^^^^^^^^^^^^^^^^^^^ expected `WShow`, found `OnWShow` + | | + | expected due to this + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver-outer-id-left.rs b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver-outer-id-left.rs new file mode 100644 index 0000000000000..277aa91907875 --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver-outer-id-left.rs @@ -0,0 +1,38 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// [new]check-pass +// [old]known-bug: unknown + +#![feature(type_alias_impl_trait)] + +struct W(T); +struct WShow; +impl W<()> { + pub fn show(&self) -> WShow { + WShow + } +} + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} +impl OnW for W {} + +fn id2(_: T, x: T) -> T { + x +} + +type Test = impl Sized; + +fn define() -> Test {} + +fn test(x: Test) { + let _: WShow = id2(W(x), W(())).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver-outer-id-right.rs b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver-outer-id-right.rs new file mode 100644 index 0000000000000..cb635b8104dc0 --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver-outer-id-right.rs @@ -0,0 +1,37 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// check-pass + +#![feature(type_alias_impl_trait)] + +struct W(T); +struct WShow; +impl W<()> { + pub fn show(&self) -> WShow { + WShow + } +} + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} +impl OnW for W {} + +fn id2(_: T, x: T) -> T { + x +} + +type Test = impl Sized; + +fn define() -> Test {} + +fn test(x: Test) { + let _: WShow = id2(W(()), W(x)).show(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver.old.stderr b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver.old.stderr new file mode 100644 index 0000000000000..99cc6caf6c0b1 --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver.old.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/reveal-hidden-via-wrapped-receiver.rs:31:20 + | +LL | let _: WShow = W(x).show(); + | ----- ^^^^^^^^^^^ expected `WShow`, found `OnWShow` + | | + | expected due to this + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver.rs b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver.rs new file mode 100644 index 0000000000000..088c1297b3228 --- /dev/null +++ b/tests/ui/impl-trait/inference/may-define-without-must-define/reveal-hidden-via-wrapped-receiver.rs @@ -0,0 +1,34 @@ +// edition:2021 +// revisions: new old +// [new]compile-flags: -Ztrait-solver=next +// [old]compile-flags: -Ztrait-solver=classic +// [new]check-pass +// [old]known-bug: unknown + +#![feature(type_alias_impl_trait)] + +struct W(T); +struct WShow; +impl W<()> { + pub fn show(&self) -> WShow { + WShow + } +} + +struct OnWShow; +trait OnW { + fn show(&self) -> OnWShow { + OnWShow + } +} +impl OnW for W {} + +type Test = impl Sized; + +fn define() -> Test {} + +fn test(x: Test) { + let _: WShow = W(x).show(); +} + +fn main() {}