]> git.lizzy.rs Git - rust.git/log
rust.git
6 years agoAuto merge of #45771 - petrochenkov:crate, r=nikomatsakis
bors [Tue, 21 Nov 2017 12:32:59 +0000 (12:32 +0000)]
Auto merge of #45771 - petrochenkov:crate, r=nikomatsakis

Support `::crate` in paths

cc https://github.com/rust-lang/rust/issues/45477
Fixes https://github.com/rust-lang/rust/issues/45229

6 years agoAuto merge of #45701 - cramertj:impl-trait-this-time, r=eddyb
bors [Tue, 21 Nov 2017 10:00:18 +0000 (10:00 +0000)]
Auto merge of #45701 - cramertj:impl-trait-this-time, r=eddyb

impl Trait Lifetime Handling

This PR implements the updated strategy for handling `impl Trait` lifetimes, as described in [RFC 1951](https://github.com/rust-lang/rfcs/blob/master/text/1951-expand-impl-trait.md) (cc #42183).

With this PR, the `impl Trait` desugaring works as follows:
```rust
fn foo<T, 'a, 'b, 'c>(...) -> impl Foo<'a, 'b> { ... }
// desugars to
exists type MyFoo<ParentT, 'parent_a, 'parent_b, 'parent_c, 'a, 'b>: Foo<'a, 'b>;
fn foo<T, 'a, 'b, 'c>(...) -> MyFoo<T, 'static, 'static, 'static, 'a, 'b> { ... }
```
All of the in-scope (parent) generics are listed as parent generics of the anonymous type, with parent regions being replaced by `'static`. Parent regions referenced in the `impl Trait` return type are duplicated into the anonymous type's generics and mapped appropriately.

One case came up that wasn't specified in the RFC: it's possible to write a return type that contains multiple regions, neither of which outlives the other. In that case, it's not clear what the required lifetime of the output type should be, so we generate an error.

There's one remaining FIXME in one of the tests: `-> impl Foo<'a, 'b> + 'c` should be able to outlive both `'a` and `'b`, but not `'c`. Currently, it can't outlive any of them. @nikomatsakis and I have discussed this, and there are some complex interactions here if we ever allow `impl<'a, 'b> SomeTrait for AnonType<'a, 'b> { ... }`, so the plan is to hold off on this until we've got a better idea of what the interactions are here.

cc #34511.
Fixes #44727.

6 years agoAuto merge of #45545 - durka:macro-backtrace, r=nrc
bors [Tue, 21 Nov 2017 06:42:14 +0000 (06:42 +0000)]
Auto merge of #45545 - durka:macro-backtrace, r=nrc

show macro backtrace with -Z flag

Fixes #39413 by adding a facility to restore the "old school" macro expansion backtraces (previously removed in https://github.com/rust-lang/rust/commit/61865384b8fa6d79d2b36cbd7c899eaf15f4aeea).

The restored functionality is accessed through the flag `-Z external-macro-backtrace`. Errors showing the truncated backtraces will suggest this flag.

### Example

Code: <details>
`a/src/lib.rs`
```rust
#[macro_export]
macro_rules! a {
    () => { a!(@) };
    (@) => { a!(@@) };
    (@@) => {
        syntax error;
    }
}
```
`b/src/main.rs`
```rust
#[macro_use] extern crate a;

macro_rules! b {
    () => { b!(@) };
    (@) => { b!(@@) };
    (@@) => {
        syntax error;
    }
}

fn main() {
    a!();
    b!();
}
```
</details>

<br/><br/>
Running without env var (note: first error is from remote macro, second from local macro):

<details>

```
$ cargo +custom run
   Compiling b v0.1.0
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `error`
  --> src/main.rs:12:5
   |
12 |     a!();
   |     ^^^^^
   |     |
   |     expected one of 8 possible tokens here
   |     unexpected token
   |
   = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info)

error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `error`
  --> src/main.rs:7:16
   |
7  |         syntax error;
   |               -^^^^^ unexpected token
   |               |
   |               expected one of 8 possible tokens here
...
13 |     b!();
   |     ----- in this macro invocation

error: aborting due to 2 previous errors

error: Could not compile `b`.

To learn more, run the command again with --verbose.
```
</details>
The output is the same as today, except for an addition to the note which aids discoverability of the new environment variable.

<br/><br/>
Running _with_ env var:
<details>

```
$ RUST_MACRO_BACKTRACE=1 cargo +custom run
   Compiling b v0.1.0
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `error`
 --> <a macros>:1:72
  |
1 | (  ) => { a ! ( @ ) } ; ( @ ) => { a ! ( @ @ ) } ; ( @ @ ) => { syntax error ;
  |                                                                       -^^^^^ unexpected token
  |                                                                       |
  |                                                                       expected one of 8 possible tokens here
src/main.rs:12:5: 12:10 note: in this expansion of a! (defined in <a macros>)
<a macros>:1:11: 1:20 note: in this expansion of a! (defined in <a macros>)
<a macros>:1:36: 1:47 note: in this expansion of a! (defined in <a macros>)

error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `error`
 --> src/main.rs:7:16
  |
7 |         syntax error;
  |               -^^^^^ unexpected token
  |               |
  |               expected one of 8 possible tokens here
src/main.rs:12:5: 12:10 note: in this expansion of a! (defined in <a macros>)
<a macros>:1:11: 1:20 note: in this expansion of a! (defined in <a macros>)
<a macros>:1:36: 1:47 note: in this expansion of a! (defined in <a macros>)

error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `error`
 --> src/main.rs:7:16
  |
7 |         syntax error;
  |               -^^^^^ unexpected token
  |               |
  |               expected one of 8 possible tokens here
src/main.rs:13:5: 13:10 note: in this expansion of b! (defined in src/main.rs)
src/main.rs:4:13: 4:18 note: in this expansion of b! (defined in src/main.rs)
src/main.rs:5:14: 5:20 note: in this expansion of b! (defined in src/main.rs)

error: aborting due to 2 previous errors

error: Could not compile `b`.

To learn more, run the command again with --verbose.
```
</details>

The output is hard to read, but better than nothing (and it's exactly what we used to have before the infamous `fix_multispans_in_std_macros`).

<br/><br/>
Wishlist:

- Save the actual source of macros in crate metadata, not just AST, so the output can be improved
    - Hopefully this would allow line numbers in the trace as well
- Show the actual macro invocations in the traces

r? @nrc

6 years agoAuto merge of #45039 - QuietMisdreavus:doc-spotlight, r=GuillaumeGomez,QuietMisdreavus
bors [Tue, 21 Nov 2017 03:03:28 +0000 (03:03 +0000)]
Auto merge of #45039 - QuietMisdreavus:doc-spotlight, r=GuillaumeGomez,QuietMisdreavus

show in docs whether the return type of a function impls Iterator/Read/Write

Closes #25928

This PR makes it so that when rustdoc documents a function, it checks the return type to see whether it implements a handful of specific traits. If so, it will print the impl and any associated types. Rather than doing this via a whitelist within rustdoc, i chose to do this by a new `#[doc]` attribute parameter, so things like `Future` could tap into this if desired.

### Known shortcomings

~~The printing of impls currently uses the `where` class over the whole thing to shrink the font size relative to the function definition itself. Naturally, when the impl has a where clause of its own, it gets shrunken even further:~~ (This is no longer a problem because the design changed and rendered this concern moot.)

The lookup currently just looks at the top-level type, not looking inside things like Result or Option, which renders the spotlights on Read/Write a little less useful:

<details><summary>`File::{open, create}` don't have spotlight info (pic of old design)</summary>

![image](https://user-images.githubusercontent.com/5217170/31209495-e59d027e-a950-11e7-9998-ceefceb71c07.png)

</details>

All three of the initially spotlighted traits are generically implemented on `&mut` references. Rustdoc currently treats a `&mut T` reference-to-a-generic as an impl on the reference primitive itself. `&mut Self` counts as a generic in the eyes of rustdoc. All this combines to create this lovely scene on `Iterator::by_ref`:

<details><summary>`Iterator::by_ref` spotlights Iterator, Read, and Write (pic of old design)</summary>

![image](https://user-images.githubusercontent.com/5217170/31209554-50b271ca-a951-11e7-928b-4f83416c8681.png)

</details>

6 years agoAuto merge of #46130 - kennytm:rollup, r=kennytm
bors [Mon, 20 Nov 2017 22:35:41 +0000 (22:35 +0000)]
Auto merge of #46130 - kennytm:rollup, r=kennytm

Rollup of 9 pull requests

- Successful merges: #46082, #46088, #46092, #46107, #46119, #46121, #46122, #46124, #46128
- Failed merges:

6 years agoReport special messages for path segment keywords in wrong positions
Vadim Petrochenkov [Sun, 19 Nov 2017 14:05:29 +0000 (17:05 +0300)]
Report special messages for path segment keywords in wrong positions

6 years agoSupport `::crate` in paths
Vadim Petrochenkov [Sat, 4 Nov 2017 20:56:45 +0000 (23:56 +0300)]
Support `::crate` in paths

6 years agoRollup merge of #46128 - Coding-Doctors:patch-1, r=dtolnay
kennytm [Mon, 20 Nov 2017 19:14:49 +0000 (03:14 +0800)]
Rollup merge of #46128 - Coding-Doctors:patch-1, r=dtolnay

Fix doc tests for trim_right_matches

First pr, but isn't anything big so hopefully it should all be good.

6 years agoRollup merge of #46124 - rkruppe:no-llvm_unreachable, r=arielb1
kennytm [Mon, 20 Nov 2017 19:14:48 +0000 (03:14 +0800)]
Rollup merge of #46124 - rkruppe:no-llvm_unreachable, r=arielb1

[rustllvm] Use report_fatal_error over llvm_unreachable

This makes it more robust when assertions are disabled, crashing instead of causing UB.

Also introduces a tidy check to enforce this rule, which in turn necessitated making tidy run on `src/rustllvm`.

Fixes #44020

6 years agoRollup merge of #46122 - malbarbo:docs, r=steveklabnik
kennytm [Mon, 20 Nov 2017 19:14:47 +0000 (03:14 +0800)]
Rollup merge of #46122 - malbarbo:docs, r=steveklabnik

Fix some docs summary nits

6 years agoRollup merge of #46121 - malbarbo:rc_arc_pointer, r=dtolnay
kennytm [Mon, 20 Nov 2017 19:14:46 +0000 (03:14 +0800)]
Rollup merge of #46121 - malbarbo:rc_arc_pointer, r=dtolnay

Print the address of the pointed value in Pointer impl for Rc and Arc

Fixes https://github.com/rust-lang/rust/issues/35384

6 years agoRollup merge of #46119 - ritiek:master, r=arielb1
kennytm [Mon, 20 Nov 2017 19:14:45 +0000 (03:14 +0800)]
Rollup merge of #46119 - ritiek:master, r=arielb1

Fix typo in MIR "cannot move out of borrowed content"

I believe this all we need to change (#46018). Anyway, do let me know if there is anything else that needs to changed as well!

6 years agoRollup merge of #46107 - nyanzebra:develop, r=kennytm
kennytm [Mon, 20 Nov 2017 19:14:44 +0000 (03:14 +0800)]
Rollup merge of #46107 - nyanzebra:develop, r=kennytm

Fixes spelling error in COMPILER_TESTS.md

Fixes a small spelling mistake :P

6 years agoRollup merge of #46092 - sfackler:ppid, r=alexcrichton
kennytm [Mon, 20 Nov 2017 19:14:43 +0000 (03:14 +0800)]
Rollup merge of #46092 - sfackler:ppid, r=alexcrichton

Add process::parent_id

I have this as a Unix-only API since it seems like Windows doesn't have
a similar API.

r? @alexcrichton

6 years agoRollup merge of #46088 - vitiral:read_doc, r=steveklabnik
kennytm [Mon, 20 Nov 2017 19:14:42 +0000 (03:14 +0800)]
Rollup merge of #46088 - vitiral:read_doc, r=steveklabnik

add doc for doing `Read` from `&str`

This information can be found on [stackoverflow](https://stackoverflow.com/questions/32674905/pass-string-to-function-taking-read-trait) but I think it would be beneficial if it was documented in the `Read` trait itself.

I had an *extremely* hard time finding this information, and "mocking" a reader with a string is an EXTREMELY common thing (I believe).

6 years agoRollup merge of #46082 - Enet4:mutex_from, r=sfackler
kennytm [Mon, 20 Nov 2017 19:14:41 +0000 (03:14 +0800)]
Rollup merge of #46082 - Enet4:mutex_from, r=sfackler

impl From for Mutex and RwLock

I felt that these implementations were missing, because doing `x.into()` works for other smart containers (such as `RefCell`), and in general I would say that the conversion makes sense.

6 years agoFix result for assert_eq
Benjamin Hoffmeyer [Mon, 20 Nov 2017 18:47:42 +0000 (13:47 -0500)]
Fix result for assert_eq

6 years agoFix doc tests for trim_right_matches
Benjamin Hoffmeyer [Mon, 20 Nov 2017 18:37:56 +0000 (13:37 -0500)]
Fix doc tests for trim_right_matches

6 years agoaddress review comments
Alex Burka [Mon, 20 Nov 2017 18:03:20 +0000 (18:03 +0000)]
address review comments

6 years agoClippy is broken
Taylor Cramer [Mon, 20 Nov 2017 17:52:09 +0000 (09:52 -0800)]
Clippy is broken

6 years agoPrint the address of the pointed value in Pointer impl for Rc and Arc
Marco A L Barbosa [Mon, 20 Nov 2017 16:41:53 +0000 (14:41 -0200)]
Print the address of the pointed value in Pointer impl for Rc and Arc

6 years agoAuto merge of #46110 - steveklabnik:update-books, r=steveklabnik
bors [Mon, 20 Nov 2017 17:26:26 +0000 (17:26 +0000)]
Auto merge of #46110 - steveklabnik:update-books, r=steveklabnik

Update books for next release

Since I was out last week I didn't get this done as early as usual, I don't know if beta has branched already or not.

6 years ago[rustllvm] Use report_fatal_error over llvm_unreachable
Robin Kruppe [Mon, 20 Nov 2017 16:47:29 +0000 (17:47 +0100)]
[rustllvm] Use report_fatal_error over llvm_unreachable

This makes it more robust when assertions are disabled,
crashing instead of causing UB.

Also introduces a tidy check to enforce this rule,
which in turn necessitated making tidy run on src/rustllvm.

Fixes #44020

6 years agoFix some docs summary nits
Marco A L Barbosa [Fri, 6 Oct 2017 14:41:04 +0000 (11:41 -0300)]
Fix some docs summary nits

6 years agoFix typo in MRI "cannot move out of borrowed content"
Ritiek Malhotra [Mon, 20 Nov 2017 15:56:21 +0000 (21:26 +0530)]
Fix typo in MRI "cannot move out of borrowed content"

6 years agoAuto merge of #45645 - fhartwig:39550, r=QuietMisdreavus
bors [Mon, 20 Nov 2017 14:47:40 +0000 (14:47 +0000)]
Auto merge of #45645 - fhartwig:39550, r=QuietMisdreavus

Make rustdoc not include self-by-value methods from Deref target

Fixes #39550

6 years agoUpdate books for next release
steveklabnik [Mon, 20 Nov 2017 11:19:25 +0000 (06:19 -0500)]
Update books for next release

Also includes a fix in std::ops

6 years agoAuto merge of #45998 - ollie27:doc_book_css, r=steveklabnik
bors [Mon, 20 Nov 2017 12:10:14 +0000 (12:10 +0000)]
Auto merge of #45998 - ollie27:doc_book_css, r=steveklabnik

Fix broken CSS for book redirect pages

rust.css has to be next to the font files so we shouldn't copy it for
only the book redirect pages, instead just use the version that is
already there.

This also removes the duplicate code creating version_info.html.

Fixes: #45974
6 years agoAuto merge of #45905 - alexcrichton:add-wasm-target, r=aturon
bors [Mon, 20 Nov 2017 08:29:46 +0000 (08:29 +0000)]
Auto merge of #45905 - alexcrichton:add-wasm-target, r=aturon

std: Add a new wasm32-unknown-unknown target

This commit adds a new target to the compiler: wasm32-unknown-unknown. This target is a reimagining of what it looks like to generate WebAssembly code from Rust. Instead of using Emscripten which can bring with it a weighty runtime this instead is a target which uses only the LLVM backend for WebAssembly and a "custom linker" for now which will hopefully one day be direct calls to lld.

Notable features of this target include:

* There is zero runtime footprint. The target assumes nothing exists other than the wasm32 instruction set.
* There is zero toolchain footprint beyond adding the target. No custom linker is needed, rustc contains everything.
* Very small wasm modules can be generated directly from Rust code using this target.
* Most of the standard library is stubbed out to return an error, but anything related to allocation works (aka `HashMap`, `Vec`, etc).
* Naturally, any `#[no_std]` crate should be 100% compatible with this new target.

This target is currently somewhat janky due to how linking works. The "linking" is currently unconditional whole program LTO (aka LLVM is being used as a linker). Naturally that means compiling programs is pretty slow! Eventually though this target should have a linker.

This target is also intended to be quite experimental. I'm hoping that this can act as a catalyst for further experimentation in Rust with WebAssembly. Breaking changes are very likely to land to this target, so it's not recommended to rely on it in any critical capacity yet. We'll let you know when it's "production ready".

### Building yourself

First you'll need to configure the build of LLVM and enable this target

```
$ ./configure --target=wasm32-unknown-unknown --set llvm.experimental-targets=WebAssembly
```

Next you'll want to remove any previously compiled LLVM as it needs to be rebuilt with WebAssembly support. You can do that with:

```
$ rm -rf build
```

And then you're good to go! A `./x.py build` should give you a rustc with the appropriate libstd target.

### Test support

Currently testing-wise this target is looking pretty good but isn't complete. I've got almost the entire `run-pass` test suite working with this target (lots of tests ignored, but many passing as well). The `core` test suite is [still getting LLVM bugs fixed](https://reviews.llvm.org/D39866) to get that working and will take some time. Relatively simple programs all seem to work though!

In general I've only tested this with a local fork that makes use of LLVM 5 rather than our current LLVM 4 on master. The LLVM 4 WebAssembly backend AFAIK isn't broken per se but is likely missing bug fixes available on LLVM 5. I'm hoping though that we can decouple the LLVM 5 upgrade and adding this wasm target!

### But the modules generated are huge!

It's worth nothing that you may not immediately see the "smallest possible wasm module" for the input you feed to rustc. For various reasons it's very difficult to get rid of the final "bloat" in vanilla rustc (again, a real linker should fix all this). For now what you'll have to do is:

    cargo install --git https://github.com/alexcrichton/wasm-gc
    wasm-gc foo.wasm bar.wasm

And then `bar.wasm` should be the smallest we can get it!

---

In any case for now I'd love feedback on this, particularly on the various integration points if you've got better ideas of how to approach them!

6 years agoAuto merge of #45819 - Havvy:cell, r=aturon
bors [Mon, 20 Nov 2017 05:58:23 +0000 (05:58 +0000)]
Auto merge of #45819 - Havvy:cell, r=aturon

Add RefCell<T>::replace_with

I also moved the `Panic` sections to before examples in the other two functions also under this feature gate, and changed the variable names in `replace` to be more readable.

r? @rust-libs

6 years agostd: Add a new wasm32-unknown-unknown target
Alex Crichton [Mon, 23 Oct 2017 03:01:00 +0000 (20:01 -0700)]
std: Add a new wasm32-unknown-unknown target

This commit adds a new target to the compiler: wasm32-unknown-unknown. This
target is a reimagining of what it looks like to generate WebAssembly code from
Rust. Instead of using Emscripten which can bring with it a weighty runtime this
instead is a target which uses only the LLVM backend for WebAssembly and a
"custom linker" for now which will hopefully one day be direct calls to lld.

Notable features of this target include:

* There is zero runtime footprint. The target assumes nothing exists other than
  the wasm32 instruction set.
* There is zero toolchain footprint beyond adding the target. No custom linker
  is needed, rustc contains everything.
* Very small wasm modules can be generated directly from Rust code using this
  target.
* Most of the standard library is stubbed out to return an error, but anything
  related to allocation works (aka `HashMap`, `Vec`, etc).
* Naturally, any `#[no_std]` crate should be 100% compatible with this new
  target.

This target is currently somewhat janky due to how linking works. The "linking"
is currently unconditional whole program LTO (aka LLVM is being used as a
linker). Naturally that means compiling programs is pretty slow! Eventually
though this target should have a linker.

This target is also intended to be quite experimental. I'm hoping that this can
act as a catalyst for further experimentation in Rust with WebAssembly. Breaking
changes are very likely to land to this target, so it's not recommended to rely
on it in any critical capacity yet. We'll let you know when it's "production
ready".

---

Currently testing-wise this target is looking pretty good but isn't complete.
I've got almost the entire `run-pass` test suite working with this target (lots
of tests ignored, but many passing as well). The `core` test suite is still
getting LLVM bugs fixed to get that working and will take some time. Relatively
simple programs all seem to work though!

---

It's worth nothing that you may not immediately see the "smallest possible wasm
module" for the input you feed to rustc. For various reasons it's very difficult
to get rid of the final "bloat" in vanilla rustc (again, a real linker should
fix all this). For now what you'll have to do is:

    cargo install --git https://github.com/alexcrichton/wasm-gc
    wasm-gc foo.wasm bar.wasm

And then `bar.wasm` should be the smallest we can get it!

---

In any case for now I'd love feedback on this, particularly on the various
integration points if you've got better ideas of how to approach them!

6 years agoAuto merge of #46068 - wesleywiser:incr_duplicate_read_stats, r=michaelwoerister
bors [Mon, 20 Nov 2017 03:34:13 +0000 (03:34 +0000)]
Auto merge of #46068 - wesleywiser:incr_duplicate_read_stats, r=michaelwoerister

[incremental] Collect stats about duplicated edge reads from queries

Part of #45873

6 years agoFixes spelling error in COMPILER_TESTS.md
Robert T Baldwin [Mon, 20 Nov 2017 02:59:00 +0000 (18:59 -0800)]
Fixes spelling error in COMPILER_TESTS.md

6 years agotidy 😡
Alex Burka [Mon, 20 Nov 2017 01:23:44 +0000 (01:23 +0000)]
tidy ðŸ˜¡

6 years agobreak rustfmt
Alex Burka [Mon, 20 Nov 2017 01:01:09 +0000 (01:01 +0000)]
break rustfmt

6 years agoMake rustdoc not include self-by-value methods from Deref target
Florian Hartwig [Tue, 31 Oct 2017 01:01:23 +0000 (02:01 +0100)]
Make rustdoc not include self-by-value methods from Deref target

6 years agouse -Z flag instead of env var
Alex Burka [Sat, 18 Nov 2017 20:16:10 +0000 (20:16 +0000)]
use -Z flag instead of env var

6 years agoupdate UI tests
Alex Burka [Fri, 27 Oct 2017 12:32:23 +0000 (12:32 +0000)]
update UI tests

6 years agoadd UI test
Alex Burka [Fri, 27 Oct 2017 04:50:54 +0000 (04:50 +0000)]
add UI test

6 years agoshow macro backtrace with env var
Alex Burka [Thu, 26 Oct 2017 04:39:37 +0000 (04:39 +0000)]
show macro backtrace with env var

6 years agoAuto merge of #45225 - eddyb:trans-abi, r=arielb1
bors [Sun, 19 Nov 2017 22:12:22 +0000 (22:12 +0000)]
Auto merge of #45225 - eddyb:trans-abi, r=arielb1

Refactor type memory layouts and ABIs, to be more general and easier to optimize.

To combat combinatorial explosion, type layouts are now described through 3 orthogonal properties:
* `Variants` describes the plurality of sum types (where applicable)
  * `Single` is for one inhabited/active variant, including all C `struct`s and `union`s
  * `Tagged` has its variants discriminated by an integer tag, including C `enum`s
  * `NicheFilling` uses otherwise-invalid values ("niches") for all but one of its inhabited variants
* `FieldPlacement` describes the number and memory offsets of fields (if any)
  * `Union` has all its fields at offset `0`
  * `Array` has offsets that are a multiple of its `stride`; guarantees all fields have one type
  * `Arbitrary` records all the field offsets, which can be out-of-order
* `Abi` describes how values of the type should be passed around, including for FFI
  * `Uninhabited` corresponds to no values, associated with unreachable control-flow
  * `Scalar` is ABI-identical to its only integer/floating-point/pointer "scalar component"
  * `ScalarPair` has two "scalar components", but only applies to the Rust ABI
  * `Vector` is for SIMD vectors, typically `#[repr(simd)]` `struct`s in Rust
  * `Aggregate` has arbitrary contents, including all non-transparent C `struct`s and `union`s

Size optimizations implemented so far:
* ignoring uninhabited variants (i.e. containing uninhabited fields), e.g.:
  * `Option<!>` is 0 bytes
  * `Result<T, !>` has the same size as `T`
* using arbitrary niches, not just `0`, to represent a data-less variant, e.g.:
  * `Option<bool>`, `Option<Option<bool>>`, `Option<Ordering>` are all 1 byte
  * `Option<char>` is 4 bytes
* using a range of niches to represent *multiple* data-less variants, e.g.:
  * `enum E { A(bool), B, C, D }` is 1 byte

Code generation now takes advantage of `Scalar` and `ScalarPair` to, in more cases, pass around scalar components as immediates instead of indirectly, through pointers into temporary memory, while avoiding LLVM's "first-class aggregates", and there's more untapped potential here.

Closes #44426, fixes #5977, fixes #14540, fixes #43278.

6 years agoRevert "tests: Update run-make/issue-25581 to reflect how fat pointers are passed."
Eduard-Mihai Burtescu [Sun, 19 Nov 2017 21:38:48 +0000 (23:38 +0200)]
Revert "tests: Update run-make/issue-25581 to reflect how fat pointers are passed."

This reverts commit b12dcdef4fae5e3856e6911fd6cfbeedadcf3821.

6 years agoAdd process::parent_id
Steven Fackler [Sun, 19 Nov 2017 05:09:18 +0000 (21:09 -0800)]
Add process::parent_id

I have this as a Unix-only API since it seems like Windows doesn't have
a similar API.

6 years agorustc_trans: remove primitive_align optimization.
Eduard-Mihai Burtescu [Sun, 19 Nov 2017 18:28:52 +0000 (20:28 +0200)]
rustc_trans: remove primitive_align optimization.

6 years agoAuto merge of #45454 - Aaronepower:master, r=alexcrichton
bors [Sun, 19 Nov 2017 17:23:01 +0000 (17:23 +0000)]
Auto merge of #45454 - Aaronepower:master, r=alexcrichton

Updated Release notes for 1.22.0

[rendered](https://github.com/Aaronepower/rust/blob/master/RELEASES.md)

6 years agoRemove some trailing whitespace.
Michael Woerister [Sun, 19 Nov 2017 16:26:19 +0000 (17:26 +0100)]
Remove some trailing whitespace.

6 years agoFix tidy line-length issue.
Michael Woerister [Sun, 19 Nov 2017 16:12:04 +0000 (17:12 +0100)]
Fix tidy line-length issue.

6 years agorustc_trans: work around i686-pc-windows-msvc byval align LLVM bug.
Eduard-Mihai Burtescu [Sun, 19 Nov 2017 10:13:24 +0000 (12:13 +0200)]
rustc_trans: work around i686-pc-windows-msvc byval align LLVM bug.

6 years agoAuto merge of #46074 - scottmcm:unspecialize-nth, r=bluss
bors [Sun, 19 Nov 2017 12:20:14 +0000 (12:20 +0000)]
Auto merge of #46074 - scottmcm:unspecialize-nth, r=bluss

Undo the Sized specialization from Iterator::nth

I just added this as part of https://github.com/rust-lang/rust/pull/45595, but I'm now afraid there's a specialization issue with it, since I tried to add [another similar specialization](https://github.com/rust-lang/rust/compare/master...scottmcm:faster-iter-by-ref?expand=1#diff-1398f322bc563592215b583e9b0ba936R2390), and ended up getting really disturbing test failures like
```
thread 'iter::test_by_ref_folds' panicked at 'assertion failed: `(left == right)`
  left: `15`,
 right: `15`', src\libcore\../libcore/tests\iter.rs:1720:4
```

So since this wasn't the most critical part of the change and a new beta is branching within a week, I think putting this part back to what it was before is the best option.

6 years agocargotest: temporarily use eddyb/servo to include servo/servo#19285.
Eduard-Mihai Burtescu [Sun, 19 Nov 2017 09:48:12 +0000 (11:48 +0200)]
cargotest: temporarily use eddyb/servo to include servo/servo#19285.

6 years agoDon't glob-import overlapping variant names in test/codegen/match-optimizes-away.rs.
Eduard-Mihai Burtescu [Sat, 18 Nov 2017 13:41:07 +0000 (15:41 +0200)]
Don't glob-import overlapping variant names in test/codegen/match-optimizes-away.rs.

6 years agoAuto merge of #46064 - Keruspe:master, r=sfackler
bors [Sun, 19 Nov 2017 05:19:10 +0000 (05:19 +0000)]
Auto merge of #46064 - Keruspe:master, r=sfackler

update openssl{,-sys} to fix build with libressl 2.6.x

6 years agoAuto merge of #46048 - cramertj:update-libc-2, r=alexcrichton
bors [Sun, 19 Nov 2017 03:02:15 +0000 (03:02 +0000)]
Auto merge of #46048 - cramertj:update-libc-2, r=alexcrichton

Update libc to include Fuchsia changes

This is an update of libc to include the updated Fuchsia "open" flags added in https://github.com/rust-lang/libc/pull/849.

cc @smklein
r? @alexcrichton

6 years agorustc_trans: (hack) use preferred alignment for atomic loads/stores.
Eduard-Mihai Burtescu [Sun, 19 Nov 2017 01:56:37 +0000 (03:56 +0200)]
rustc_trans: (hack) use preferred alignment for atomic loads/stores.

6 years agorustc: rename CachedLayout to LayoutDetails.
Eduard-Mihai Burtescu [Sat, 28 Oct 2017 13:52:41 +0000 (16:52 +0300)]
rustc: rename CachedLayout to LayoutDetails.

6 years agorustc: extend the niche-filling enum optimization past 2 variants.
Eduard-Mihai Burtescu [Thu, 12 Oct 2017 00:55:49 +0000 (03:55 +0300)]
rustc: extend the niche-filling enum optimization past 2 variants.

6 years agorustc: use layout::Abi::ScalarPair for structs in more cases.
Eduard-Mihai Burtescu [Tue, 10 Oct 2017 20:38:07 +0000 (23:38 +0300)]
rustc: use layout::Abi::ScalarPair for structs in more cases.

6 years agorustc_trans: remove type_is_fat_ptr and its uses.
Eduard-Mihai Burtescu [Tue, 10 Oct 2017 19:04:13 +0000 (22:04 +0300)]
rustc_trans: remove type_is_fat_ptr and its uses.

6 years agorustc: don't special-case Box<T> as having a pointer layout.
Eduard-Mihai Burtescu [Tue, 10 Oct 2017 17:55:21 +0000 (20:55 +0300)]
rustc: don't special-case Box<T> as having a pointer layout.

6 years agorustc_trans: support scalar pairs directly in the Rust ABI.
Eduard-Mihai Burtescu [Tue, 10 Oct 2017 17:54:50 +0000 (20:54 +0300)]
rustc_trans: support scalar pairs directly in the Rust ABI.

6 years agorustc: unpack scalar pair newtype layout ABIs.
Eduard-Mihai Burtescu [Mon, 9 Oct 2017 16:56:41 +0000 (19:56 +0300)]
rustc: unpack scalar pair newtype layout ABIs.

6 years agorustc: unpack scalar newtype layout ABIs.
Eduard-Mihai Burtescu [Sun, 8 Oct 2017 23:31:06 +0000 (02:31 +0300)]
rustc: unpack scalar newtype layout ABIs.

6 years agorustc_trans: be more relaxed with non-lvalue consumes, especially ZSTs.
Eduard-Mihai Burtescu [Sun, 8 Oct 2017 21:38:10 +0000 (00:38 +0300)]
rustc_trans: be more relaxed with non-lvalue consumes, especially ZSTs.

6 years agorustc: place ZSTs first during struct field reordering.
Eduard-Mihai Burtescu [Sun, 8 Oct 2017 20:08:47 +0000 (23:08 +0300)]
rustc: place ZSTs first during struct field reordering.

6 years agorustc: encode scalar pairs in layout ABI.
Eduard-Mihai Burtescu [Fri, 6 Oct 2017 07:25:35 +0000 (10:25 +0300)]
rustc: encode scalar pairs in layout ABI.

6 years agorustc_trans: restrict "immediate pairs" to pairs of scalars.
Eduard-Mihai Burtescu [Thu, 5 Oct 2017 01:22:23 +0000 (04:22 +0300)]
rustc_trans: restrict "immediate pairs" to pairs of scalars.

6 years agorustc_trans: generate LLVM pointee types based on alignment.
Eduard-Mihai Burtescu [Wed, 4 Oct 2017 23:21:10 +0000 (02:21 +0300)]
rustc_trans: generate LLVM pointee types based on alignment.

6 years agorustc_trans: compute better align/dereferenceable attributes from pointees.
Eduard-Mihai Burtescu [Tue, 3 Oct 2017 07:45:07 +0000 (10:45 +0300)]
rustc_trans: compute better align/dereferenceable attributes from pointees.

6 years agorustc: optimize out uninhabited types and variants.
Eduard-Mihai Burtescu [Tue, 26 Sep 2017 18:34:10 +0000 (21:34 +0300)]
rustc: optimize out uninhabited types and variants.

6 years agorustc: track validity ranges for layout::Abi::Scalar values.
Eduard-Mihai Burtescu [Tue, 26 Sep 2017 11:41:06 +0000 (14:41 +0300)]
rustc: track validity ranges for layout::Abi::Scalar values.

6 years agorustc: remove redundant/unused fields from layout::Abi::Vector.
Eduard-Mihai Burtescu [Tue, 26 Sep 2017 04:27:48 +0000 (07:27 +0300)]
rustc: remove redundant/unused fields from layout::Abi::Vector.

6 years agorustc: generalize layout::Variants::NicheFilling to niches other than 0.
Eduard-Mihai Burtescu [Sun, 24 Sep 2017 09:12:26 +0000 (12:12 +0300)]
rustc: generalize layout::Variants::NicheFilling to niches other than 0.

6 years agorustc_trans: check for layout::I1 instead of TyBool.
Eduard-Mihai Burtescu [Sun, 24 Sep 2017 09:01:09 +0000 (12:01 +0300)]
rustc_trans: check for layout::I1 instead of TyBool.

6 years agorustc: make TyLayout::field(NonZero<*T>, 0) return &T.
Eduard-Mihai Burtescu [Sun, 24 Sep 2017 08:56:23 +0000 (11:56 +0300)]
rustc: make TyLayout::field(NonZero<*T>, 0) return &T.

6 years agorustc: support u128 discriminant ranges.
Eduard-Mihai Burtescu [Sat, 23 Sep 2017 12:04:37 +0000 (15:04 +0300)]
rustc: support u128 discriminant ranges.

6 years agorustc: collapse the remains of Layout into Variants (enums vs everything else).
Eduard-Mihai Burtescu [Fri, 22 Sep 2017 22:54:45 +0000 (01:54 +0300)]
rustc: collapse the remains of Layout into Variants (enums vs everything else).

6 years agorustc: move size, align & primitive_align from Abi::Aggregate to layout.
Eduard-Mihai Burtescu [Fri, 22 Sep 2017 19:44:40 +0000 (22:44 +0300)]
rustc: move size, align & primitive_align from Abi::Aggregate to layout.

6 years agorustc_trans: go through layouts uniformly for fat pointers and variants.
Eduard-Mihai Burtescu [Thu, 21 Sep 2017 17:40:50 +0000 (20:40 +0300)]
rustc_trans: go through layouts uniformly for fat pointers and variants.

6 years agorustc: collapse Layout::FatPointer into Layout::Univariant.
Eduard-Mihai Burtescu [Wed, 20 Sep 2017 22:56:20 +0000 (01:56 +0300)]
rustc: collapse Layout::FatPointer into Layout::Univariant.

6 years agorustc_trans: query LLVM types from a layout instead of a Ty.
Eduard-Mihai Burtescu [Wed, 20 Sep 2017 20:07:47 +0000 (23:07 +0300)]
rustc_trans: query LLVM types from a layout instead of a Ty.

6 years agorustc_trans: keep a layout instead of a type in {Lvalue,Operand}Ref.
Eduard-Mihai Burtescu [Wed, 20 Sep 2017 15:17:23 +0000 (18:17 +0300)]
rustc_trans: keep a layout instead of a type in {Lvalue,Operand}Ref.

6 years agorustc_trans: nest abi::ArgType's for fat pointers instead of eagerly flattening.
Eduard-Mihai Burtescu [Wed, 20 Sep 2017 02:16:06 +0000 (05:16 +0300)]
rustc_trans: nest abi::ArgType's for fat pointers instead of eagerly flattening.

6 years agorustc_trans: pass OperandRef arguments to trans_intrinsic_call.
Eduard-Mihai Burtescu [Tue, 19 Sep 2017 23:32:22 +0000 (02:32 +0300)]
rustc_trans: pass OperandRef arguments to trans_intrinsic_call.

6 years agorustc: do not pub use Layout::* in layout.
Eduard-Mihai Burtescu [Tue, 19 Sep 2017 21:29:34 +0000 (00:29 +0300)]
rustc: do not pub use Layout::* in layout.

6 years agorustc_trans: compute LLVM types from type layouts, not Rust types.
Eduard-Mihai Burtescu [Tue, 19 Sep 2017 20:43:55 +0000 (23:43 +0300)]
rustc_trans: compute LLVM types from type layouts, not Rust types.

6 years agorustc: split layout::FieldPlacement::Linear back into Union and Array.
Eduard-Mihai Burtescu [Tue, 19 Sep 2017 09:52:30 +0000 (12:52 +0300)]
rustc: split layout::FieldPlacement::Linear back into Union and Array.

6 years agorustc: move layout::Struct into FieldPlacement/Abi.
Eduard-Mihai Burtescu [Tue, 19 Sep 2017 09:38:20 +0000 (12:38 +0300)]
rustc: move layout::Struct into FieldPlacement/Abi.

6 years agorustc: hide details in Layout in favor of Abi or FieldPlacement.
Eduard-Mihai Burtescu [Sun, 17 Sep 2017 20:37:18 +0000 (23:37 +0300)]
rustc: hide details in Layout in favor of Abi or FieldPlacement.

6 years agorustc: store CachedLayout for each variant of enum Layout's instead of Struct.
Eduard-Mihai Burtescu [Sun, 17 Sep 2017 16:34:28 +0000 (19:34 +0300)]
rustc: store CachedLayout for each variant of enum Layout's instead of Struct.

6 years agorustc: move size/alignment from Layout into layout::Abi.
Eduard-Mihai Burtescu [Sun, 17 Sep 2017 01:42:22 +0000 (04:42 +0300)]
rustc: move size/alignment from Layout into layout::Abi.

6 years agorustc: make Layout::NullablePointer a lot more like Layout::General.
Eduard-Mihai Burtescu [Sat, 16 Sep 2017 23:25:20 +0000 (02:25 +0300)]
rustc: make Layout::NullablePointer a lot more like Layout::General.

6 years agorustc: collapse Layout::CEnum into Layout::General.
Eduard-Mihai Burtescu [Sat, 16 Sep 2017 20:12:39 +0000 (23:12 +0300)]
rustc: collapse Layout::CEnum into Layout::General.

6 years agorustc: give Layout::CEnum a discriminant field like Layout::General.
Eduard-Mihai Burtescu [Sat, 16 Sep 2017 13:40:29 +0000 (16:40 +0300)]
rustc: give Layout::CEnum a discriminant field like Layout::General.

6 years agorustc: move CEnum's signedness into Primitive::Int.
Eduard-Mihai Burtescu [Sat, 16 Sep 2017 13:39:53 +0000 (16:39 +0300)]
rustc: move CEnum's signedness into Primitive::Int.

6 years agorustc: use Primitive instead of Integer for CEnum and General discriminants.
Eduard-Mihai Burtescu [Sat, 16 Sep 2017 09:23:22 +0000 (12:23 +0300)]
rustc: use Primitive instead of Integer for CEnum and General discriminants.

6 years agorustc: do not track `non_zero` in Layout.
Eduard-Mihai Burtescu [Sat, 16 Sep 2017 07:44:27 +0000 (10:44 +0300)]
rustc: do not track `non_zero` in Layout.

6 years agorustc: collapse Layout::{Raw,StructWrapped}NullablePointer into one variant.
Eduard-Mihai Burtescu [Fri, 15 Sep 2017 19:42:23 +0000 (22:42 +0300)]
rustc: collapse Layout::{Raw,StructWrapped}NullablePointer into one variant.

6 years agorustc: introduce layout::Abi for reduced general ABI "passing style".
Eduard-Mihai Burtescu [Thu, 14 Sep 2017 19:50:18 +0000 (22:50 +0300)]
rustc: introduce layout::Abi for reduced general ABI "passing style".

6 years agorustc: represent the discriminant as a field for Layout::{Raw,StructWrapped}NullableP...
Eduard-Mihai Burtescu [Wed, 13 Sep 2017 21:02:53 +0000 (00:02 +0300)]
rustc: represent the discriminant as a field for Layout::{Raw,StructWrapped}NullablePointer.

6 years agorustc_trans: treat General enums like unions.
Eduard-Mihai Burtescu [Wed, 13 Sep 2017 20:18:40 +0000 (23:18 +0300)]
rustc_trans: treat General enums like unions.