]> git.lizzy.rs Git - rust.git/log
rust.git
7 years agoRollup merge of #37962 - GuillaumeGomez:socket-v6, r=frewsxcv
Seo Sanghyeon [Sat, 26 Nov 2016 13:02:13 +0000 (22:02 +0900)]
Rollup merge of #37962 - GuillaumeGomez:socket-v6, r=frewsxcv

Add missing examples to SocketAddrV6

r? @steveklabnik

cc @frewsxcv

7 years agoAuto merge of #37960 - samestep:five, r=frewsxcv
bors [Sat, 26 Nov 2016 02:19:47 +0000 (20:19 -0600)]
Auto merge of #37960 - samestep:five, r=frewsxcv

Use literal 5 instead of five in book section 4.1

The other two code snippets in this sentence are valid code, so it makes more sense to use the literal `5` rather than the invalid symbol `five`.

7 years agoAuto merge of #38000 - rkruppe:llvm-dinamespace-fwdcompat, r=alexcrichton
bors [Fri, 25 Nov 2016 22:57:37 +0000 (16:57 -0600)]
Auto merge of #38000 - rkruppe:llvm-dinamespace-fwdcompat, r=alexcrichton

[LLVM 4.0] Pass new argument ExportSymbol to DIBuilder::createNameSpace

cc #37609

7 years agoAuto merge of #37987 - plietar:cross-proc-macro, r=jseyfried
bors [Fri, 25 Nov 2016 19:48:08 +0000 (13:48 -0600)]
Auto merge of #37987 - plietar:cross-proc-macro, r=jseyfried

Delay error reporting of filename mismatch.

When cross compiling with procedural macros, the crate loader starts by
looking for a target crate, before trying with a host crate.

Rather than emitting an error immediately if the host and target
extension differ, the compiler should delay it until both attempts have
failed.

Fixes #37899

7 years agoPass new argument ExportSymbol to DIBuilder::createNameSpace
Robin Kruppe [Fri, 25 Nov 2016 16:23:25 +0000 (17:23 +0100)]
Pass new argument ExportSymbol to DIBuilder::createNameSpace

7 years agoAuto merge of #37982 - rkruppe:llvm-diagnostic-fwdcompat, r=alexcrichton
bors [Fri, 25 Nov 2016 15:01:33 +0000 (09:01 -0600)]
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

7 years agoAuto merge of #37979 - nnethercote:Ty-super_fold_with, r=eddyb
bors [Fri, 25 Nov 2016 06:22:49 +0000 (00:22 -0600)]
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)
```

7 years agoAuto merge of #37974 - japaric:abort, r=alexcrichton
bors [Fri, 25 Nov 2016 01:03:07 +0000 (19:03 -0600)]
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

7 years agoDelay error reporting of filename mismatch.
Paul Lietar [Thu, 24 Nov 2016 22:12:36 +0000 (22:12 +0000)]
Delay error reporting of filename mismatch.

When cross compiling with procedural macros, the crate loader starts by
looking for a target crate, before trying with a host crate.

Rather than emitting an error immediately if the host and target
extension differ, the compiler should delay it until both attempts have
failed.

Fixes #37899

r? @jseyfried

7 years agoAuto merge of #37951 - jseyfried:improve_macro_resolution_perf, r=nrc
bors [Thu, 24 Nov 2016 21:31:47 +0000 (15:31 -0600)]
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

7 years agoAuto merge of #37944 - bluss:adaptors-are-empty, r=alexcrichton
bors [Thu, 24 Nov 2016 17:56:11 +0000 (11:56 -0600)]
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.

7 years agoSupport LLVM 4.0 in OptimizationDiagnostic FFI
Robin Kruppe [Thu, 24 Nov 2016 16:33:47 +0000 (17:33 +0100)]
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

7 years agoAuto merge of #37770 - pnkfelix:print-type-sizes, r=arielb1
bors [Thu, 24 Nov 2016 14:26:36 +0000 (08:26 -0600)]
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.

7 years agoAvoid more unnecessary mk_ty calls in Ty::super_fold_with.
Nicholas Nethercote [Thu, 24 Nov 2016 10:10:08 +0000 (21:10 +1100)]
Avoid more unnecessary mk_ty calls in Ty::super_fold_with.

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

7 years agoAuto merge of #37943 - bluss:exact-is-empty, r=alexcrichton
bors [Thu, 24 Nov 2016 09:37:44 +0000 (03:37 -0600)]
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.

7 years agoTests of `-Z print-type-sizes` functionality.
Felix S. Klock II [Thu, 24 Nov 2016 09:28:29 +0000 (10:28 +0100)]
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.

7 years agoRevisions from review comments, squashed.
Felix S. Klock II [Tue, 15 Nov 2016 16:48:07 +0000 (17:48 +0100)]
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.

7 years agoAdd `-Z print-type-sizes`, a tool for digging into how variants are laid out.
Felix S. Klock II [Mon, 14 Nov 2016 16:46:20 +0000 (17:46 +0100)]
Add `-Z print-type-sizes`, a tool for digging into how variants are laid out.

7 years agoAuto merge of #37890 - eddyb:rustdoc-1, r=nrc
bors [Thu, 24 Nov 2016 06:26:44 +0000 (00:26 -0600)]
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.

7 years agoAuto merge of #37849 - xen0n:compiler-rt-bump, r=alexcrichton
bors [Thu, 24 Nov 2016 03:03:47 +0000 (21:03 -0600)]
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

7 years agostd: make compilation of libpanic_unwind optional via a Cargo feature
Jorge Aparicio [Thu, 24 Nov 2016 02:49:54 +0000 (21:49 -0500)]
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

7 years agoAuto merge of #37931 - eddyb:meta-version, r=jseyfried
bors [Wed, 23 Nov 2016 23:48:44 +0000 (17:48 -0600)]
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`.

7 years agorustdoc: we can now assume DocContext always has a TyCtxt.
Eduard-Mihai Burtescu [Sun, 20 Nov 2016 01:42:54 +0000 (03:42 +0200)]
rustdoc: we can now assume DocContext always has a TyCtxt.

7 years agorustdoc: sidestep the main pipeline for test collection.
Eduard-Mihai Burtescu [Sun, 20 Nov 2016 01:11:20 +0000 (03:11 +0200)]
rustdoc: sidestep the main pipeline for test collection.

7 years agorustdoc: use libsyntax ast::Attribute instead of "cleaning" them.
Eduard-Mihai Burtescu [Wed, 23 Nov 2016 23:40:52 +0000 (01:40 +0200)]
rustdoc: use libsyntax ast::Attribute instead of "cleaning" them.

7 years agoAuto merge of #37908 - nrc:save-def, r=eddyb
bors [Wed, 23 Nov 2016 20:31:45 +0000 (14:31 -0600)]
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).

7 years agoInspect def locally instead of using a method
Nick Cameron [Wed, 23 Nov 2016 18:50:22 +0000 (07:50 +1300)]
Inspect def locally instead of using a method

7 years agoAuto merge of #36449 - canndrew:expand_is_uninhabited, r=eddyb
bors [Wed, 23 Nov 2016 17:16:22 +0000 (11:16 -0600)]
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?

7 years agoAdd missing examples to SocketAddrV6
Guillaume Gomez [Wed, 23 Nov 2016 16:14:41 +0000 (17:14 +0100)]
Add missing examples to SocketAddrV6

7 years agoAuto merge of #37937 - GuillaumeGomez:rollup, r=GuillaumeGomez
bors [Wed, 23 Nov 2016 14:01:41 +0000 (08:01 -0600)]
Auto merge of #37937 - GuillaumeGomez:rollup, r=GuillaumeGomez

Rollup of 7 pull requests

- Successful merges: #37442, #37760, #37836, #37851, #37859, #37913, #37925
- Failed merges:

7 years agoUse literal 5 instead of five in book section 4.1
Sam Estep [Wed, 23 Nov 2016 13:41:50 +0000 (08:41 -0500)]
Use literal 5 instead of five in book section 4.1

7 years agoRollup merge of #37940 - michaelwoerister:ich-struct-constructors, r=nikomatsakis
Guillaume Gomez [Wed, 23 Nov 2016 11:18:10 +0000 (12:18 +0100)]
Rollup merge of #37940 - michaelwoerister:ich-struct-constructors, r=nikomatsakis

ICH: Add test case for struct constructor expressions.

r? @nikomatsakis

7 years agoRollup merge of #37938 - michaelwoerister:move-myriad-closures, r=eddyb
Guillaume Gomez [Wed, 23 Nov 2016 11:18:10 +0000 (12:18 +0100)]
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

7 years agoRollup merge of #37925 - jtdowney:env-args-doc-links, r=steveklabnik
Guillaume Gomez [Wed, 23 Nov 2016 11:18:10 +0000 (12:18 +0100)]
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.

7 years agoRollup merge of #37913 - GuillaumeGomez:socket-v4, r=frewsxcv
Guillaume Gomez [Wed, 23 Nov 2016 11:18:10 +0000 (12:18 +0100)]
Rollup merge of #37913 - GuillaumeGomez:socket-v4, r=frewsxcv

Add missing examples for SocketAddrV4

r? @steveklabnik

cc @frewsxcv

7 years agoRollup merge of #37851 - jneem:master, r=sanxiyn
Guillaume Gomez [Wed, 23 Nov 2016 11:18:09 +0000 (12:18 +0100)]
Rollup merge of #37851 - jneem:master, r=sanxiyn

Add a regression test for issue 23699.

This should close #23699

7 years agoRollup merge of #37836 - steveklabnik:remove-incorrect-reference-comment, r=Guillaume...
Guillaume Gomez [Wed, 23 Nov 2016 11:18:09 +0000 (12:18 +0100)]
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

7 years agoRollup merge of #37760 - nnethercote:TypeWalker-SmallVector, r=arielb1
Guillaume Gomez [Wed, 23 Nov 2016 11:18:09 +0000 (12:18 +0100)]
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%.

7 years agoRollup merge of #37442 - estebank:cast-deref-hint, r=jonathandturner
Guillaume Gomez [Wed, 23 Nov 2016 11:18:09 +0000 (12:18 +0100)]
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.

7 years agoAuto merge of #37924 - brson:config-bug, r=alexcrichton
bors [Wed, 23 Nov 2016 10:51:49 +0000 (04:51 -0600)]
Auto merge of #37924 - brson:config-bug, r=alexcrichton

configure: Fix string equality

7 years agoRevert libcore changes
Andrew Cann [Wed, 23 Nov 2016 09:13:12 +0000 (17:13 +0800)]
Revert libcore changes

7 years agoAuto merge of #37886 - Stebalien:set-perm, r=alexcrichton
bors [Wed, 23 Nov 2016 07:21:45 +0000 (01:21 -0600)]
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.

7 years agoFix a bunch of bugs shown by the test
Nick Cameron [Wed, 23 Nov 2016 05:47:07 +0000 (18:47 +1300)]
Fix a bunch of bugs shown by the test

7 years agoAuto merge of #37681 - nrc:crate-metadata, r=@alexcrichton
bors [Wed, 23 Nov 2016 03:54:10 +0000 (21:54 -0600)]
Auto merge of #37681 - nrc:crate-metadata, r=@alexcrichton

add --crate-type metadata

r? @alexcrichton

7 years agomacros: improve performance of legacy name resolution.
Jeffrey Seyfried [Wed, 23 Nov 2016 01:51:37 +0000 (01:51 +0000)]
macros: improve performance of legacy name resolution.

7 years agocore, collections: Implement better .is_empty() for slice and vec iterators
Ulrik Sverdrup [Tue, 22 Nov 2016 22:31:31 +0000 (23:31 +0100)]
core, collections: Implement better .is_empty() for slice and vec iterators

These iterators can use a pointer comparison instead of computing the length.

7 years agoAdd a test
Nick Cameron [Wed, 23 Nov 2016 00:35:07 +0000 (13:35 +1300)]
Add a test

7 years agoAuto merge of #37487 - goffrie:break, r=nikomatsakis
bors [Tue, 22 Nov 2016 23:51:59 +0000 (17:51 -0600)]
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 ^_^

7 years agoRebasing and review changes
Nick Cameron [Thu, 10 Nov 2016 21:00:33 +0000 (10:00 +1300)]
Rebasing and review changes

7 years agosave-analysis: fix ICE on partially resolved path
Nick Cameron [Mon, 21 Nov 2016 05:11:36 +0000 (18:11 +1300)]
save-analysis: fix ICE on partially resolved path

Occurs when we produce save-analysis before type checking is complete (due to errors).

7 years agocore: Forward ExactSizeIterator methods for important iterator adaptors
Ulrik Sverdrup [Tue, 22 Nov 2016 22:48:33 +0000 (23:48 +0100)]
core: Forward ExactSizeIterator methods for important iterator adaptors

7 years agoICH: Add test case for struct constructor expressions.
Michael Woerister [Tue, 22 Nov 2016 20:49:58 +0000 (15:49 -0500)]
ICH: Add test case for struct constructor expressions.

7 years agoMove the myriad-closures.rs test case to run-pass-full test suite.
Michael Woerister [Tue, 22 Nov 2016 20:16:54 +0000 (15:16 -0500)]
Move the myriad-closures.rs test case to run-pass-full test suite.

7 years agoAdd a method for setting permissions directly on an open file.
Steven Allen [Sat, 19 Nov 2016 17:53:54 +0000 (09:53 -0800)]
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.

7 years agorustc_metadata: don't break the version check when CrateRoot changes.
Eduard-Mihai Burtescu [Tue, 22 Nov 2016 12:51:55 +0000 (14:51 +0200)]
rustc_metadata: don't break the version check when CrateRoot changes.

7 years agoAuto merge of #37843 - nikomatsakis:issue-33685-hard-error, r=eddyb
bors [Tue, 22 Nov 2016 12:39:42 +0000 (06:39 -0600)]
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

7 years agoAuto merge of #37834 - bluss:peek-none, r=BurntSushi
bors [Tue, 22 Nov 2016 09:29:46 +0000 (03:29 -0600)]
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

7 years agoUse FxHashSet instead of HashMap
Andrew Cann [Tue, 22 Nov 2016 06:39:56 +0000 (14:39 +0800)]
Use FxHashSet instead of HashMap

7 years agoMake is_uninhabited respect privacy
Andrew Cann [Wed, 9 Nov 2016 09:55:57 +0000 (17:55 +0800)]
Make is_uninhabited respect privacy

7 years agoRevert libcore changes, redefine Void instead
Andrew Cann [Wed, 9 Nov 2016 09:55:11 +0000 (17:55 +0800)]
Revert libcore changes, redefine Void instead

7 years agoRecursive types are always non-empty
Andrew Cann [Wed, 14 Sep 2016 17:41:45 +0000 (01:41 +0800)]
Recursive types are always non-empty

7 years agoExpand is_uninhabited for references
Andrew Cann [Wed, 14 Sep 2016 17:11:11 +0000 (01:11 +0800)]
Expand is_uninhabited for references

7 years agoFix previous commit
Andrew Cann [Wed, 14 Sep 2016 17:10:53 +0000 (01:10 +0800)]
Fix previous commit

7 years agoExpand `is_uninhabited` to recurse into datatypes
Andrew Cann [Wed, 14 Sep 2016 15:58:58 +0000 (23:58 +0800)]
Expand `is_uninhabited` to recurse into datatypes

7 years agoExpand is_uninhabited for ! and tuples
Andrew Cann [Tue, 13 Sep 2016 08:30:57 +0000 (16:30 +0800)]
Expand is_uninhabited for ! and tuples

7 years agoImplement the `loop_break_value` feature.
Geoffry Song [Sat, 29 Oct 2016 22:15:06 +0000 (15:15 -0700)]
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, `loop` loops no longer construct a `()` value at
  termination of the loop; rather, the `break` expression assigns the
  result of the loop. `while` loops are unchanged.
- `break` respects contexts in which expressions may not end with braced
  blocks. That is, `while break { break-value } { while-body }` is
  illegal; this preserves backwards compatibility.
- 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 ^_^

7 years agoAuto merge of #37602 - jseyfried:directory_ownership, r=nikomatsakis
bors [Tue, 22 Nov 2016 03:15:48 +0000 (21:15 -0600)]
Auto merge of #37602 - jseyfried:directory_ownership, r=nikomatsakis

parser: simplify directory ownership semantics

This PR simplifies the semantics of "directory ownership". After this PR,
 - a non-inline module without a `#[path]` attribute (e.g. `mod foo;`) is allowed iff its parent module/block (whichever is nearer) is a directory owner,
 - an non-inline module is a directory owner iff its corresponding file is named `mod.rs` (c.f. [comment](https://github.com/rust-lang/rust/issues/32401#issuecomment-201021902)),
 - a block is never a directory owner (c.f. #31534), and
 - an inline module is a directory owner iff either
   - its parent module/block is a directory owner (again, c.f. #31534), or
   - it has a `#[path]` attribute (c.f. #36789).

These semantics differ from today's in three orthogonal ways:
 - `#[path = "foo.rs"] mod foo;` is no longer a directory owner. This is a [breaking-change].
 - #36789 is generalized to apply to modules that are not directory owners in addition to blocks.
 - A macro-expanded non-inline module is only allowed where an ordinary non-inline module would be allowed. Today, we incorrectly allow macro-expanded non-inline modules in modules that are not directory owners (but not in blocks). This is a [breaking-change].

Fixes #32401.
r? @nikomatsakis

7 years agoStart warning cycle.
Jeffrey Seyfried [Mon, 14 Nov 2016 09:31:03 +0000 (09:31 +0000)]
Start warning cycle.

7 years agoFix fallout in tests.
Jeffrey Seyfried [Sat, 5 Nov 2016 10:46:44 +0000 (10:46 +0000)]
Fix fallout in tests.

7 years agoAdd a regression test and organize tests.
Jeffrey Seyfried [Sat, 5 Nov 2016 05:31:35 +0000 (05:31 +0000)]
Add a regression test and organize tests.

7 years agoClean up directory ownership semantics.
Jeffrey Seyfried [Sat, 5 Nov 2016 04:16:26 +0000 (04:16 +0000)]
Clean up directory ownership semantics.

7 years agoAuto merge of #37642 - nnethercote:no-HirVec-of-P, r=michaelwoerister
bors [Mon, 21 Nov 2016 23:59:10 +0000 (17:59 -0600)]
Auto merge of #37642 - nnethercote:no-HirVec-of-P, r=michaelwoerister

Change HirVec<P<T>> to HirVec<T> in hir:: Expr.

This PR changes data structures like this:
```
[ ExprArray | 8 | P ]
                  |
                  v
                  [ P | P | P | P | P | P | P | P ]
                    |
                    v
                    [ ExprTup | 2 | P ]
                                    |
                                    v
                                    [ P | P ]
                                      |
                                      v
                                      [ Expr ]
```
to this:
```
[ ExprArray | 8 | P ]
                  |
                  v
                  [ [ ExprTup | 2 | P ] | ... ]
                                    |
                                    v
                                    [ Expr | Expr ]
```
I thought this would be a win for #36799, and on a cut-down version of that workload this reduces the peak heap size (as measured by Massif) from 885 MiB to 875 MiB. However, the peak RSS as measured by `-Ztime-passes` and by `/usr/bin/time` increases by about 30 MiB.

I'm not sure why. Just look at the picture above -- the second data structure clearly takes up less space than the first. My best idea relates to unused elements in the slices. `HirVec<Expr>` is a typedef for `P<[Expr]>`. If there were any unused excess elements then I could see that memory usage would increase, because those excess elements are larger in `HirVec<Expr>` than in `HirVec<P<Expr>>`. But AIUI there are no such excess elements, and Massif's measurements corroborate that.

However, the two main creation points for these data structures are these lines from `lower_expr`:
```rust
        ExprKind::Vec(ref exprs) => {
            hir::ExprArray(exprs.iter().map(|x| self.lower_expr(x)).collect())
        }
        ExprKind::Tup(ref elts) => {
            hir::ExprTup(elts.iter().map(|x| self.lower_expr(x)).collect())
        }
```
I suspect what is happening is that temporary excess elements are created within the `collect` calls. The workload from #36799 has many 2-tuples and 3-tuples and when `Vec` gets doubled it goes from a capacity of 1 to 4, which would lead to excess elements. Though, having said that, `Vec::with_capacity` doesn't create excess AFAICT. So I'm not sure. What goes on inside `collect` is complex.

Anyway, in its current form this PR is a memory consumption regression and so not worth landing but I figured I'd post it in case anyone has additional insight.

7 years agoUse SmallVec for TypeWalker's stack.
Nicholas Nethercote [Mon, 17 Oct 2016 21:23:09 +0000 (08:23 +1100)]
Use SmallVec for TypeWalker's stack.

The change also adds the missing `SmallVec::truncate` method.

7 years agoAdd some internal docs links for Args/ArgsOs
John Downey [Mon, 21 Nov 2016 22:12:14 +0000 (16:12 -0600)]
Add some internal docs links for Args/ArgsOs

7 years agoconfigure: Fix string equality
Brian Anderson [Mon, 21 Nov 2016 22:10:51 +0000 (22:10 +0000)]
configure: Fix string equality

7 years agoChange HirVec<P<T>> to HirVec<T> in Expr.
Nicholas Nethercote [Fri, 28 Oct 2016 10:16:44 +0000 (21:16 +1100)]
Change HirVec<P<T>> to HirVec<T> in Expr.

This changes structures like this:
```
[ ExprArray | 8 | P ]
                  |
                  v
                  [ P | P | P | P | P | P | P | P ]
                    |
                    v
                    [ ExprTup | 2 | P ]
                                    |
                                    v
                                    [ P | P ]
                                      |
                                      v
                                      [ Expr ]
```
to this:
```
[ ExprArray | 8 | P ]
                  |
                  v
                  [ [ ExprTup | 2 | P ] | ... ]
                                    |
                                    v
                                    [ Expr | Expr ]
```

7 years agoAdd regression test for issue 23699.
Joe Neeman [Mon, 21 Nov 2016 21:02:03 +0000 (22:02 +0100)]
Add regression test for issue 23699.

7 years agoAuto merge of #37677 - jsen-:master, r=alexcrichton
bors [Mon, 21 Nov 2016 20:37:24 +0000 (14:37 -0600)]
Auto merge of #37677 - jsen-:master, r=alexcrichton

libstd: support creation of anonymous pipe on WinXP/2K3

`PIPE_REJECT_REMOTE_CLIENTS` flag is not supported on Windows < VISTA, and every invocation of `anon_pipe` including attempts to pipe `std::process::Child`'s stdio fails.
This PR should work around this issue by performing a runtime check of windows version and conditionally omitting this flag on "XP and friends".

Getting the version should be probably moved out of the function `anon_pipe` itself (the OS version does not often change during runtime :) ), but:
 - I didn't find any precedent for this and assuming there's not much overhead (I hope windows does not perform any heuristics to find out it's own version, just fills couple of fields in the struct).
 - the code path is not especially performance sensitive anyway.

7 years agoAuto merge of #37912 - sanxiyn:llvm-compat, r=eddyb
bors [Mon, 21 Nov 2016 17:23:04 +0000 (11:23 -0600)]
Auto merge of #37912 - sanxiyn:llvm-compat, r=eddyb

Restore compatibility with LLVM 3.7 and 3.8

This should fix Travis build.

7 years agoAuto merge of #37824 - jseyfried:symbols, r=eddyb
bors [Mon, 21 Nov 2016 14:08:47 +0000 (08:08 -0600)]
Auto merge of #37824 - jseyfried:symbols, r=eddyb

Clean up `ast::Attribute`, `ast::CrateConfig`, and string interning

This PR
 - removes `ast::Attribute_` (changing `Attribute` from `Spanned<Attribute_>` to a struct),
 - moves a `MetaItem`'s name from the `MetaItemKind` variants to a field of `MetaItem`,
 - avoids needlessly wrapping `ast::MetaItem` with `P`,
 - moves string interning into `syntax::symbol` (`ast::Name` is a reexport of `symbol::Symbol` for now),
 - replaces `InternedString` with `Symbol` in the AST, HIR, and various other places, and
 - refactors `ast::CrateConfig` from a `Vec` to a `HashSet`.

r? @eddyb

7 years agoAdd missing examples for SocketAddrV4
Guillaume Gomez [Mon, 21 Nov 2016 13:07:58 +0000 (14:07 +0100)]
Add missing examples for SocketAddrV4

7 years agoFix fallout in `rustdoc` and tests.
Jeffrey Seyfried [Thu, 17 Nov 2016 14:04:36 +0000 (14:04 +0000)]
Fix fallout in `rustdoc` and tests.

7 years agoRestore compatibility with LLVM 3.7 and 3.8
Seo Sanghyeon [Mon, 21 Nov 2016 11:30:05 +0000 (20:30 +0900)]
Restore compatibility with LLVM 3.7 and 3.8

7 years agoAuto merge of #37127 - jseyfried:stabilize_RFC_1560, r=nrc
bors [Mon, 21 Nov 2016 10:54:46 +0000 (04:54 -0600)]
Auto merge of #37127 - jseyfried:stabilize_RFC_1560, r=nrc

Stabilize RFC 1560

Fixes #13598, fixes #23157, fixes #32303.
cc #35120
r? @nrc

7 years agoFix fallout in tests.
Jeffrey Seyfried [Thu, 13 Oct 2016 08:05:03 +0000 (08:05 +0000)]
Fix fallout in tests.

7 years agoCleanup.
Jeffrey Seyfried [Tue, 11 Oct 2016 07:47:21 +0000 (07:47 +0000)]
Cleanup.

7 years agoStabilize RFC 1560.
Jeffrey Seyfried [Fri, 30 Sep 2016 00:03:16 +0000 (00:03 +0000)]
Stabilize RFC 1560.

7 years agoFix incremental compilation hashing.
Jeffrey Seyfried [Sun, 20 Nov 2016 00:32:54 +0000 (00:32 +0000)]
Fix incremental compilation hashing.

7 years agoRemove `Rc` from the interner.
Jeffrey Seyfried [Sat, 19 Nov 2016 05:55:28 +0000 (05:55 +0000)]
Remove `Rc` from the interner.

7 years agoCleanup `InternedString`.
Jeffrey Seyfried [Thu, 17 Nov 2016 14:04:20 +0000 (14:04 +0000)]
Cleanup `InternedString`.

7 years agoUse `Symbol` instead of `InternedString` in the AST, HIR, and various other places.
Jeffrey Seyfried [Wed, 16 Nov 2016 10:52:37 +0000 (10:52 +0000)]
Use `Symbol` instead of `InternedString` in the AST, HIR, and various other places.

7 years agoUpdate compiler-rt to fix MIPS64 infinite recursion
Wang Xuerui [Fri, 18 Nov 2016 05:25:19 +0000 (13:25 +0800)]
Update compiler-rt to fix MIPS64 infinite recursion

Fixes #37823.

7 years agoAuto merge of #37895 - jseyfried:fix_proc_macro_deps, r=nrc
bors [Mon, 21 Nov 2016 06:16:51 +0000 (00:16 -0600)]
Auto merge of #37895 - jseyfried:fix_proc_macro_deps, r=nrc

Fix bug involving proc-macro dependencies

Fixes #37893.
r? @nrc

7 years agoMove `syntax::util::interner` -> `syntax::symbol`, cleanup.
Jeffrey Seyfried [Wed, 16 Nov 2016 08:21:52 +0000 (08:21 +0000)]
Move `syntax::util::interner` -> `syntax::symbol`, cleanup.

7 years agoAuto merge of #37888 - bluss:chars-count, r=alexcrichton
bors [Sun, 20 Nov 2016 23:06:53 +0000 (17:06 -0600)]
Auto merge of #37888 - bluss:chars-count, r=alexcrichton

Improve .chars().count()

Use a simpler loop to count the `char` of a string: count the
number of non-continuation bytes. Use `count += <conditional>` which the
compiler understands well and can apply loop optimizations to.

benchmark descriptions and results for two configurations:

- ascii: ascii text
- cy: cyrillic text
- jp: japanese text
- words ascii: counting each split_whitespace item from the ascii text
- words jp: counting each split_whitespace item from the jp text

```
x86-64 rustc -Copt-level=3
 name               orig_ ns/iter      cmov_ ns/iter      diff ns/iter   diff %
 count_ascii        1,453 (1755 MB/s)  1,398 (1824 MB/s)           -55   -3.79%
 count_cy           5,990 (856 MB/s)   2,545 (2016 MB/s)        -3,445  -57.51%
 count_jp           3,075 (1169 MB/s)  1,772 (2029 MB/s)        -1,303  -42.37%
 count_words_ascii  4,157 (521 MB/s)   1,797 (1205 MB/s)        -2,360  -56.77%
 count_words_jp     3,337 (1071 MB/s)  1,772 (2018 MB/s)        -1,565  -46.90%

x86-64 rustc -Ctarget-feature=+avx -Copt-level=3
 name               orig_ ns/iter      cmov_ ns/iter      diff ns/iter   diff %
 count_ascii        1,444 (1766 MB/s)  763 (3343 MB/s)            -681  -47.16%
 count_cy           5,871 (874 MB/s)   1,527 (3360 MB/s)        -4,344  -73.99%
 count_jp           2,874 (1251 MB/s)  1,073 (3351 MB/s)        -1,801  -62.67%
 count_words_ascii  4,131 (524 MB/s)   1,871 (1157 MB/s)        -2,260  -54.71%
 count_words_jp     3,253 (1099 MB/s)  1,331 (2686 MB/s)        -1,922  -59.08%
```

I briefly explored a more involved blocked algorithm (looking at 8 or more bytes at a time),
but the code in this PR was always winning `count_words_ascii` in particular (counting
many small strings); this solution is an improvement without tradeoffs.

7 years agosupport creation of anonymous pipe on WinXP/2K3
jsen- [Thu, 10 Nov 2016 01:00:25 +0000 (02:00 +0100)]
support creation of anonymous pipe on WinXP/2K3

7 years agoAuto merge of #37862 - shepmaster:llvm-4.0-always-set-eh-personality, r=eddyb
bors [Sun, 20 Nov 2016 19:50:47 +0000 (13:50 -0600)]
Auto merge of #37862 - shepmaster:llvm-4.0-always-set-eh-personality, r=eddyb

[LLVM 4.0] Set EH personality when resuming stack unwinding

To resume stack unwinding, the LLVM `resume` instruction must be used.

In order to use this instruction, the calling function must have an
exception handling personality set.

LLVM 4.0 adds a new IR validation check to ensure a personality is
always set in these cases.

This was introduced in [r277360](https://reviews.llvm.org/rL277360).

7 years agoTests
Nick Cameron [Thu, 10 Nov 2016 05:29:27 +0000 (18:29 +1300)]
Tests

7 years agoRead in rmeta crates
Nick Cameron [Thu, 10 Nov 2016 02:57:30 +0000 (15:57 +1300)]
Read in rmeta crates

7 years agoAdd --crate-type metadata
Nick Cameron [Tue, 25 Oct 2016 22:14:02 +0000 (11:14 +1300)]
Add --crate-type metadata

With the same semantics as -Zno-trans