Commit Graph

54470 Commits

Author SHA1 Message Date
bors
222e337ac1 Auto merge of #34322 - pnkfelix:fix-rustc-ctags, r=alexcrichton
Fixed the `TAGS.rustc.emacs` and `TAGS.rustc.vi` make targets.

(They were added to `ctags.mk` in PR #33256, but I guess I must have
 only tested running `make TAGS.emacs TAGS.rustc.emacs` and not `make
 TAGS.rustc.emacs` on its own.)
2016-06-17 07:58:33 -07:00
吴冉波
d0a0befb54 Traits where syntax's extra usage example more clearly
r? @steveklabnik
2016-06-17 22:54:06 +08:00
bors
c8eff682fd Auto merge of #33090 - bluss:special-zip-2, r=aturon
Specialize .zip() for efficient slice and slice iteration

The idea is to introduce a private trait TrustedRandomAccess and specialize .zip() for random access iterators into a counted loop.

The implementation in the PR is internal and has no visible effect in the API

Why a counted loop? To have each slice iterator compile to just a pointer, and both pointers are indexed with the same loop counter value in the generated code. When this succeeds, copying loops are readily recognized and replaced with memcpy and addition loops autovectorize well.

The TrustedRandomAccess approach works very well on the surface. Microbenchmarks optimize well, following the ideas above, and that is a dramatic improvement of .zip()'s codegen.

```rust
// old zip before this PR: bad, byte-for-byte loop
// with specialized zip: memcpy
pub fn copy_zip(xs: &[u8], ys: &mut [u8]) {
    for (a, b) in ys.iter_mut().zip(xs) {
        *a = *b;
    }
}

// old zip before this PR: single addition per iteration
// with specialized zip: vectorized
pub fn add_zip(xs: &[f32], ys: &mut [f32]) {
    for (a, b) in ys.iter_mut().zip(xs) { *a += *b; }
}

// old zip before this PR: single addition per iteration
// with specialized zip: vectorized (!!)
pub fn add_zip3(xs: &[f32], ys: &[f32], zs: &mut [f32]) {
    for ((a, b), c) in zs.iter_mut().zip(xs).zip(ys) { *a += *b * *c; }
}
```

Yet in more complex situations, the .zip() loop can still fall back to its old behavior where phantom null checks throw in fake premature end of the loop conditionals. Remember that a NULL inside
Option<(&T, &T)> makes it a `None` value and a premature (in this case)
end of the loop.

So even if we have 1) an explicit `Some` in the code and 2) the types of the pointers are `&T` or `&mut T` which are nonnull, we can still get a phantom null check at that point.

One example that illustrates the difference is `copy_zip` with slice versus Vec arguments. The involved iterator types are exactly the same, but the Vec version doesn't compile down to memcpy. Investigating into this, the function argument metadata emitted to llvm plays the biggest role. As eddyb summarized, we need nonnull for the loop to autovectorize and noalias for it to replace with memcpy.

There was an experiment to use `assume` to add a non-null assumption on each of the two elements in the specialized zip iterator, but this only helped in some of the test cases and regressed others. Instead I think the nonnull/noalias metadata issue is something we need to solve separately anyway.

These have conditionally implemented TrustedRandomAccess

- Enumerate
- Zip

These have not implemented it

- Map is sideeffectful. The forward case would be workable, but the double ended case is complicated.
- Chain, exact length semantics unclear
- Filter, FilterMap, FlatMap and many others don't offer random access and/or exact length
2016-06-17 03:36:32 -07:00
Guillaume Gomez
9ac3d9b63c Fix panic when using debug 2016-06-17 12:33:55 +02:00
Felix S. Klock II
272ce38476 Fixed the TAGS.rustc.emacs and TAGS.rustc.vi make targets.
(They were added to `ctags.mk` in PR #33256, but I guess I must have
 only tested running `make TAGS.emacs TAGS.rustc.emacs` and not `make
 TAGS.rustc.emacs` on its own.)
2016-06-17 12:07:48 +02:00
Erick Tryzelaar
9de2de1d21 Pretty-print attributes on tuple structs and add tests
This adds support to the pretty printer to print attributes
added to tuple struct elements.  Furthermore, it adds a test
that makes sure we will print attributes on all variant data
types.
2016-06-17 10:05:19 +01:00
Jeffrey Seyfried
f0b21c2d1e Rename ast::ExprKind::Again -> ast::ExprKind::Continue 2016-06-17 05:21:25 +00:00
Jeffrey Seyfried
962d5c16b5 Fix fallout 2016-06-17 05:21:23 +00:00
Jeffrey Seyfried
b5dbe01a2c Refactor away ast::Decl and refactor ast::Stmt 2016-06-17 05:04:40 +00:00
bors
be203ac258 Auto merge of #34306 - arielb1:mir-dump-fixes, r=eddyb
Fixes for `-Z dump-mir`

Do not overwrite the parent MIR when dumping promoted MIR.

r? @eddyb
2016-06-16 21:57:06 -07:00
bors
114be1e9f0 Auto merge of #34315 - Manishearth:rollup, r=Manishearth
Rollup of 4 pull requests

- Successful merges: #34298, #34302, #34307, #34312
- Failed merges:
2016-06-16 19:07:41 -07:00
Manish Goregaokar
019c594c6a Rollup merge of #34312 - erickt:add-try, r=nikomatsakis
Revert using ? for try! in the libsyntax pretty printer

The use of ...?instead of try!(...) in libsyntax makes extracting libsyntax into syntex quite painful since it's not stable yet. This makes backports take a much longer time and causes a lot of problems for the syntex dependencies. Even if it was, it'd take a few release cycles until syntex would be able to use it. Since it's not stable and that this feature is just syntax sugar, it would be most helpful if we could remove it.

cc #34311
2016-06-17 00:12:04 +01:00
Manish Goregaokar
5bac0c3985 Rollup merge of #34307 - nagisa:more-cache, r=arielb1
[MIR] Cache drops for early scope exits

Previously we would rebuild all drops on every early exit from a scope, which for code like:

```rust
match x {
    A => return 1,
    B => return 2,
    ...
    C => return 27
}
```

would produce 27 exactly same chains of drops for each return, basically a `O(n*m)` explosion. [This](https://cloud.githubusercontent.com/assets/679122/16125192/3355e32c-33fb-11e6-8564-c37cab2477a0.png) is such a case for a match on 80-variant enum with 3 droppable variables in scope.

For [`::core::iter::Iterator::partial_cmp`](6edea2cfda/src/libcore/iter/iterator.rs (L1909)) the CFG looked like [this](https://cloud.githubusercontent.com/assets/679122/16122708/ce0024d8-33f0-11e6-93c2-e1c44b910db2.png) (after initial SimplifyCfg). With this patch the CFG looks like [this](https://cloud.githubusercontent.com/assets/679122/16122806/294fb16e-33f1-11e6-95f6-16c5438231af.png) instead.

Some numbers (overall very small wins, however neither of the crates have many cases which abuse this corner case):

|                         | old time | old rss | new time | new rss  |
|-------------------------|----------|---------|----------|----------|
| core dump               | 0.879        |   224MB     |   0.871  |  223MB   |
| core MIR passes         | 0.759        | 224MB       | 0.718    | 223MB    |
| core MIR codegen passes | 1.762        | 230MB       | 1.442    | 228MB    |
| core trans              | 3.263        | 279MB       | 3.116    | 278MB    |
| core llvm passes        | 5.611        | 263MB       | 5.565    | 263MB    |
| std dump                | 0.487        |   190MB     |   0.475  |  192MB   |
| std MIR passes          | 0.311       | 190MB       | 0.288    | 192MB    |
| std MIR codegen passes  | 0.753        | 195MB       | 0.720    | 197MB    |
| std trans               | 2.589        | 287MB       | 2.523    | 287MB    |
| std llvm passes         | 7.268        | 245MB       | 7.447    | 246MB    |
2016-06-17 00:12:04 +01:00
Manish Goregaokar
51b20bcbf4 Rollup merge of #34302 - retep998:🐇-sanity-is-overrated-🐇, r=alexcrichton
Fix issue where rustbuild expected msvc to have ar

I made `cc2ar` return an `Option`.

r? @alexcrichton
2016-06-17 00:12:04 +01:00
Manish Goregaokar
986bb53a7b Rollup merge of #34298 - nrc:save-parent, r=eddyb
save-analysis: some tweaks
2016-06-17 00:12:04 +01:00
bors
f911d87b3b Auto merge of #34272 - jseyfried:simplify_gated_cfg_checking, r=nrc
Simplify gated cfg checking

r? @nrc
2016-06-16 16:09:45 -07:00
Tshepang Lekhonkhobe
1253e82b7f doc: fix mis-named binding & remove not needed mut 2016-06-16 23:20:58 +02:00
Simonas Kazlauskas
04d63ccf5a Cache drops for early scope exits
Previously we would rebuild all drops on every early exit from a scope, which for code like:

```rust
match x {
    a => return 1,
    b => return 2,
    ...
    z => return 27
}
```

would produce 27 exactly same chains of drops for each return, a O(n*m) explosion in drops.
2016-06-17 00:00:44 +03:00
Erick Tryzelaar
ba5cab1fe0 Revert using ? for try! in the libsyntax pretty printer
The use of ...?instead of try!(...) in libsyntax makes
extracting libsyntax into syntex quite painful since it's
not stable yet. This makes backports take a much longer time
and causes a lot of problems for the syntex dependencies. Even
if it was, it'd take a few release cycles until syntex would
be able to use it. Since it's not stable and that this feature
is just syntax sugar, it would be most helpful if we could remove
it.

cc #34311
2016-06-16 21:16:55 +01:00
Jeffrey Seyfried
2cd6ccf0b1 Simplify gated cfg checking 2016-06-16 19:24:44 +00:00
bors
18f28719ef Auto merge of #34187 - luser:extern-crate-abspaths, r=michaelwoerister
Add an abs_path member to FileMap, use it when writing debug info.

Fixes #34179.

When items are inlined from extern crates, the filename in the debug info
is taken from the FileMap that's serialized in the rlib metadata.
Currently this is just FileMap.name, which is whatever path is passed to rustc.
Since libcore and libstd are built by invoking rustc with relative paths,
they wind up with relative paths in the rlib, and when linked into a binary
the debug info uses relative paths for the names, but since the compilation
directory for the final binary, tools trying to read source filenames
will wind up with bad paths. We noticed this in Firefox with source
filenames from libcore/libstd having bad paths.

This change stores an absolute path in FileMap.abs_path, and uses that
if available for writing debug info. This is not going to magically make
debuggers able to find the source, but it will at least provide sensible
paths.
2016-06-16 12:13:25 -07:00
Ted Mielczarek
24e7491660 Add an abs_path member to FileMap, use it when writing debug info.
When items are inlined from extern crates, the filename in the debug info
is taken from the FileMap that's serialized in the rlib metadata.
Currently this is just FileMap.name, which is whatever path is passed to rustc.
Since libcore and libstd are built by invoking rustc with relative paths,
they wind up with relative paths in the rlib, and when linked into a binary
the debug info uses relative paths for the names, but since the compilation
directory for the final binary, tools trying to read source filenames
will wind up with bad paths. We noticed this in Firefox with source
filenames from libcore/libstd having bad paths.

This change stores an absolute path in FileMap.abs_path, and uses that
if available for writing debug info. This is not going to magically make
debuggers able to find the source, but it will at least provide sensible
paths.
2016-06-16 18:08:46 +01:00
bors
12b6345bc2 Auto merge of #34296 - dsprenkels:issue-23122-tests, r=alexcrichton
Add regression tests for #23122

This PR adds two regression tests for #23122.

Closes #23122.
2016-06-16 09:26:36 -07:00
Ariel Ben-Yehuda
a6d694ea00 fix MirSource::Promoted handling 2016-06-16 17:30:09 +03:00
Ariel Ben-Yehuda
5da8bf8402 stop having 'static in dump-mir names 2016-06-16 16:54:20 +03:00
Ariel Ben-Yehuda
63cdd7ab50 use a different filename for original and promoted MIRs 2016-06-16 16:54:20 +03:00
bors
7aba683c76 Auto merge of #34239 - jseyfried:fix_macro_use_scope_regression, r=nrc
Revert a change in the scope of macros imported from crates to fix a regression

Fixes #34212.
The regression was caused by #34032, which changed the scope of macros imported from extern crates to match the scope of macros imported from modules.
r? @nrc
2016-06-16 06:37:18 -07:00
Peter Atashian
e0992df35f
Fix issue where rustbuild expected msvc to have ar
Signed-off-by: Peter Atashian <retep998@gmail.com>
2016-06-16 08:38:06 -04:00
bors
6edea2cfda Auto merge of #34216 - jseyfried:nested_cfg_attr, r=nrc
Support nested `cfg_attr` attributes

Support arbitrarily deeply nested `cfg_attr` attributes (e.g. `#[cfg_attr(foo, cfg_attr(bar, baz))]`).
This makes configuration idempotent.

Currently, the nighties do not support any `cfg_attr` nesting. Stable and beta support just one level of `cfg_attr` nesting (expect for attributes on macro-expanded nodes, where no nesting is supported).

This is a [breaking-change]. For example, the following would break:
```rust
macro_rules! m { () => {
    #[cfg_attr(all(), cfg_attr(all(), cfg(foo)))]
    fn f() {}
} }
m!();

fn main() { f() } //~ ERROR unresolved name `f`
```
r? @nrc
2016-06-16 03:49:55 -07:00
Nick Cameron
a835d7487c save-analysis: add a decl_id for methods
This is non-null if the method is in a (non-inherent) impl and in that case will be the id for the method declaration in the implemented trait.
2016-06-16 11:28:39 +01:00
bors
a479a6a7a6 Auto merge of #34290 - arielb1:short-ladder, r=eddyb
don't generate drop ladder steps for fields that don't need dropping

cc @eddyb

This should help with #34166
2016-06-16 01:01:26 -07:00
Jeffrey Seyfried
c41cf30e9d Strip unconfigured nodes from decorator-generated AST 2016-06-16 07:58:43 +00:00
Daan Sprenkels
7ee3eaa79c Add regression tests for #23122 2016-06-16 09:46:25 +02:00
Jeffrey Seyfried
83d283b67b Avoid expanding decorator-generated items twice 2016-06-16 06:44:38 +00:00
Ariel Ben-Yehuda
68129a682a fix codegen-units fallout 2016-06-16 09:26:44 +03:00
bors
7339eca0cc Auto merge of #34000 - estebank:missingargs, r=jseyfried
Show types of all args when missing args

When there're missing arguments in a function call, present a list of
all the expected types:

```rust
fn main() {
    t("");
}

fn t(a: &str, x: String) {}
```

```bash
% rustc file.rs
file.rs:3:5: 2:8 error: this function takes 2 parameters but 0
parameters were supplied [E0061]
file.rs:3     t();
              ^~~
file.rs:3:5: 2:8 help: run `rustc --explain E0061` to see a detailed explanation
file.rs:3:5: 2:8 note: the following parameter types were expected: &str, std::string::String
error: aborting due to previous error
```

Fixes #33649
2016-06-15 22:12:26 -07:00
Jeffrey Seyfried
58372af058 Add test for MultiItemModifiers that add items 2016-06-16 03:55:57 +00:00
Jeffrey Seyfried
ac1a1d32f6 Allow MultiItemModifiers to expand into zero or many items 2016-06-16 03:55:55 +00:00
Jeffrey Seyfried
34191ed1c8 Refactor MultiModifier expansion 2016-06-16 03:55:53 +00:00
Jeffrey Seyfried
6ba7b7c22d Implement HasAttrs for Annotatable 2016-06-16 03:55:52 +00:00
bors
58adb07607 Auto merge of #34291 - Manishearth:rollup, r=Manishearth
Rollup of 4 pull requests

- Successful merges: #34207, #34268, #34270, #34290
- Failed merges:
2016-06-15 19:25:45 -07:00
Esteban Küber
1020e3036b Show types of all args when missing args
When there're missing arguments in a function call, present a list of
all the expected types:

```rust
fn main() {
    t("");
}

fn t(a: &str, x: String) {}
```

```bash
% rustc file.rs
file.rs:3:5: 2:8 error: this function takes 2 parameters but 0
parameters were supplied [E0061]
file.rs:3     t();
              ^~~
file.rs:3:5: 2:8 help: run `rustc --explain E0061` to see a detailed explanation
file.rs:3:5: 2:8 note: the following parameter types were expected: &str, std::string::String
error: aborting due to previous error
```

Fixes #33649
2016-06-15 18:40:11 -07:00
Manish Goregaokar
e3d6bb1f71 Rollup merge of #34270 - gkoz:error_file_exists, r=alexcrichton
Add ERROR_FILE_EXISTS to ErrorKind conversion on Windows

Bug report: https://users.rust-lang.org/t/detecting-error-kind-for-opening-file/6215
Reference: https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx#error_file_exists
2016-06-16 01:39:44 +01:00
Manish Goregaokar
2675a55a8f Rollup merge of #34268 - zackmdavis:if_let_over_none_unit_arm, r=jseyfried
prefer `if let` to match with `None => ()` arm in some places

Casual grepping revealed some places in the codebase (some of which
antedated `if let`'s December 2014 stabilization in c200ae5a) where we
were using a match with a `None => ()` arm where (in the present
author's opinion) an `if let` conditional would be more readable. (Other
places where matching to the unit value did seem to better express the
intent were left alone.)

It's likely that we don't care about making such trivial,
non-functional, sheerly æsthetic changes.

But if we do, this is a patch.
2016-06-16 01:39:44 +01:00
Manish Goregaokar
d84993b054 Rollup merge of #34207 - petrochenkov:nohyg, r=jseyfried
Remove last traces of identifier hygiene from HIR

e783a0a5e3 removed the [last](https://github.com/rust-lang/rust/pull/33654#discussion_r63415218) [use](https://github.com/rust-lang/rust/pull/33654#discussion_r63416284) of hygiene at post-resolve compilation stages, so we can avoid renaming during lowering to HIR and just keep original names.

r? @nrc
2016-06-16 01:39:43 +01:00
Oliver Middleton
195fc5a325 rustdoc: Add stability notices to impl items
Also fixes missing stability notices on methods with no docs.
2016-06-15 23:56:24 +01:00
Ariel Ben-Yehuda
2960bc8246 don't generate drop ladder steps for fields that don't need dropping 2016-06-16 00:48:02 +03:00
Alex Burka
b54afbee1f include list of characters 2016-06-15 16:42:36 -04:00
Alex Burka
523dbfc312 update reference for #29734 2016-06-15 16:35:03 -04:00
bors
bb4a79b087 Auto merge of #34220 - srinivasreddy:rf_cargotest, r=brson
run rustfmt on cargotest folder in src/tools/cargotest
2016-06-15 13:11:19 -07:00