Skip to content

Commit 49ac725

Browse files
committed
fix precise live drops
1 parent 122e91e commit 49ac725

File tree

5 files changed

+38
-7
lines changed

5 files changed

+38
-7
lines changed

Diff for: compiler/rustc_const_eval/src/transform/check_consts/post_drop_elaboration.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ impl Visitor<'tcx> for CheckLiveDrops<'mir, 'tcx> {
7979
mir::TerminatorKind::Drop { place: dropped_place, .. } => {
8080
let dropped_ty = dropped_place.ty(self.body, self.tcx).ty;
8181
if !NeedsNonConstDrop::in_any_value_of_ty(self.ccx, dropped_ty) {
82-
bug!(
83-
"Drop elaboration left behind a Drop for a type that does not need dropping"
84-
);
82+
// Instead of throwing a bug, we just return here. This is because we have to
83+
// run custom `const Drop` impls.
84+
return;
8585
}
8686

8787
if dropped_place.is_indirect() {

Diff for: src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.stderr renamed to src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
error[E0277]: the trait bound `NonTrivialDrop: Drop` is not satisfied
2-
--> $DIR/const-drop-fail.rs:28:5
2+
--> $DIR/const-drop-fail.rs:30:5
33
|
44
LL | NonTrivialDrop,
55
| ^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `NonTrivialDrop`
66
|
77
note: required by a bound in `check`
8-
--> $DIR/const-drop-fail.rs:19:19
8+
--> $DIR/const-drop-fail.rs:21:19
99
|
1010
LL | const fn check<T: ~const Drop>(_: T) {}
1111
| ^^^^^^^^^^^ required by this bound in `check`
1212

1313
error[E0277]: the trait bound `ConstImplWithDropGlue: Drop` is not satisfied
14-
--> $DIR/const-drop-fail.rs:30:5
14+
--> $DIR/const-drop-fail.rs:32:5
1515
|
1616
LL | ConstImplWithDropGlue(NonTrivialDrop),
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `ConstImplWithDropGlue`
1818
|
1919
note: required by a bound in `check`
20-
--> $DIR/const-drop-fail.rs:19:19
20+
--> $DIR/const-drop-fail.rs:21:19
2121
|
2222
LL | const fn check<T: ~const Drop>(_: T) {}
2323
| ^^^^^^^^^^^ required by this bound in `check`

Diff for: src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
// revisions: stock precise
12
#![feature(const_trait_impl)]
23
#![feature(const_mut_refs)]
34
#![feature(const_fn_trait_bound)]
5+
#![cfg_attr(precise, feature(const_precise_live_drops))]
46

57
struct NonTrivialDrop;
68

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
error[E0277]: the trait bound `NonTrivialDrop: Drop` is not satisfied
2+
--> $DIR/const-drop-fail.rs:30:5
3+
|
4+
LL | NonTrivialDrop,
5+
| ^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `NonTrivialDrop`
6+
|
7+
note: required by a bound in `check`
8+
--> $DIR/const-drop-fail.rs:21:19
9+
|
10+
LL | const fn check<T: ~const Drop>(_: T) {}
11+
| ^^^^^^^^^^^ required by this bound in `check`
12+
13+
error[E0277]: the trait bound `ConstImplWithDropGlue: Drop` is not satisfied
14+
--> $DIR/const-drop-fail.rs:32:5
15+
|
16+
LL | ConstImplWithDropGlue(NonTrivialDrop),
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `ConstImplWithDropGlue`
18+
|
19+
note: required by a bound in `check`
20+
--> $DIR/const-drop-fail.rs:21:19
21+
|
22+
LL | const fn check<T: ~const Drop>(_: T) {}
23+
| ^^^^^^^^^^^ required by this bound in `check`
24+
25+
error: aborting due to 2 previous errors
26+
27+
For more information about this error, try `rustc --explain E0277`.

Diff for: src/test/ui/rfc-2632-const-trait-impl/const-drop.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// run-pass
2+
// revisions: stock precise
23
#![feature(const_trait_impl)]
34
#![feature(const_fn_trait_bound)]
45
#![feature(const_mut_refs)]
56
#![feature(const_panic)]
7+
#![cfg_attr(precise, feature(const_precise_live_drops))]
68

79
struct S<'a>(&'a mut u8);
810

0 commit comments

Comments
 (0)