Commit Graph

61753 Commits

Author SHA1 Message Date
Simonas Kazlauskas
6c19104c43 Fix build
Additionally, revert unnecessary changes to ty::layout
2017-02-10 19:47:06 +02:00
Simonas Kazlauskas
eb727a8faa Add TerminatorKind::if_ convenience constructor
Constructs a TerminatorKind::SwitchInt for an equivalent conditional true-false branch.
2017-02-10 19:45:55 +02:00
Simonas Kazlauskas
a8b7b62185 Revert use of layout code in typeck::collect 2017-02-10 19:45:53 +02:00
Simonas Kazlauskas
362eb7ea07 Inspect now does not force on-stack Lvalue 2017-02-10 19:44:00 +02:00
Simonas Kazlauskas
76d9a4e646 Fix codegen test 2017-02-10 19:44:00 +02:00
Simonas Kazlauskas
8e00d28ff4 Prefer switching on false for boolean switches
This ends up not really mattering because we generate a plain conditional branch in LLVM either
way.
2017-02-10 19:44:00 +02:00
Simonas Kazlauskas
4be18488a7 Fix SwitchInt building in ElaborateDrops pass
Previously it used to build a switch in a way that didn’t preserve the invariat of SwitchInt. Now
it builds it in an optimal way too, where otherwise branch becomes all the branches which did not
have partial variant drops.
2017-02-10 19:44:00 +02:00
Simonas Kazlauskas
c9939863ca Fix the IntTypeExt::to_ty() lifetime bounds 2017-02-10 19:43:57 +02:00
Simonas Kazlauskas
64182a587c Reimplement simplify_cfg for SwitchInt
First example of optimisation that applies to many more cases than originally.
2017-02-10 19:42:41 +02:00
Simonas Kazlauskas
92c56f607b Fix build on further stages 2017-02-10 19:42:41 +02:00
Simonas Kazlauskas
a00a0adc79 Only SwitchInt over integers, not all consts
Also use a Cow to avoid full Vec for all SwitchInts
2017-02-10 19:42:41 +02:00
Simonas Kazlauskas
aac82d9b13 SwitchInt over Switch
This removes another special case of Switch by replacing it with the more general SwitchInt. While
this is more clunky currently, there’s no reason we can’t make it nice (and efficient) to use.
2017-02-10 19:42:41 +02:00
Simonas Kazlauskas
5d70a7fbe4 AdtDef now contains discr_ty same as layouted 2017-02-10 19:42:39 +02:00
Simonas Kazlauskas
24c93efbb5 Move type of discriminant to AdtDef
Previously AdtDef variants contained ConstInt for each discriminant, which did not really reflect
the actual type of the discriminants. Moving the type into AdtDef allows to easily put the type
into metadata and also saves bytes from ConstVal overhead for each discriminant.

Also arguably the code is cleaner now :)
2017-02-10 19:38:36 +02:00
Ingvar Stepanyan
f35b598bbf Disable memory init file until further notice
It's support is currently too buggy in both Rust tests and Cargo.
2017-02-10 17:34:05 +00:00
Simonas Kazlauskas
98d1db7fe3 If is now always a SwitchInt in MIR 2017-02-10 19:31:37 +02:00
Simonas Kazlauskas
779c6b6cb8 Add Rvalue::Discriminant to retrieve discriminant 2017-02-10 19:31:37 +02:00
Ingvar Stepanyan
84c2a67160 Reenable exception catching in Emscripten even on optimized targets 2017-02-10 17:31:04 +00:00
Ingvar Stepanyan
eed6168a3b Add Emscripten-specific linker
It claims to accept most GNU linker options, but in fact most of them
have no effect and instead it requires some special options which are
easier to handle in a separate trait.

Currently added:
 - `export_symbols`: works on executables as special Emscripten case
since staticlibs/dylibs aren't compiled to JS, while exports are
required to be accessible from JS.
Fixes #39171.
 - `optimize` - translates Rust's optimization level to Emscripten
optimization level (whether passed via `-C opt-level=...` or `-O...`).
Fixes #36899.
 - `debuginfo` - translates debug info; Emscripten has 5 debug levels
while Rust has 3, so chose to translate `-C debuginfo=1` to `-g3`
(preserves whitespace, variable and function names for easy debugging).
Fixes #36901.
 - `no_default_libraries` - tells Emscripten to exlude `memcpy` and co.
2017-02-10 17:31:04 +00:00
bors
bc524d3d55 Auto merge of #39708 - jethrogb:patch-4, r=frewsxcv
Update set operations documentation

Reminding people of set terminology.
2017-02-10 14:26:18 +00:00
Rob Speer
11d36aec83 iterator docs: Move paragraph about discarding; clarify "consumed" 2017-02-10 01:35:29 -05:00
Rob Speer
ebf29ef073 Rephrase my proposed edit ("objects" -> "elements") 2017-02-10 01:31:14 -05:00
Rob Speer
5cc5e0851e Fix a misleading statement in Iterator.nth()
The `Iterator.nth()` documentation says "Note that all preceding elements will be consumed". I assumed from that that the preceding elements would be the *only* ones that were consumed, but in fact the returned element is consumed as well.

The way I read the documentation, I assumed that `nth(0)` would not discard anything (as there are 0 preceding elements), so I added a sentence clarifying that it does. I also rephrased it to avoid the stunted "i.e." phrasing.
2017-02-10 01:31:14 -05:00
Brian Vincent
fb9104768c Dont segfault if btree range is not in order 2017-02-10 00:16:04 -06:00
bors
f80514426a Auto merge of #39712 - frewsxcv:rollup, r=frewsxcv
Rollup of 6 pull requests

- Successful merges: #39587, #39674, #39693, #39700, #39705, #39707
- Failed merges:
2017-02-10 04:50:08 +00:00
Vadim Chugunov
28896758eb Code cleanup. 2017-02-09 18:35:19 -08:00
Corey Farwell
84ad515793 Rollup merge of #39707 - durka:parsimonious-span-note, r=jonathandturner
change span_notes to notes in E0368/E0369

Fixes #39650.

All the uses of `span_note` in these errors were reusing the same span as the original error, which causes unnecessary repetition.

For an example, see the changes to [src/test/ui/span/issue-39018.stderr](https://github.com/rust-lang/rust/pull/39707/files?diff=unified#diff-46336f62958fdb34233db414cb9914a1R4).

r? @jonathandturner
2017-02-09 19:43:26 -05:00
Corey Farwell
3199b2478a Rollup merge of #39705 - tspiteri:name-trait-fn-params, r=aturon
name anonymous fn parameters in libcore traits

This follows the discussion in rust-lang/rfcs#1685. The patch gives names to anonymous parameters in libcore traits. It would have two benefits I can think of: firstly it would provide names to tools that can use the names from the traits, and secondly core/std can serve as an example when writing traits; this change helps by not encouraging the use of anonymous parameters.
2017-02-09 19:43:25 -05:00
Corey Farwell
af1ddb9ec5 Rollup merge of #39700 - msopena:master, r=est31
Adding compile fail test for const_indexing feature

First attempt at contributing to rust. Picked up an easy feature to test.

Issue #39059
r? @est31
2017-02-09 19:43:24 -05:00
Corey Farwell
ae5d8fc929 Rollup merge of #39693 - durka:patch-36, r=petrochenkov
driver: restore partially deleted comment

Fixes #39689. Comment was lost in commit 811b8747 (#31916 @nagisa).
2017-02-09 19:43:23 -05:00
Corey Farwell
ed7f3c4635 Rollup merge of #39674 - jseyfried:fix_token_tree_parsing_ICE, r=nrc
parser: fix ICE when parsing token trees after an error

Fixes #39388, fixes #39616.
r? @nrc
2017-02-09 19:43:21 -05:00
Corey Farwell
41653fd26a Rollup merge of #39587 - Keruspe:master, r=alexcrichton
rustbuild: support setting verbosity in config.toml

Most if not all the configuration is settable trhough config.toml but the verbosity isn't yet.

This avoids having to pass -v to x.py on each command if you want verbosity to be always on.
2017-02-09 19:43:20 -05:00
Brian Anderson
e491f39914 Update 1.15.1 relnotes 2017-02-10 00:30:02 +00:00
Alex Burka
9fffd14171 change span_notes to notes in E0368/E0369 2017-02-09 22:45:42 +00:00
Jethro Beekman
ba82a76db9 Update set operations documentation
Reminding people of set terminology.
2017-02-09 14:16:16 -08:00
bors
24a70eb598 Auto merge of #39694 - frewsxcv:rollup, r=frewsxcv
Rollup of 6 pull requests

- Successful merges: #39604, #39619, #39670, #39678, #39682, #39683
- Failed merges:
2017-02-09 21:58:10 +00:00
Trevor Spiteri
e626a6807c name anonymous fn parameters in libcore traits 2017-02-09 22:31:21 +01:00
Sean Griffin
b3937ea862 Explicitly mention that Vec::reserve is based on len not capacity
I spent a good chunk of time tracking down a buffer overrun bug that
resulted from me mistakenly thinking that `reserve` was based on the
current capacity not the current length. It would be helpful if this
were called out explicitly in the docs.
2017-02-09 13:58:48 -05:00
Mario
ec4a3cc371 Adding compile fail test for const_indexing feature 2017-02-09 19:39:46 +01:00
Michael Howell
bc4ad1a2c9 Add the short type to inline links, too 2017-02-09 11:02:01 -07:00
Michael Howell
fce944d4e7 Add the item type to the tooltip
See:
https://users.rust-lang.org/t/seeking-opinions-from-colorblind-rustaceans-coloring-in-rustdoc-code-blocks
2017-02-09 10:38:29 -07:00
Corey Farwell
55c17a5994 Rollup merge of #39683 - solson:fix-unaligned-load-librustc_metadata, r=bluss
Fix unaligned load in librustc_metadata::index.

The derived `Clone` impl contains UB and will be unsafe when we fix https://github.com/rust-lang/rust/issues/27060. See [this comment](https://github.com/rust-lang/rust/issues/27060#issuecomment-278617096) for more context.

r? @bluss
2017-02-09 12:14:24 -05:00
Corey Farwell
7e2b2f30cd Rollup merge of #39682 - solson:fix-unaligned-read, r=eddyb
Fix unsafe unaligned loads in test.

r? @eddyb
cc @Aatch @nikomatsakis

The `#[derive(PartialEq, Debug)]` impls on a packed struct contain undefined behaviour. Both generated impls take references to unaligned fields, which will fail to compile once we correctly treat that as unsafe (see https://github.com/rust-lang/rust/issues/27060).

This UB was found by running the test under [Miri](https://github.com/solson/miri/) which rejects these unsafe unaligned loads. 😄

Here's a simpler example:

```rust
struct Packed {
    a: u8,
    b: u64,
}
```

It expands to:

```rust
    fn fmt(&self, __arg_0: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        match *self {
            Packed { a: ref __self_0_0, b: ref __self_0_1 } => { // BAD: these patterns are unsafe
                let mut builder = __arg_0.debug_struct("Packed");
                let _ = builder.field("a", &&(*__self_0_0));
                let _ = builder.field("b", &&(*__self_0_1));
                builder.finish()
            }
        }
    }
```

and

```rust
    fn eq(&self, __arg_0: &Packed) -> bool {
        match *__arg_0 {
            Packed { a: ref __self_1_0, b: ref __self_1_1 } => // BAD: these patterns are unsafe
            match *self {
                Packed { a: ref __self_0_0, b: ref __self_0_1 } => // BAD: these patterns are unsafe
                true && (*__self_0_0) == (*__self_1_0) &&
                    (*__self_0_1) == (*__self_1_1),
            },
        }
    }
```
2017-02-09 12:14:23 -05:00
Corey Farwell
7bd0da7e89 Rollup merge of #39678 - vadimcn:top-level-expn, r=michaelwoerister
Exclude top-level macro expansions from source location override.

It occurred to me that a simple heuristic can address the issue #36382: any macros that expand into items (including `include!()`) don't need to be stepped over because there's not code to step through above a function scope level.

r? @michaelwoerister
2017-02-09 12:14:22 -05:00
Corey Farwell
711b95f6b1 Rollup merge of #39670 - JanZerebecki:fix-mailmap-gifnksm, r=steveklabnik
Fix mailmap for @gifnksm

cc rust-lang-nursery/thanks#71
2017-02-09 12:14:21 -05:00
Corey Farwell
3eaca413fe Rollup merge of #39619 - michaelwoerister:rename-crate-metadata, r=alexcrichton
Choose different name for metadata obj-file to avoid clashes with user-chosen names.

Fixes #39585 and probably https://github.com/rust-lang/rust/issues/39508.
Incremental compilation assigns different names to obj-files than regular compilation. If a crate is called "metadata" this can lead to a clash between the root module's obj-file and the obj-file containing crate-metadata. This PR assigns a name to the metadata obj-file that cannot clash with other obj-file because it contains a `.` which is not allowed in a Rust module identifier.

r? @alexcrichton

cc @nikomatsakis
2017-02-09 12:14:19 -05:00
Corey Farwell
a05cc5ca9d Rollup merge of #39604 - est31:i128_tests, r=alexcrichton
Unignore u128 test for stage 0,1

Even more SNAP cleanup.

Follow-up of #39519.

Sorry, I didn't check twice.
2017-02-09 12:14:18 -05:00
bors
4053276354 Auto merge of #38109 - tromey:main-subprogram, r=michaelwoerister
Emit DW_AT_main_subprogram

This changes rustc to emit DW_AT_main_subprogram on the "main" program.
This lets gdb suitably stop at the user's main in response to
"start" (rather than the library's main, which is what happens
currently).

Fixes #32620
r? michaelwoerister
2017-02-09 17:09:50 +00:00
Alex Burka
ca9c7ae61b driver: restore partially deleted comment 2017-02-09 12:07:58 -05:00
Oliver Schneider
c7f9811aba removed unused struct 2017-02-09 17:58:26 +01:00