]> git.lizzy.rs Git - rust.git/log
rust.git
6 years agoAdd missing Debug impls to std_unicode
Oliver Middleton [Wed, 22 Nov 2017 00:49:28 +0000 (00:49 +0000)]
Add missing Debug impls to std_unicode

Also adds #![deny(missing_debug_implementations)] so they don't get
missed again.

6 years agoAuto merge of #46166 - kennytm:rollup, r=kennytm
bors [Tue, 21 Nov 2017 17:14:05 +0000 (17:14 +0000)]
Auto merge of #46166 - kennytm:rollup, r=kennytm

Rollup of 11 pull requests

- Successful merges: #45987, #46031, #46050, #46052, #46103, #46120, #46134, #46141, #46148, #46155, #46157
- Failed merges:

6 years agoRollup merge of #46157 - martinlindhe:master, r=kennytm
kennytm [Tue, 21 Nov 2017 17:13:06 +0000 (01:13 +0800)]
Rollup merge of #46157 - martinlindhe:master, r=kennytm

fix some typos

This is the result of me testing out a WIP source code typo-finder
and your project was the random target this time.

6 years agoRollup merge of #46155 - SimonSapin:stylo, r=kennytm
kennytm [Tue, 21 Nov 2017 17:13:05 +0000 (01:13 +0800)]
Rollup merge of #46155 - SimonSapin:stylo, r=kennytm

Revert servo to upstream in cargotest

This is a follow-up to https://github.com/rust-lang/rust/pull/45225#issuecomment-345503017 now that upstream has adjusted: https://github.com/servo/servo/pull/19316

6 years agoRollup merge of #46148 - SimonSapin:patch-6, r=alexcrichton
kennytm [Tue, 21 Nov 2017 17:13:04 +0000 (01:13 +0800)]
Rollup merge of #46148 - SimonSapin:patch-6, r=alexcrichton

Expand a couple points in 1.22.0 release notes

Let’s not give false hopes about `const fn` :)

6 years agoRollup merge of #46141 - aqrln:tosocketaddrs-doc-fix-typo, r=frewsxcv
kennytm [Tue, 21 Nov 2017 17:13:03 +0000 (01:13 +0800)]
Rollup merge of #46141 - aqrln:tosocketaddrs-doc-fix-typo, r=frewsxcv

Fix a typo in ToSocketAddrs documentation

Fix a typo in `ToSocketAddrs` documentation: s/ToSocketsAddr/ToSocketAddrs

6 years agoRollup merge of #46134 - GuillaumeGomez:negative-traits, r=QuietMisdreavus
kennytm [Tue, 21 Nov 2017 17:13:02 +0000 (01:13 +0800)]
Rollup merge of #46134 - GuillaumeGomez:negative-traits, r=QuietMisdreavus

Display negative traits implementation

Fixes #45816.

r? @QuietMisdreavus

6 years agoRollup merge of #46120 - arielb1:def-debug, r=michaelwoerister
kennytm [Tue, 21 Nov 2017 17:13:01 +0000 (01:13 +0800)]
Rollup merge of #46120 - arielb1:def-debug, r=michaelwoerister

clean the Debug impl for CrateNum and DefId

Just a tiny quality-of-life improvement because I got tired of noisy debug logs.

```
before: DefId { krate: CrateNum(11), index: DefIndex(0:6) => foo[8787]::Mapper[0]::OtherType[0] } }
after: {crate11:0:6 ~ foo[8787]::Mapper[0]::OtherType[0]})
```

r? @michaelwoerister

6 years agoRollup merge of #46103 - zackmdavis:dead_code_lint_should_say_never_constructed_for_v...
kennytm [Tue, 21 Nov 2017 17:13:00 +0000 (01:13 +0800)]
Rollup merge of #46103 - zackmdavis:dead_code_lint_should_say_never_constructed_for_variants, r=arielb1

dead code lint to say "never constructed" for variants

As reported in #19140, #44083, and #44565, some users were confused when
the dead-code lint reported an enum variant to be "unused" when it was
matched on (but not constructed). This wording change makes it clearer
that the lint is in fact checking for construction.

We continue to say "used" for all other items (it's tempting to say
"called" for functions and methods, but this turns out not to be
correct: functions can be passed as arguments and the dead-code lint
isn't special-casing that or anything).

Resolves #19140.

r? @pnkfelix

6 years agoRollup merge of #46052 - oli-obk:rendered_diagnostics_in_json, r=petrochenkov
kennytm [Tue, 21 Nov 2017 17:12:59 +0000 (01:12 +0800)]
Rollup merge of #46052 - oli-obk:rendered_diagnostics_in_json, r=petrochenkov

Include rendered diagnostic in json

r? @petrochenkov

6 years agoRollup merge of #46050 - sunfishcode:read_to_end, r=sfackler
kennytm [Tue, 21 Nov 2017 17:12:58 +0000 (01:12 +0800)]
Rollup merge of #46050 - sunfishcode:read_to_end, r=sfackler

Optimize `read_to_end`.

This patch makes `read_to_end` use Vec's memory-growth pattern rather
than using a custom pattern.

This has some interesting effects:

 - If memory is reserved up front, `read_to_end` can be faster, as it
   starts reading at the buffer size, rather than always starting at 32
   bytes. This speeds up file reading by 2x in one of my use cases.

 - It can reduce the number of syscalls when reading large files.
   Previously, `read_to_end` would settle into a sequence of 8192-byte
   reads. With this patch, the read size follows Vec's allocation
   pattern. For example, on a 16MiB file, it can do 21 read syscalls
   instead of 2057. In simple benchmarks of large files though, overall
   speed is still dominated by the actual I/O.

 - A downside is that Read implementations that don't implement
   `initializer()` may see increased memory zeroing overhead.

I benchmarked this on a variety of data sizes, with and without
preallocated buffers. Most benchmarks see no difference, but reading
a small/medium file with a pre-allocated buffer is faster.

6 years agoRollup merge of #46031 - Keruspe:cargofmt, r=Mark-Simulacrum
kennytm [Tue, 21 Nov 2017 17:12:57 +0000 (01:12 +0800)]
Rollup merge of #46031 - Keruspe:cargofmt, r=Mark-Simulacrum

rustbuild: distribute cargo-fmt alongside rustfmt

Not sure whether we want that nor if it's the right way to do so, but it feels quite weird to have rustfmt without cargo-fmt. Or are there other plans wrt that?

What do you think @nrc ?

6 years agoRollup merge of #45987 - gaurikholkar:let-expr, r=michaelwoerister
kennytm [Tue, 21 Nov 2017 17:12:56 +0000 (01:12 +0800)]
Rollup merge of #45987 - gaurikholkar:let-expr, r=michaelwoerister

update let-expressions hash test to use `except`

A part of #44924, this PR updated let-expressions test using `except`.

cc @michaelwoerister
r? @nikomatsakis

6 years agofix some typos
Martin Lindhe [Tue, 21 Nov 2017 14:33:45 +0000 (15:33 +0100)]
fix some typos

6 years agoclean the Debug impl for CrateNum and DefId
Ariel Ben-Yehuda [Mon, 20 Nov 2017 15:49:21 +0000 (17:49 +0200)]
clean the Debug impl for CrateNum and DefId

before: DefId { krate: CrateNum(11), index: DefIndex(0:6) => foo[8787]::Mapper[0]::OtherType[0] } }
after: DefId(11:0:6 ~ foo[8787]::Mapper[0]::OtherType[0])

6 years agoRevert servo to upstream in cargotest
Simon Sapin [Tue, 21 Nov 2017 13:21:24 +0000 (14:21 +0100)]
Revert servo to upstream in cargotest

This is a follow-up to https://github.com/rust-lang/rust/pull/45225#issuecomment-345503017
now that upstream has adjusted https://github.com/servo/servo/pull/19316

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 agoRemove 1.23.0 release notes entry on const_fn
Simon Sapin [Tue, 21 Nov 2017 11:43:24 +0000 (12:43 +0100)]
Remove 1.23.0 release notes entry on const_fn

It doesn’t change anything for stable users in practice. See discussion in https://github.com/rust-lang/rust/pull/46148

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 agoExpand a couple points in 1.22.0 release notes
Simon Sapin [Tue, 21 Nov 2017 07:37:34 +0000 (08:37 +0100)]
Expand a couple points in 1.22.0 release notes

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 agoFix a typo in ToSocketAddrs documentation
Alexey Orlenko [Mon, 20 Nov 2017 23:53:36 +0000 (01:53 +0200)]
Fix a typo in ToSocketAddrs documentation

Fix a typo in ToSocketAddrs documentation: s/ToSocketsAddr/ToSocketAddrs

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 agoDisplay negative traits implementation
Guillaume Gomez [Mon, 20 Nov 2017 20:50:05 +0000 (21:50 +0100)]
Display negative traits implementation

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 agoUpdate ui test to rustc master
Oliver Schneider [Mon, 20 Nov 2017 11:42:38 +0000 (12:42 +0100)]
Update ui test to rustc master

6 years agorustbuild: fix expectation message
Marc-Antoine Perennou [Mon, 20 Nov 2017 09:02:08 +0000 (10:02 +0100)]
rustbuild: fix expectation message

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
6 years agoAddress PR comments
Oliver Schneider [Mon, 20 Nov 2017 08:40:55 +0000 (09:40 +0100)]
Address PR comments

6 years agoThe end of a span can be *before* the first char in a line
Oliver Schneider [Fri, 17 Nov 2017 12:13:02 +0000 (13:13 +0100)]
The end of a span can be *before* the first char in a line

6 years agoInclude rendered diagnostic in json
Oliver Schneider [Fri, 17 Nov 2017 07:55:22 +0000 (08:55 +0100)]
Include rendered diagnostic in json

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 agodead code lint to say "never constructed" for variants
Zack M. Davis [Sun, 19 Nov 2017 18:15:36 +0000 (10:15 -0800)]
dead code lint to say "never constructed" for variants

As reported in #19140, #44083, and #44565, some users were confused when
the dead-code lint reported an enum variant to be "unused" when it was
matched on (but not constructed). This wording change makes it clearer
that the lint is in fact checking for construction.

We continue to say "used" for all other items (it's tempting to say
"called" for functions and methods, but this turns out not to be
correct: functions can be passed as arguments and the dead-code lint
isn't special-casing that or anything).

Resolves #19140.

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.