Commit Graph

59176 Commits

Author SHA1 Message Date
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
Corey Farwell
e1269ff688 Remove completed FIXME.
https://github.com/rust-lang/rust/issues/30530
2016-11-24 16:26:21 -05: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
fkjogu
a3e03e42e1 Define bound argument in std::sync::mpsc::sync_channel
The `bound` argument in `std::sync::mpsc::sync:channel(bound: usize)` was not defined in the documentation.
2016-11-24 09:49:30 +01:00
Esteban Küber
b7982bbbe0 review comments 2016-11-23 23:44:17 -08: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
Theodore DeRego
5c1c48532f Separated fuchsia-specific process stuff into 'process_fuchsia.rs' and refactored out some now-duplicated code into a 'process_common.rs' 2016-11-23 13:58:13 -08: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
Steven Fackler
8560991cb0 Add a tracking issue for enum_set 2016-11-23 10:55:44 -08: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
Guillaume Gomez
559141c827 Add missing examples to SocketAddrV6 2016-11-23 17:14:41 +01: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
Sam Estep
b15e6a6a00 Use "radices" instead of "radicum" 2016-11-23 08:49:35 -05:00
Sam Estep
49c6b3c23f Use literal 5 instead of five in book section 4.1 2016-11-23 08:41:50 -05:00
Guillaume Gomez
a5049f7bba Add ::1 example in IPv6 to IPv4 conversion 2016-11-23 12:24:04 +01: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
Ulrik Sverdrup
557369ed2e core: Fix example for .map()
Make the example use DoubleEndedIterator for map, like it said it would.
2016-11-23 11:39:53 +01:00
Ulrik Sverdrup
1c6048d0f4 core: Iterator docs, collect is not an adaptor 2016-11-23 11:39:53 +01: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
Theodore DeRego
ae09957040 Whoops :| s/update/unwrap/ 2016-11-22 16:18:02 -08:00
Theodore DeRego
fae86b92de Cleaned up and appeased the linter 2016-11-22 16:08:48 -08: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