rust/mk
bors 01118928fc Auto merge of #30587 - oli-obk:eager_const_eval2, r=nikomatsakis
typestrong const integers

~~It would be great if someone could run crater on this PR, as this has a high danger of breaking valid code~~ Crater ran. Good to go.

----

So this PR does a few things:

1. ~~const eval array values when const evaluating an array expression~~
2. ~~const eval repeat value when const evaluating a repeat expression~~
3. ~~const eval all struct and tuple fields when evaluating a struct/tuple expression~~
4. remove the `ConstVal::Int` and `ConstVal::Uint` variants and replace them with a single enum (`ConstInt`) which has variants for all integral types
  * `usize`/`isize` are also enums with variants for 32 and 64 bit. At creation and various usage steps there are assertions in place checking if the target bitwidth matches with the chosen enum variant
5. enum discriminants (`ty::Disr`) are now `ConstInt`
6. trans has its own `Disr` type now (newtype around `u64`)

This obviously can't be done without breaking changes (the ones that are noticable in stable)
We could probably write lints that find those situations and error on it for a cycle or two. But then again, those situations are rare and really bugs imo anyway:

```rust
let v10 = 10 as i8;
let v4 = 4 as isize;
assert_eq!(v10 << v4 as usize, 160 as i8);
 ```

stops compiling because 160 is not a valid i8

```rust
struct S<T, S> {
    a: T,
    b: u8,
    c: S
}
let s = S { a: 0xff_ff_ff_ffu32, b: 1, c: 0xaa_aa_aa_aa as i32 };
```

stops compiling because `0xaa_aa_aa_aa` is not a valid i32

----

cc @eddyb @pnkfelix

related: https://github.com/rust-lang/rfcs/issues/1071
2016-03-14 11:38:23 -07:00
..
cfg Auto merge of #32034 - alexcrichton:old-x86-msvc, r=aturon 2016-03-10 22:47:49 -08:00
clean.mk Added missing argument to 'find' 2015-10-27 23:47:53 +13:00
crates.mk Auto merge of #30587 - oli-obk:eager_const_eval2, r=nikomatsakis 2016-03-14 11:38:23 -07:00
ctags.mk Update the ctags rules and targets. 2015-07-30 06:35:42 +10:00
debuggers.mk debuginfo: Create common debugger pretty printer module. 2015-05-30 20:06:08 +02:00
dist.mk mk: Fix make dist 2016-03-12 12:22:40 -08:00
docs.mk mk: Move disable-jemalloc logic into makefiles 2016-02-25 21:05:59 -08:00
grammar.mk Revert "mk: fix some undefined variable warnings" 2016-02-01 23:27:04 -08:00
host.mk mk: Move disable-jemalloc logic into makefiles 2016-02-25 21:05:59 -08:00
install.mk mk: Move disable-jemalloc logic into makefiles 2016-02-25 21:05:59 -08:00
llvm.mk rustc_llvm: Tweak how initialization is performed 2016-02-11 11:12:33 -08:00
main.mk Bump to 1.9 2016-03-01 18:34:26 +00:00
platform.mk mk: Move disable-jemalloc logic into makefiles 2016-02-25 21:05:59 -08:00
prepare.mk mk: Move disable-jemalloc logic into makefiles 2016-02-25 21:05:59 -08:00
reconfig.mk mk: Fix reconfiguring top-level ./configure 2015-06-17 17:32:11 -07:00
rt.mk More reliable and consistent method of cancelling -Werror* 2016-03-05 14:45:25 +01:00
rustllvm.mk trans: Use LLVM's writeArchive to modify archives 2015-07-10 09:06:21 -07:00
snap.mk Remove extra eval call in snap.mk 2015-11-13 15:15:51 -05:00
stage0.mk mk/stage0: complain instead of creating an empty file 2014-11-20 16:00:12 -05:00
target.mk mk: Move disable-jemalloc logic into makefiles 2016-02-25 21:05:59 -08:00
tests.mk mk: Distribute fewer TARGET_CRATES 2016-03-07 13:05:12 -08:00
util.mk mk: Build crates with relative paths to rustc 2015-06-13 01:41:52 +02:00