diff options
author | John Hodge <tpg@ucc.asn.au> | 2017-11-21 20:46:13 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2017-11-21 20:46:13 +0800 |
commit | 98949d800e41cba0b5f93f94ce26aea311ede990 (patch) | |
tree | a497cc7365454b9318eb731c1ad1aee1bf768d68 | |
parent | c131c30e6db48c1edc77b123ce6771e3c5608242 (diff) | |
download | mrust-98949d800e41cba0b5f93f94ce26aea311ede990.tar.gz |
MIR Validate Full - Alter handling of Box
-rw-r--r-- | src/mir/check_full.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/mir/check_full.cpp b/src/mir/check_full.cpp index 15fe8b33..2762c4e7 100644 --- a/src/mir/check_full.cpp +++ b/src/mir/check_full.cpp @@ -909,7 +909,8 @@ void MIR_Validate_FullValState(::MIR::TypeResolve& mir_res, const ::MIR::Functio // Box<T> - Wrapper around Unique<T> MIR_ASSERT(mir_res, vs.is_composite(), "Shallow drop on non-composite state - " << se.slot << " (state=" << StateFmt(state,vs) << ")"); const auto& sub_states = state.get_composite(mir_res, vs); - MIR_ASSERT(mir_res, sub_states.size() == 1, ""); +#if 0 + MIR_ASSERT(mir_res, sub_states.size() == 1, "Shallow drop of slot with incorrect state shape (state=" << StateFmt(state,vs) << ")"); // Unique<T> - NonZero<*const T>, PhantomData<T> MIR_ASSERT(mir_res, sub_states[0].is_composite(), ""); const auto& sub_states2 = state.get_composite(mir_res, sub_states[0]); @@ -929,6 +930,15 @@ void MIR_Validate_FullValState(::MIR::TypeResolve& mir_res, const ::MIR::Functio { MIR_ASSERT(mir_res, !sub_states4[1].is_valid(), "Shallow drop on populated Box - " << se.slot << " (state=" << StateFmt(state,vs) << ")"); } +#else + MIR_ASSERT(mir_res, sub_states.size() == 2, "Shallow drop of slot with incorrect state shape (state=" << StateFmt(state,vs) << ")"); + MIR_ASSERT(mir_res, sub_states[0].is_valid(), "Shallow drop on deallocated Box - " << se.slot << " (state=" << StateFmt(state,vs) << ")"); + // TODO: This is leak protection, enable it once the rest works + if( ENABLE_LEAK_DETECTOR ) + { + MIR_ASSERT(mir_res, !sub_states[1].is_valid(), "Shallow drop on populated Box - " << se.slot << " (state=" << StateFmt(state,vs) << ")"); + } +#endif state.set_lvalue_state(mir_res, se.slot, State(false)); } |