add RPITIT tests: method compat auto trait leakage
This commit is contained in:
parent
2e79f7cd61
commit
836ea25b4d
4 changed files with 224 additions and 0 deletions
|
@ -0,0 +1,58 @@
|
|||
error[E0391]: cycle detected when computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::{anon_assoc#0}`
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:24
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:24
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^
|
||||
= note: ...which requires evaluating trait selection obligation `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo::{opaque#0}: core::marker::Send`...
|
||||
note: ...which requires computing type of opaque `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo::{opaque#0}`...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:24
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^
|
||||
note: ...which requires borrow-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:5
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires promoting constants in MIR for `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:5
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires checking if `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo` contains FFI-unwind calls...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:5
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires building MIR for `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:5
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires match-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:5
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires type-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:5
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: ...which again requires computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::{anon_assoc#0}`, completing the cycle
|
||||
note: cycle used when checking that `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>` is well-formed
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:17:1
|
||||
|
|
||||
LL | impl Trait for u32 {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
= 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 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0391`.
|
|
@ -0,0 +1,122 @@
|
|||
error[E0391]: cycle detected when computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::{anon_assoc#0}`
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:24
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:5
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo::{opaque#0}`...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:24
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^
|
||||
note: ...which requires computing type of opaque `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo::{opaque#0}`...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:24
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^
|
||||
note: ...which requires borrow-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:5
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires promoting constants in MIR for `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:5
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires checking if `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo` contains FFI-unwind calls...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:5
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires building MIR for `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:5
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires match-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:5
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires type-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:5
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: ...which again requires computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::{anon_assoc#0}`, completing the cycle
|
||||
note: cycle used when checking that `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>` is well-formed
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:17:1
|
||||
|
|
||||
LL | impl Trait for u32 {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
= 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[E0391]: cycle detected when computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::{anon_assoc#0}`
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:24
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:5
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo::{opaque#0}`...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:24
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^
|
||||
note: ...which requires computing type of opaque `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo::{opaque#0}`...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:24
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^
|
||||
note: ...which requires borrow-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:5
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires promoting constants in MIR for `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:5
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires checking if `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo` contains FFI-unwind calls...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:5
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires building MIR for `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:5
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires match-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:5
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires type-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:21:5
|
||||
|
|
||||
LL | fn foo(b: bool) -> impl Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: ...which again requires computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::{anon_assoc#0}`, completing the cycle
|
||||
note: cycle used when checking that `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>` is well-formed
|
||||
--> $DIR/method-compatability-via-leakage-cycle.rs:17:1
|
||||
|
|
||||
LL | impl Trait for u32 {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
= 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
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0391`.
|
|
@ -0,0 +1,30 @@
|
|||
//@ revisions: current next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@ known-bug: #139788
|
||||
|
||||
// Recursively using the trait method inside of an impl in case checking
|
||||
// method compatability relies on opaque type leakage currently causes a
|
||||
// cycle error.
|
||||
|
||||
trait Trait {
|
||||
// desugars to
|
||||
// type Assoc: Sized + Send;
|
||||
// fn foo(b: bool) -> Self::Assoc;
|
||||
fn foo(b: bool) -> impl Sized + Send;
|
||||
}
|
||||
|
||||
impl Trait for u32 {
|
||||
// desugars to
|
||||
// type Assoc = impl_rpit::<Self>;
|
||||
// fn foo(b: bool) -> Self::Assoc { .. }
|
||||
fn foo(b: bool) -> impl Sized {
|
||||
if b {
|
||||
u32::foo(false)
|
||||
} else {
|
||||
1u32
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,14 @@
|
|||
//@ check-pass
|
||||
//@ revisions: current next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
|
||||
trait Trait {
|
||||
fn foo() -> impl Sized + Send;
|
||||
}
|
||||
|
||||
impl Trait for u32 {
|
||||
fn foo() -> impl Sized {}
|
||||
}
|
||||
|
||||
fn main() {}
|
Loading…
Add table
Add a link
Reference in a new issue