rust/compiler/rustc_middle/src
bors e2be5f568d 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`
2020-09-09 20:04:04 +00:00
..
dep_graph mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
hir mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
ich mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
infer mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
middle pretty: trim paths of unique symbols 2020-09-02 22:26:37 +03:00
mir review 2020-09-08 16:39:12 +02:00
query pretty: trim paths of unique symbols 2020-09-02 22:26:37 +03:00
traits Rollup merge of #76340 - jonas-schievink:rm-dupe, r=Mark-Simulacrum 2020-09-07 01:18:10 +02:00
ty Fix documentation for TyCtxt::all_impls 2020-09-06 12:10:46 +02:00
util mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
arena.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
lib.rs datastructures: replace once_cell crate with an impl from std 2020-08-30 20:06:14 +01:00
lint.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
macros.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
tests.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00