diff options
| author | bors <bors@rust-lang.org> | 2020-09-09 20:04:04 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-09-09 20:04:04 +0000 |
| commit | e2be5f568d1f60365b825530f5b5cb722460591b (patch) | |
| tree | 0cbb2200538ae294e0849811e4707f4ddeea6b1f /compiler/rustc_codegen_llvm/src | |
| parent | d92155bf6ae0b7d79fc83cbeeb0cc0c765353471 (diff) | |
| parent | 74e07198a08fea62ab2fba9ae258f4d118d7dffe (diff) | |
| download | rust-e2be5f568d1f60365b825530f5b5cb722460591b.tar.gz rust-e2be5f568d1f60365b825530f5b5cb722460591b.zip | |
Auto merge of #74595 - lcnr:ConstEvaluatable-fut-compat, r=oli-obk
make `ConstEvaluatable` more strict
relevant zulip discussion: https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/.60ConstEvaluatable.60.20generic.20functions/near/204125452
Let's see how much this impacts. Depending on how this goes this should probably be a future compat warning.
Short explanation: we currently forbid anonymous constants which depend on generic types, e.g. `[0; std::mem::size_of::<T>]` currently errors.
We previously checked this by evaluating the constant and returned an error if that failed. This however allows things like
```rust
const fn foo<T>() -> usize {
if std::mem::size_of::<*mut T>() < 8 { // size of *mut T does not depend on T
std::mem::size_of::<T>()
} else {
8
}
}
fn test<T>() {
let _ = [0; foo::<T>()];
}
```
which is a backwards compatibility hazard. This also has worrying interactions with mir optimizations (https://github.com/rust-lang/rust/pull/74491#issuecomment-661890421) and intrinsics (#74538).
r? `@oli-obk` `@eddyb`
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions
