fix precise live drops
This commit is contained in:
parent
122e91e330
commit
49ac725d51
5 changed files with 38 additions and 7 deletions
|
@ -79,9 +79,9 @@ impl Visitor<'tcx> for CheckLiveDrops<'mir, 'tcx> {
|
||||||
mir::TerminatorKind::Drop { place: dropped_place, .. } => {
|
mir::TerminatorKind::Drop { place: dropped_place, .. } => {
|
||||||
let dropped_ty = dropped_place.ty(self.body, self.tcx).ty;
|
let dropped_ty = dropped_place.ty(self.body, self.tcx).ty;
|
||||||
if !NeedsNonConstDrop::in_any_value_of_ty(self.ccx, dropped_ty) {
|
if !NeedsNonConstDrop::in_any_value_of_ty(self.ccx, dropped_ty) {
|
||||||
bug!(
|
// Instead of throwing a bug, we just return here. This is because we have to
|
||||||
"Drop elaboration left behind a Drop for a type that does not need dropping"
|
// run custom `const Drop` impls.
|
||||||
);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if dropped_place.is_indirect() {
|
if dropped_place.is_indirect() {
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
error[E0277]: the trait bound `NonTrivialDrop: Drop` is not satisfied
|
error[E0277]: the trait bound `NonTrivialDrop: Drop` is not satisfied
|
||||||
--> $DIR/const-drop-fail.rs:28:5
|
--> $DIR/const-drop-fail.rs:30:5
|
||||||
|
|
|
|
||||||
LL | NonTrivialDrop,
|
LL | NonTrivialDrop,
|
||||||
| ^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `NonTrivialDrop`
|
| ^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `NonTrivialDrop`
|
||||||
|
|
|
|
||||||
note: required by a bound in `check`
|
note: required by a bound in `check`
|
||||||
--> $DIR/const-drop-fail.rs:19:19
|
--> $DIR/const-drop-fail.rs:21:19
|
||||||
|
|
|
|
||||||
LL | const fn check<T: ~const Drop>(_: T) {}
|
LL | const fn check<T: ~const Drop>(_: T) {}
|
||||||
| ^^^^^^^^^^^ required by this bound in `check`
|
| ^^^^^^^^^^^ required by this bound in `check`
|
||||||
|
|
||||||
error[E0277]: the trait bound `ConstImplWithDropGlue: Drop` is not satisfied
|
error[E0277]: the trait bound `ConstImplWithDropGlue: Drop` is not satisfied
|
||||||
--> $DIR/const-drop-fail.rs:30:5
|
--> $DIR/const-drop-fail.rs:32:5
|
||||||
|
|
|
|
||||||
LL | ConstImplWithDropGlue(NonTrivialDrop),
|
LL | ConstImplWithDropGlue(NonTrivialDrop),
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `ConstImplWithDropGlue`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `ConstImplWithDropGlue`
|
||||||
|
|
|
|
||||||
note: required by a bound in `check`
|
note: required by a bound in `check`
|
||||||
--> $DIR/const-drop-fail.rs:19:19
|
--> $DIR/const-drop-fail.rs:21:19
|
||||||
|
|
|
|
||||||
LL | const fn check<T: ~const Drop>(_: T) {}
|
LL | const fn check<T: ~const Drop>(_: T) {}
|
||||||
| ^^^^^^^^^^^ required by this bound in `check`
|
| ^^^^^^^^^^^ required by this bound in `check`
|
|
@ -1,6 +1,8 @@
|
||||||
|
// revisions: stock precise
|
||||||
#![feature(const_trait_impl)]
|
#![feature(const_trait_impl)]
|
||||||
#![feature(const_mut_refs)]
|
#![feature(const_mut_refs)]
|
||||||
#![feature(const_fn_trait_bound)]
|
#![feature(const_fn_trait_bound)]
|
||||||
|
#![cfg_attr(precise, feature(const_precise_live_drops))]
|
||||||
|
|
||||||
struct NonTrivialDrop;
|
struct NonTrivialDrop;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
error[E0277]: the trait bound `NonTrivialDrop: Drop` is not satisfied
|
||||||
|
--> $DIR/const-drop-fail.rs:30:5
|
||||||
|
|
|
||||||
|
LL | NonTrivialDrop,
|
||||||
|
| ^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `NonTrivialDrop`
|
||||||
|
|
|
||||||
|
note: required by a bound in `check`
|
||||||
|
--> $DIR/const-drop-fail.rs:21:19
|
||||||
|
|
|
||||||
|
LL | const fn check<T: ~const Drop>(_: T) {}
|
||||||
|
| ^^^^^^^^^^^ required by this bound in `check`
|
||||||
|
|
||||||
|
error[E0277]: the trait bound `ConstImplWithDropGlue: Drop` is not satisfied
|
||||||
|
--> $DIR/const-drop-fail.rs:32:5
|
||||||
|
|
|
||||||
|
LL | ConstImplWithDropGlue(NonTrivialDrop),
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `ConstImplWithDropGlue`
|
||||||
|
|
|
||||||
|
note: required by a bound in `check`
|
||||||
|
--> $DIR/const-drop-fail.rs:21:19
|
||||||
|
|
|
||||||
|
LL | const fn check<T: ~const Drop>(_: T) {}
|
||||||
|
| ^^^^^^^^^^^ required by this bound in `check`
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0277`.
|
|
@ -1,8 +1,10 @@
|
||||||
// run-pass
|
// run-pass
|
||||||
|
// revisions: stock precise
|
||||||
#![feature(const_trait_impl)]
|
#![feature(const_trait_impl)]
|
||||||
#![feature(const_fn_trait_bound)]
|
#![feature(const_fn_trait_bound)]
|
||||||
#![feature(const_mut_refs)]
|
#![feature(const_mut_refs)]
|
||||||
#![feature(const_panic)]
|
#![feature(const_panic)]
|
||||||
|
#![cfg_attr(precise, feature(const_precise_live_drops))]
|
||||||
|
|
||||||
struct S<'a>(&'a mut u8);
|
struct S<'a>(&'a mut u8);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue