diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-02-08 20:35:01 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-08 20:35:01 +0100 |
| commit | ed528515d0057aa96a6b24457d14d35ed8cb431c (patch) | |
| tree | 4bb61c282edf05b8b61e8789f5f4b2d355ab6ee0 /tests | |
| parent | 9565e8d81e7de0e48ff6f1597c7346bf058e5368 (diff) | |
| parent | ad511ef92ed5454182c1c6b3afe0846d654af009 (diff) | |
| download | rust-ed528515d0057aa96a6b24457d14d35ed8cb431c.tar.gz rust-ed528515d0057aa96a6b24457d14d35ed8cb431c.zip | |
Rollup merge of #120801 - oli-obk:drop_recursion_ice, r=Nilstrieb
Avoid ICE in drop recursion check in case of invalid drop impls fixes #120787
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/drop/recursion-check-on-erroneous-impl.rs | 11 | ||||
| -rw-r--r-- | tests/ui/drop/recursion-check-on-erroneous-impl.stderr | 11 |
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/ui/drop/recursion-check-on-erroneous-impl.rs b/tests/ui/drop/recursion-check-on-erroneous-impl.rs new file mode 100644 index 00000000000..733c8b0b085 --- /dev/null +++ b/tests/ui/drop/recursion-check-on-erroneous-impl.rs @@ -0,0 +1,11 @@ +// can't use build-fail, because this also fails check-fail, but +// the ICE from #120787 only reproduces on build-fail. +// compile-flags: --emit=mir + +struct PrintOnDrop<'a>(&'a str); + +impl Drop for PrintOnDrop<'_> { + fn drop() {} //~ ERROR method `drop` has a `&mut self` declaration in the trait +} + +fn main() {} diff --git a/tests/ui/drop/recursion-check-on-erroneous-impl.stderr b/tests/ui/drop/recursion-check-on-erroneous-impl.stderr new file mode 100644 index 00000000000..831adb88cef --- /dev/null +++ b/tests/ui/drop/recursion-check-on-erroneous-impl.stderr @@ -0,0 +1,11 @@ +error[E0186]: method `drop` has a `&mut self` declaration in the trait, but not in the impl + --> $DIR/recursion-check-on-erroneous-impl.rs:8:5 + | +LL | fn drop() {} + | ^^^^^^^^^ expected `&mut self` in impl + | + = note: `drop` from trait: `fn(&mut Self)` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0186`. |
