diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-05-04 08:09:03 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-04 08:09:03 +0200 |
| commit | 6fca1a925985105e4393bbca227f868ee2de5c96 (patch) | |
| tree | a17338ec1a8a911d960a26804f7bd912ca9ba378 /tests/ui/consts | |
| parent | 129195f57c02c8a8e4cfc4b766d4ff7a3a837882 (diff) | |
| parent | bd146c72ac2faf6bbf189ad92d06e0bcd6cc92fc (diff) | |
| download | rust-6fca1a925985105e4393bbca227f868ee2de5c96.tar.gz rust-6fca1a925985105e4393bbca227f868ee2de5c96.zip | |
Rollup merge of #110859 - compiler-errors:no-negative-drop-impls, r=oli-obk
Explicitly reject negative and reservation drop impls Fixes #110858 It doesn't really make sense for a type to have a `!Drop` impl. Or at least, I don't want us to implicitly assign a meaning to it by the way the compiler *currently* handles it (incompletely), and rather I would like to see a PR (or an RFC...) assign a meaning to `!Drop` if we actually wanted one for it.
Diffstat (limited to 'tests/ui/consts')
| -rw-r--r-- | tests/ui/consts/const-block-const-bound.rs | 6 | ||||
| -rw-r--r-- | tests/ui/consts/const-block-const-bound.stderr | 18 |
2 files changed, 2 insertions, 22 deletions
diff --git a/tests/ui/consts/const-block-const-bound.rs b/tests/ui/consts/const-block-const-bound.rs index 42aa0216b87..3704a1a5a39 100644 --- a/tests/ui/consts/const-block-const-bound.rs +++ b/tests/ui/consts/const-block-const-bound.rs @@ -11,15 +11,9 @@ impl Drop for UnconstDrop { fn drop(&mut self) {} } -struct NonDrop; - -impl !Drop for NonDrop {} - fn main() { const { f(UnconstDrop); //~^ ERROR can't drop - f(NonDrop); - //~^ ERROR can't drop } } diff --git a/tests/ui/consts/const-block-const-bound.stderr b/tests/ui/consts/const-block-const-bound.stderr index fef4914fad5..caf24e7afcf 100644 --- a/tests/ui/consts/const-block-const-bound.stderr +++ b/tests/ui/consts/const-block-const-bound.stderr @@ -1,5 +1,5 @@ error[E0277]: can't drop `UnconstDrop` in const contexts - --> $DIR/const-block-const-bound.rs:20:9 + --> $DIR/const-block-const-bound.rs:16:9 | LL | f(UnconstDrop); | ^^^^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `UnconstDrop` @@ -12,20 +12,6 @@ LL | &f(UnconstDrop); LL | &mut f(UnconstDrop); | ++++ -error[E0277]: can't drop `NonDrop` in const contexts - --> $DIR/const-block-const-bound.rs:22:9 - | -LL | f(NonDrop); - | ^^^^^^^^^^ the trait `~const Destruct` is not implemented for `NonDrop` - | - = note: the trait bound `NonDrop: ~const Destruct` is not satisfied -help: consider borrowing here - | -LL | &f(NonDrop); - | + -LL | &mut f(NonDrop); - | ++++ - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. |
