Uh oh!
There was an error while loading. Please reload this page.
Forward-compatibly deny drops in constants if they *could* actually run. - #43932
Conversation
| // Deny *any* live drops anywhere other than functions. | ||
| if self.mode != Mode::Fn { | ||
| // HACK(eddyb) Emulate a bit of dataflow analysis, |
There was a problem hiding this comment.
This is not really "drop elaboration" dataflow - drop elaboration does not know that None has no destructor - but rather "const qual" dataflow.
There was a problem hiding this comment.
Right, it's a combination of the two.
eddyb
commented
Aug 17, 2017
@bors try (for cargobomb) |
bors
commented
Aug 17, 2017
Forward-compatibly deny drops in constants if they *could* actually run. This is part of #40036, specifically the checks for user-defined destructor invocations on locals which *may not* have been moved away, the motivating example being: ```rust const FOO: i32 = (HasDrop {...}, 0).1; ``` The evaluation of constant MIR will continue to create `'static` slots for more locals than is necessary (if `Storage{Live,Dead}` statements are ignored), but it shouldn't be misusable. r? @nikomatsakis
bors
commented
Aug 17, 2017
☀️ Test successful - status-travis |
eddyb
commented
Aug 17, 2017
cc @rust-lang/infra Cargobomb run requested. |
aidanhs
commented
Aug 18, 2017
Cargobomb run started |
nikomatsakis
commented
Aug 21, 2017
Any news from cargobomb run? |
aidanhs
commented
Aug 22, 2017
~27 hours remaining. I was away for the weekend so didn't manage to kick off a phase of the run until yesterday. |
aidanhs
commented
Aug 23, 2017
eddyb
commented
Aug 24, 2017
Great, only regression is Rocket (which I've seen on crater before). However, I've changed by mind about it - it only uses associated |
alexcrichton
commented
Aug 24, 2017
Switching to S-waiting-on-review as looks like cargobomb's been run, cc @nikomatsakis |
eddyb
commented
Aug 24, 2017
Also waiting on me to treat inherent associated |
52667d8 to
8697b80Compareeddyb
commented
Aug 27, 2017
Latest crater report confirms Rocket has been fixed. r? @nikomatsakis |
arielb1
commented
Aug 27, 2017
Could you add a test for the rocket case, so we can make sure it stays fixed? |
| if self.mode != Mode::Fn { | ||
| // HACK(eddyb) Emulate a bit of dataflow analysis, | ||
| // conservatively, that drop elaboration will do. | ||
| let needs_drop = if let Lvalue::Local(local) = *lvalue { |
There was a problem hiding this comment.
I presume that we will reject (for constants) things that mutate "MIR locals" once they are assigned?
There was a problem hiding this comment.
Yeah that is considered an assignment and disallowed as "statement-like".
| fn drop(&mut self) {} | ||
| } | ||
| static FOO: Option<&'static WithDtor> = Some(&WithDtor); |
There was a problem hiding this comment.
maybe add a test with struct WithoutDtor and Some(&WithoutDtor)? Does that behave differently?
There was a problem hiding this comment.
That has worked since 1.0, but if you have something more advanced in mind that would actually stress the new code, I'm up for it.
nikomatsakis
left a comment
There was a problem hiding this comment.
Seems reasonable. I left a few questions.
nikomatsakis
commented
Aug 28, 2017
(To be clear, I want to revisit shortly once I see answers.) |
nikomatsakis
commented
Aug 28, 2017
@eddyb would you mind adding a few more tests, just to have more "exhaustive" coverage of the various cases? otherwise, r=me I think. |
nikomatsakis
commented
Aug 30, 2017
bors
commented
Aug 30, 2017
📌 Commit c76a024 has been approved by |
bors
commented
Aug 30, 2017
Forward-compatibly deny drops in constants if they *could* actually run. This is part of #40036, specifically the checks for user-defined destructor invocations on locals which *may not* have been moved away, the motivating example being: ```rust const FOO: i32 = (HasDrop {...}, 0).1; ``` The evaluation of constant MIR will continue to create `'static` slots for more locals than is necessary (if `Storage{Live,Dead}` statements are ignored), but it shouldn't be misusable. r? @nikomatsakis
bors
commented
Aug 30, 2017
☀️ Test successful - status-appveyor, status-travis |
Better StorageLive / StorageDead placement for constants. Fixes problems in miri (see rust-lang/miri#324 (comment)) caused by the new scope rules in #43932. What I've tried to do here is always have a `StorageLive` but no `StorageDead` for `'static` slots. It might not work perfectly in all cases, but it should unblock miri. r? @nikomatsakis cc @oli-obk
This is part of #40036, specifically the checks for user-defined destructor invocations on locals which may not have been moved away, the motivating example being:
The evaluation of constant MIR will continue to create
'staticslots for more locals than is necessary (ifStorage{Live,Dead}statements are ignored), but it shouldn't be misusable.r? @nikomatsakis