Auto merge of #152738 - workingjubilee:revert-unsound-ice-patch, r=mati865
Revert "Fix an ICE in the vtable iteration for a trait reference"
The ICE fix appears to be unsound, causing a miscompilation involving `dyn Trait` and `async {}` which induces segfaults in safe Rust code. As the patch only hid an ICE, it does not seem worth the risk.
This addresses the problem in rust-lang/rust#152735 but it may still merit team discussion even if this PR is merged.
This reverts commit 8afd63610b, reversing changes made to 19122c03c7.
This commit is contained in:
commit
3f6250a7bb
8 changed files with 35 additions and 88 deletions
|
|
@ -1,8 +1,4 @@
|
|||
// Regression test for #135470.
|
||||
// Verify that we don't ICE when building vtable entries
|
||||
// for a blanket impl involving async and impossible predicates.
|
||||
|
||||
//@ check-pass
|
||||
//@ known-bug: #135470
|
||||
//@ compile-flags: -Copt-level=0
|
||||
//@ edition: 2021
|
||||
|
||||
18
tests/crashes/137190-2.rs
Normal file
18
tests/crashes/137190-2.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
//@ known-bug: #137190
|
||||
trait Supertrait<T> {
|
||||
fn method(&self) {}
|
||||
}
|
||||
|
||||
trait Trait<P>: Supertrait<()> {}
|
||||
|
||||
impl<P> Trait<P> for () {}
|
||||
|
||||
const fn upcast<P>(x: &dyn Trait<P>) -> &dyn Supertrait<()> {
|
||||
x
|
||||
}
|
||||
|
||||
const fn foo() -> &'static dyn Supertrait<()> {
|
||||
upcast::<()>(&())
|
||||
}
|
||||
|
||||
const _: &'static dyn Supertrait<()> = foo();
|
||||
10
tests/crashes/137190-3.rs
Normal file
10
tests/crashes/137190-3.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
//@ known-bug: #137190
|
||||
trait Supertrait {
|
||||
fn method(&self) {}
|
||||
}
|
||||
|
||||
trait Trait: Supertrait {}
|
||||
|
||||
impl Trait for () {}
|
||||
|
||||
const _: &dyn Supertrait = &() as &dyn Trait as &dyn Supertrait;
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
// Regression test for #137190.
|
||||
// Variant of vtable-unsatisfied-supertrait.rs with generic traits.
|
||||
// Verify that we don't ICE when building vtable entries
|
||||
// for a generic trait whose supertrait is not implemented.
|
||||
|
||||
//@ compile-flags: --crate-type lib
|
||||
|
||||
trait Supertrait<T> {
|
||||
fn method(&self) {}
|
||||
}
|
||||
|
||||
trait Trait<P>: Supertrait<()> {}
|
||||
|
||||
impl<P> Trait<P> for () {}
|
||||
//~^ ERROR the trait bound `(): Supertrait<()>` is not satisfied
|
||||
|
||||
const fn upcast<P>(x: &dyn Trait<P>) -> &dyn Supertrait<()> {
|
||||
x
|
||||
}
|
||||
|
||||
const fn foo() -> &'static dyn Supertrait<()> {
|
||||
upcast::<()>(&())
|
||||
}
|
||||
|
||||
const _: &'static dyn Supertrait<()> = foo();
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
error[E0277]: the trait bound `(): Supertrait<()>` is not satisfied
|
||||
--> $DIR/vtable-unsatisfied-supertrait-generics.rs:14:22
|
||||
|
|
||||
LL | impl<P> Trait<P> for () {}
|
||||
| ^^ the trait `Supertrait<()>` is not implemented for `()`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/vtable-unsatisfied-supertrait-generics.rs:8:1
|
||||
|
|
||||
LL | trait Supertrait<T> {
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `Trait`
|
||||
--> $DIR/vtable-unsatisfied-supertrait-generics.rs:12:17
|
||||
|
|
||||
LL | trait Trait<P>: Supertrait<()> {}
|
||||
| ^^^^^^^^^^^^^^ required by this bound in `Trait`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
// Regression test for #137190.
|
||||
// Verify that we don't ICE when building vtable entries
|
||||
// for a trait whose supertrait is not implemented.
|
||||
|
||||
//@ compile-flags: --crate-type lib
|
||||
|
||||
trait Supertrait {
|
||||
fn method(&self) {}
|
||||
}
|
||||
|
||||
trait Trait: Supertrait {}
|
||||
|
||||
impl Trait for () {}
|
||||
//~^ ERROR the trait bound `(): Supertrait` is not satisfied
|
||||
|
||||
const _: &dyn Supertrait = &() as &dyn Trait as &dyn Supertrait;
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
error[E0277]: the trait bound `(): Supertrait` is not satisfied
|
||||
--> $DIR/vtable-unsatisfied-supertrait.rs:13:16
|
||||
|
|
||||
LL | impl Trait for () {}
|
||||
| ^^ the trait `Supertrait` is not implemented for `()`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/vtable-unsatisfied-supertrait.rs:7:1
|
||||
|
|
||||
LL | trait Supertrait {
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `Trait`
|
||||
--> $DIR/vtable-unsatisfied-supertrait.rs:11:14
|
||||
|
|
||||
LL | trait Trait: Supertrait {}
|
||||
| ^^^^^^^^^^ required by this bound in `Trait`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue