rust/src/librustc_passes
bors 5313e8728f Auto merge of #47408 - eddyb:deref-danger, r=nikomatsakis
Don't promote to 'static the result of dereferences.

This is a **breaking change**, removing copies out of dereferences from rvalue-to-`'static` promotion.

With miri we won't easily know whether the dereference itself would see the same value at runtime as miri (e.g. after mutating a `static`) or even if it can be interpreted (e.g. integer pointers).
One alternative to this ban is defining at least *some* of those situations as UB, i.e. you shouldn't have a reference in the first place, and you should work through raw pointers instead, to avoid promotion.

**EDIT**: The other *may seem* to be to add some analysis which whitelists references-to-constant-values and assume any values produced by arbitrary computation to not be safe to promote dereferences thereof - but that means producing a reference from an associated constant or `const fn` would necessarily obscure it, and in the former case, this could still impact code that runs on stable today. What we do today to track "references to statics" only works because we restrict taking a reference to a `static` at all to other `static`s (which, again, are currently limited in that they can't be read at compile-time) and to runtime-only `fn`s (*not* `const fn`s).

I'm primarily opening this PR with a conservative first approximation (e.g. `&(*r).a` is not allowed, only reborrows are, and in the old borrow only implicit ones from adjustments, at that) for cratering.

r? @nikomatsakis
2018-02-17 19:32:25 +00:00
..
ast_validation.rs AST/HIR: Add a separate structure for labels 2018-01-22 23:13:12 +03:00
Cargo.toml Try to fix a perf regression by updating log 2018-01-07 16:54:05 +01:00
consts.rs Auto merge of #47408 - eddyb:deref-danger, r=nikomatsakis 2018-02-17 19:32:25 +00:00
diagnostics.rs syntax: Rewrite parsing of impls 2018-01-14 18:10:05 +03:00
hir_stats.rs Add GenericParam, refactor Generics in ast, hir, rustdoc 2017-12-21 13:38:10 +01:00
lib.rs Move "no asm" check into AST validation 2018-01-13 23:35:11 +03:00
loops.rs Suggest removing value from break when invalid 2018-01-28 11:14:09 -08:00
mir_stats.rs mir: Add TerminatorKind::FalseUnwind 2018-02-05 15:00:40 -05:00
static_recursion.rs