rust/src/librustdoc
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
..
clean Auto merge of #30587 - oli-obk:eager_const_eval2, r=nikomatsakis 2016-03-14 11:38:23 -07:00
html rustbuild: Fix stage1 rustdoc 2016-03-08 13:44:14 -08:00
build.rs bootstrap: Add directives to not double-link libs 2016-02-11 11:12:32 -08:00
Cargo.toml bootstrap: Add a bunch of Cargo.toml files 2016-02-11 11:12:32 -08:00
core.rs Auto merge of #32133 - alexcrichton:linkchecker, r=brson 2016-03-11 04:38:04 -08:00
doctree.rs Abstract away differences between Vec and ptr::P in HIR 2015-12-18 00:52:56 +03:00
externalfiles.rs Add generic conversion traits 2015-03-23 15:01:45 -07:00
flock.rs Rename sunos to solaris 2016-01-31 19:01:30 +03:00
fold.rs This doesn't seem necessary? 2016-03-04 19:40:01 +01:00
lib.rs std: Clean out deprecated APIs 2016-03-12 12:31:13 -08:00
markdown.rs Use --cfg when running doctests 2015-12-15 18:03:55 +09:00
passes.rs Auto merge of #32055 - mitaa:rdoc-strip-priv-imports, r=alexcrichton 2016-03-06 17:08:36 +00:00
plugins.rs std: Clean out deprecated APIs 2016-03-12 12:31:13 -08:00
test.rs std: Clean out deprecated APIs 2016-03-12 12:31:13 -08:00
visit_ast.rs Consider doc(hidden) for crate-local inlining 2016-03-10 03:29:46 +01:00