Commit Graph

58963 Commits

Author SHA1 Message Date
Corey Farwell
276d91d8cb Document how the RwLockReadGuard structure is created. 2016-11-25 18:57:09 -05:00
bors
ebc0373909 Auto merge of #37982 - rkruppe:llvm-diagnostic-fwdcompat, r=alexcrichton
[LLVM 4.0] OptimizationDiagnostic FFI forward compatibility

- getMsg() changed to return std::string by-value. Fix: copy the data to a rust String during unpacking.
- getPassName() changed to return StringRef

cc #37609
2016-11-25 09:01:33 -06:00
bors
c78cc52afd Auto merge of #37979 - nnethercote:Ty-super_fold_with, r=eddyb
Avoid more unnecessary mk_ty calls in Ty::super_fold_with.

This speeds up several rustc-benchmarks by 1--5%.

This PR is the lovechild of #37108 and #37705.
```
futures-rs-test  4.059s vs  4.011s --> 1.012x faster (variance: 1.016x, 1.026x)
helloworld       0.236s vs  0.239s --> 0.986x faster (variance: 1.051x, 1.014x)
html5ever-2016-  3.831s vs  3.824s --> 1.002x faster (variance: 1.020x, 1.019x)
hyper.0.5.0      4.928s vs  4.936s --> 0.998x faster (variance: 1.003x, 1.012x)
inflate-0.1.0    4.135s vs  4.104s --> 1.007x faster (variance: 1.026x, 1.028x)
issue-32062-equ  0.309s vs  0.303s --> 1.017x faster (variance: 1.019x, 1.084x)
issue-32278-big  1.818s vs  1.797s --> 1.011x faster (variance: 1.011x, 1.008x)
jld-day15-parse  1.304s vs  1.271s --> 1.026x faster (variance: 1.018x, 1.012x)
piston-image-0. 10.938s vs 10.921s --> 1.002x faster (variance: 1.025x, 1.016x)
reddit-stress    2.327s vs  2.208s --> 1.054x faster (variance: 1.016x, 1.006x)
regex-0.1.80     8.796s vs  8.727s --> 1.008x faster (variance: 1.012x, 1.019x)
regex.0.1.30     2.294s vs  2.249s --> 1.020x faster (variance: 1.013x, 1.026x)
rust-encoding-0  1.914s vs  1.886s --> 1.015x faster (variance: 1.027x, 1.026x)
```
2016-11-25 00:22:49 -06:00
bors
2e7176f98b Auto merge of #37974 - japaric:abort, r=alexcrichton
std: make compilation of libpanic_unwind optional via a Cargo feature

with this feature disabled, you can (Cargo) compile std with
"panic=abort"

rustbuild will build std with this feature enabled, to maintain the
status quo

fixes #37252

r? @alexcrichton
2016-11-24 19:03:07 -06:00
bors
d9bdc636da Auto merge of #37951 - jseyfried:improve_macro_resolution_perf, r=nrc
macros: improve resolution performance

Avoid quadratic legacy macro name resolution in more cases.
r? @nrc
2016-11-24 15:31:47 -06:00
bors
a31ad75bde Auto merge of #37944 - bluss:adaptors-are-empty, r=alexcrichton
Forward ExactSizeIterator::len and is_empty for important iterator adaptors

Forward ExactSizeIterator::len and is_empty for important iterator adaptors

Because some iterators will provide improved version of len and/or is_empty,
adaptors should forward to those implementations if possible.
2016-11-24 11:56:11 -06:00
Robin Kruppe
730400167a Support LLVM 4.0 in OptimizationDiagnostic FFI
- getMsg() changed to return std::string by-value. Fix: copy the data to a rust String during unpacking.
- getPassName() changed to return StringRef
2016-11-24 17:33:47 +01:00
bors
ddf011d773 Auto merge of #37770 - pnkfelix:print-type-sizes, r=arielb1
Add debug flag `-Z print-type-sizes` for instrumention type/variant sizes

Add debug flag `-Z print-type-sizes` for instrumention type/variant sizes

This is meant to help with things like #36799 in a very local way; namely, once you have a hypothesis as to which types have a large population or are "too large", you can use `-Z print-type-sizes` to learn how large each type is, and how much each variant in an enum contributes to the size of that overall enum.
2016-11-24 08:26:36 -06:00
Nicholas Nethercote
4d0618ee30 Avoid more unnecessary mk_ty calls in Ty::super_fold_with.
This speeds up several rustc-benchmarks by 1--5%.
2016-11-24 21:11:05 +11:00
bors
217f57c0b5 Auto merge of #37943 - bluss:exact-is-empty, r=alexcrichton
Implement better .is_empty() for slice and vec iterators

These iterators can use a pointer comparison instead of computing the length.
2016-11-24 03:37:44 -06:00
Felix S. Klock II
75825fe1df Tests of -Z print-type-sizes functionality.
Note that the tests have been updated to initialize the local
variables; originally it was enough just to declare them.

Back when I started this, the `layout_cache` contained entries even
just for types that had been declared but not initialized. Apparently
things have changed in the interim so that if I want one of those
layouts to be computed, I need to actually initialize the value.

(Incidentally, this shows a weakness in the strategy of just walking
the `layout_cache`; the original strategy of using a MIR visitor would
probably have exhibited more robustness in terms of consistent output,
but it had other weaknesses so I chose not to reimplement it. At
least, not yet.)

----

Also, I have updated tests to avoid target-specific alignments.
2016-11-24 10:30:18 +01:00
Felix S. Klock II
70e5ca2ab4 Revisions from review comments, squashed.
Biggest change: Revised print-type-sizes output to include breakdown
of layout.

Includes info about field sizes (and alignment + padding when padding
is injected; the injected padding is derived from the offsets computed
by layout module).

Output format is illustrated in commit that has the ui tests.

Note: there exists (at least) one case of variant w/o name: empty
enums.  Namely, empty enums use anonymous univariant repr. So for such
cases, print the number of the variant instead of the name.

----

Also, eddyb suggested of reading from `layout_cache` post-trans.

(For casual readers: the compiler source often uses the word "cache"
for tables that are in fact not periodically purged, and thus are
useful as the basis for data like this.)

Some types that were previously not printed are now included in the
output. (See e.g. the tests `print_type_sizes/generics.rs` and
`print_type_sizes/variants.rs`)

----

Other review feedback:

switch to an exhaustive match when filtering in just structural types.
switch to hashset for layout info and move sort into print method.

----

Driveby change: Factored session::code_stats into its own module

----

incorporate njn feedback re output formatting.
2016-11-24 10:30:18 +01:00
Felix S. Klock II
9383fcf07f Add -Z print-type-sizes, a tool for digging into how variants are laid out. 2016-11-24 10:30:18 +01:00
bors
29abe6f9e8 Auto merge of #37890 - eddyb:rustdoc-1, r=nrc
rustdoc: separate test collection from the main "clean"-ing pipeline.

While reusing the documentation "clean"-ing infrastructure for collecting code examples to test may have seemed appealing at some point, doing the same through a HIR visitor is barely any harder.
At the same time, supporting both "regular documentation" and "test collection" modes in `rustdoc::clean` has its cost, requiring any use of a `TyCtxt` to be speculative, and provide some sort of fallback.

This simplification is the first step towards bringing rustdoc closer to the compiler, and perhaps even unifying the "local crate" (based on the HIR AST) and "inlinined across crates" (based on crate metadata and typesystem information) implementations of rustdoc.

Sadly, not all possible changes to rustdoc will be uncontroversial, so I'm starting small with this patch.
2016-11-24 00:26:44 -06:00
bors
696fab844a Auto merge of #37849 - xen0n:compiler-rt-bump, r=alexcrichton
Update compiler-rt to fix MIPS64 infinite recursion

Fixes #37823.

Test fixes are coming in a separate PR later.

r? @alexcrichton
2016-11-23 21:03:47 -06:00
Jorge Aparicio
ba07a1b58d std: make compilation of libpanic_unwind optional via a Cargo feature
with this feature disabled, you can (Cargo) compile std with
"panic=abort"

rustbuild will build std with this feature enabled, to maintain the
status quo

fixes #37252
2016-11-23 21:49:54 -05:00
bors
1e45b63052 Auto merge of #37931 - eddyb:meta-version, r=jseyfried
rustc_metadata: don't break the version check when CrateRoot changes.

In #36551 I made `rustc_version` a field of `CrateRoot`, but despite it being the first field, one could still break the version check by changing `CrateRoot` so older compilers couldn't fully decode it (e.g. #37463).

This PR fixes #37803 by moving the version string back at the beginning of metadata, right after the 32-bit big-endian absolute position of `CrateRoot`, and by incrementing `METADATA_VERSION`.
2016-11-23 17:48:44 -06:00
Eduard-Mihai Burtescu
4be7786330 rustdoc: we can now assume DocContext always has a TyCtxt. 2016-11-24 01:40:56 +02:00
Eduard-Mihai Burtescu
e68ad42dfa rustdoc: sidestep the main pipeline for test collection. 2016-11-24 01:40:56 +02:00
Eduard-Mihai Burtescu
12c5f8cb75 rustdoc: use libsyntax ast::Attribute instead of "cleaning" them. 2016-11-24 01:40:52 +02:00
bors
d5814b03e6 Auto merge of #37908 - nrc:save-def, r=eddyb
save-analysis: fix ICE on partially resolved path

Occurs when we produce save-analysis before type checking is complete (due to errors).
2016-11-23 14:31:45 -06:00
Nick Cameron
b1f86fb7c3 Inspect def locally instead of using a method 2016-11-24 07:50:22 +13:00
bors
d515586465 Auto merge of #36449 - canndrew:expand_is_uninhabited, r=eddyb
Expand is_uninhabited

This allows code such as this to compile:

``` rust
let x: ! = ...;
match x {};

let y: (u32, !) = ...;
match y {};
```

@eddyb You were worried about making this change. Do you have any idea about what could break? Are there any special tests that need to be written for it?
2016-11-23 11:16:22 -06:00
bors
127a83df66 Auto merge of #37937 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 7 pull requests

- Successful merges: #37442, #37760, #37836, #37851, #37859, #37913, #37925
- Failed merges:
2016-11-23 08:01:41 -06:00
Guillaume Gomez
d2c600a2c9 Rollup merge of #37940 - michaelwoerister:ich-struct-constructors, r=nikomatsakis
ICH: Add test case for struct constructor expressions.

r? @nikomatsakis
2016-11-23 12:18:10 +01:00
Guillaume Gomez
90a2671a3c Rollup merge of #37938 - michaelwoerister:move-myriad-closures, r=eddyb
Move the myriad-closures.rs test case to run-pass-full test suite.

r? @eddyb
2016-11-23 12:18:10 +01:00
Guillaume Gomez
cfc7fce2f0 Rollup merge of #37925 - jtdowney:env-args-doc-links, r=steveklabnik
Add some internal docs links for Args/ArgsOs

In many places the docs link to other sections and I noticed it was lacking here. Not sure if there is a standard for if inter-linking is appropriate.
2016-11-23 12:18:10 +01:00
Guillaume Gomez
881115c896 Rollup merge of #37913 - GuillaumeGomez:socket-v4, r=frewsxcv
Add missing examples for SocketAddrV4

r? @steveklabnik

cc @frewsxcv
2016-11-23 12:18:10 +01:00
Guillaume Gomez
761c738876 Rollup merge of #37851 - jneem:master, r=sanxiyn
Add a regression test for issue 23699.

This should close #23699
2016-11-23 12:18:09 +01:00
Guillaume Gomez
067ffddbbb Rollup merge of #37836 - steveklabnik:remove-incorrect-reference-comment, r=GuillaumeGomez
Clarify the reference's status.

The former wording only gave part of the picture, we want to be crystal
clear about this.

/cc @petrochenkov, who had concerns about https://github.com/rust-lang/rust/pull/37820
2016-11-23 12:18:09 +01:00
Guillaume Gomez
496a411e4e Rollup merge of #37760 - nnethercote:TypeWalker-SmallVector, r=arielb1
Type walker small vector

These two changes avoid allocations on some hot paths and speed up a few workloads (some from rustc-benchmarks, as well as the workload from #36799) by 1--2%.
2016-11-23 12:18:09 +01:00
Guillaume Gomez
464cce99f1 Rollup merge of #37442 - estebank:cast-deref-hint, r=jonathandturner
Provide hint when cast needs a dereference

For a given code:

``` rust
vec![0.0].iter().map(|s| s as i16).collect::<Vec<i16>>();
```

display:

``` nocode
error: casting `&f64` as `i16` is invalid
 --> file3.rs:2:35
  |
2 |     vec![0.0].iter().map(|s| s as i16).collect::<Vec<i16>>();
  |                              -    ^^^
  |                              |
  |                              did you mean `*s`?
```

instead of:

``` nocode
error: casting `&f64` as `i16` is invalid
 --> <anon>:2:30
  |
2 |     vec![0.0].iter().map(|s| s as i16).collect();
  |                              ^^^^^^^^
  |
  = help: cast through a raw pointer first
```

Fixes #37338.
2016-11-23 12:18:09 +01:00
bors
9fba8df211 Auto merge of #37924 - brson:config-bug, r=alexcrichton
configure: Fix string equality
2016-11-23 04:51:49 -06:00
Andrew Cann
2121118f54 Revert libcore changes 2016-11-23 17:13:12 +08:00
bors
ccdc26fd42 Auto merge of #37886 - Stebalien:set-perm, r=alexcrichton
Add a method for setting permissions directly on an open file.

On unix like systems, the underlying file corresponding to any given path may change at any time. This function makes it possible to set the permissions of the a file corresponding to a `File` object even if its path changes.

@retep998, what's the best way to do this on Windows? I looked into `SetFileInformationByHandle` but couldn't find a way to do it atomically risking clobbering access time information.

This is a first step towards fixing #37885. This function doesn't *have* to be public but this is useful functionality that should probably be exposed.
2016-11-23 01:21:45 -06:00
Nick Cameron
68312e3e20 Fix a bunch of bugs shown by the test 2016-11-23 18:47:07 +13:00
bors
5196ca8518 Auto merge of #37681 - nrc:crate-metadata, r=@alexcrichton
add --crate-type metadata

r? @alexcrichton
2016-11-22 21:54:10 -06:00
Jeffrey Seyfried
cbe478766c macros: improve performance of legacy name resolution. 2016-11-23 01:51:37 +00:00
Ulrik Sverdrup
74cde120e5 core, collections: Implement better .is_empty() for slice and vec iterators
These iterators can use a pointer comparison instead of computing the length.
2016-11-23 02:31:41 +01:00
Nick Cameron
9ea1544b80 Add a test 2016-11-23 13:35:07 +13:00
bors
1cabe21512 Auto merge of #37487 - goffrie:break, r=nikomatsakis
Implement the `loop_break_value` feature.

This implements RFC 1624, tracking issue #37339.
- `FnCtxt` (in typeck) gets a stack of `LoopCtxt`s, which store the
  currently deduced type of that loop, the desired type, and a list of
  break expressions currently seen. `loop` loops get a fresh type
  variable as their initial type (this logic is stolen from that for
  arrays). `while` loops get `()`.
- `break {expr}` looks up the broken loop, and unifies the type of
  `expr` with the type of the loop.
- `break` with no expr unifies the loop's type with `()`.
- When building MIR, loops no longer construct a `()` value at
  termination of the loop; rather, the `break` expression assigns the
  result of the loop.
- ~~I have also changed the loop scoping in MIR-building so that the test
  of a while loop is not considered to be part of that loop. This makes
  the rules consistent with #37360. The new loop scopes in typeck also
  follow this rule. That means that `loop { while (break) {} }` now
  terminates instead of looping forever. This is technically a breaking
  change.~~
- ~~On that note, expressions like `while break {}` and `if break {}` no
  longer parse because `{}` is interpreted as an expression argument to
  `break`. But no code except compiler test cases should do that anyway
  because it makes no sense.~~
- The RFC did not make it clear, but I chose to make `break ()` inside
  of a `while` loop illegal, just in case we wanted to do anything with
  that design space in the future.

This is my first time dealing with this part of rustc so I'm sure
there's plenty of problems to pick on here ^_^
2016-11-22 17:51:59 -06:00
Nick Cameron
af1b19555c Rebasing and review changes 2016-11-23 12:50:39 +13:00
Nick Cameron
3295afa6e2 save-analysis: fix ICE on partially resolved path
Occurs when we produce save-analysis before type checking is complete (due to errors).
2016-11-23 11:53:27 +13:00
Ulrik Sverdrup
22739a148e core: Forward ExactSizeIterator methods for important iterator adaptors 2016-11-22 23:51:02 +01:00
Michael Woerister
12f3caf6a8 ICH: Add test case for struct constructor expressions. 2016-11-22 15:49:58 -05:00
Michael Woerister
c0464eef17 Move the myriad-closures.rs test case to run-pass-full test suite. 2016-11-22 15:16:54 -05:00
Steven Allen
1aaca5f290 Add a method for setting permissions directly on an open file.
On unix like systems, the underlying file corresponding to any given path may
change at any time. This function makes it possible to set the permissions of
the a file corresponding to a `File` object even if its path changes.
2016-11-22 08:42:28 -08:00
Eduard-Mihai Burtescu
f4c68d2825 rustc_metadata: don't break the version check when CrateRoot changes. 2016-11-22 14:51:55 +02:00
bors
3bf2be9cee Auto merge of #37843 - nikomatsakis:issue-33685-hard-error, r=eddyb
make HR_LIFETIME_IN_ASSOC_TYPE deny-by-default

It's time to fix issue #32330.

cc #33685
cc @arielb1
2016-11-22 06:39:42 -06:00
bors
0f7c75b74f Auto merge of #37834 - bluss:peek-none, r=BurntSushi
Make Peekable remember peeking a None

Peekable should remember if a None has been seen in the `.peek()` method.
It ensures that `.peek(); .peek();` or `.peek(); .next();` only advances the
underlying iterator at most once. This does not by itself make the iterator
fused.

Thanks to @s3bk for the code in `fn peek()` itself.

Fixes #37784
2016-11-22 03:29:46 -06:00