]> git.lizzy.rs Git - rust.git/log
rust.git
6 years agoAuto merge of #46054 - nikomatsakis:nll-master-to-rust-master-1, r=arielb1
bors [Thu, 23 Nov 2017 10:46:02 +0000 (10:46 +0000)]
Auto merge of #46054 - nikomatsakis:nll-master-to-rust-master-1, r=arielb1

typeck aggregate rvalues in MIR type checker

This branch is an attempt to land content by @spastorino and @Nashenas88 that was initially landed on nll-master while we waited for https://github.com/rust-lang/rust/pull/45825 to land.

The biggest change it contains is that it extends the MIR type-checker to also type-check MIR aggregate rvalues (at least partially). Specifically, it checks that the operands provided for each field have the right type.

It does not yet check that their well-formedness predicates are met. That is https://github.com/rust-lang/rust/issues/45827. It also does not check other kinds of rvalues (that is https://github.com/rust-lang/rust/issues/45959). @spastorino is working on those issues now.

r? @arielb1

6 years agoAuto merge of #46051 - cramertj:in-band-lifetimes, r=nikomatsakis
bors [Thu, 23 Nov 2017 08:20:33 +0000 (08:20 +0000)]
Auto merge of #46051 - cramertj:in-band-lifetimes, r=nikomatsakis

Implement in-band lifetime bindings

TODO (perhaps in a future PR): Should we ban explicit instantiation of generics with in-band lifetimes, or is it uncontroversial to just append them to the end of the lifetimes list?

Fixes #46042, cc #44524.

r? @nikomatsakis

6 years agoAuto merge of #46024 - estebank:no-variant, r=petrochenkov
bors [Thu, 23 Nov 2017 05:53:08 +0000 (05:53 +0000)]
Auto merge of #46024 - estebank:no-variant, r=petrochenkov

Use the proper term when using non-existing variant

When using a non-existing variant, function or associated item, refer to
the proper term, instead of defaulting to "associated item" in
diagnostics.

Fix #28972.

```
error[E0599]: no variant named `Quux` found for type `Foo` in the current scope
 --> file.rs:7:9
  |
7 |         Foo::Quux(..) =>(),
  |         ^^^^^^^^^^^^^
```

6 years agoAuto merge of #46011 - euclio:reachability-redux, r=nrc
bors [Thu, 23 Nov 2017 03:22:55 +0000 (03:22 +0000)]
Auto merge of #46011 - euclio:reachability-redux, r=nrc

Allow filtering analysis by reachability

Fixes #43521.
Fixes https://github.com/nrc/rls-analysis/issues/79.

This PR allows a user to filter items present in the save-analysis data by setting the `reachable_only` config option. This option is intended for use by the new rustdoc. The PR isn't quite finished, because it's dependent on a new release of rls-data, but I want to make sure that the approach is valid.

https://github.com/nrc/rls-analysis/issues/79 mentions that `pub use` might need to be handled, but my thinking is that the consumer of the analysis data would be able to infer which imports are `pub use`, and which items are only reachable through `pub use`, so that doesn't need to be handled here.

r? @nrc

6 years agoAdd test to new branches
Esteban Küber [Wed, 22 Nov 2017 17:40:52 +0000 (09:40 -0800)]
Add test to new branches

6 years agoAuto merge of #45721 - nikomatsakis:hir-tree, r=arielb1
bors [Thu, 23 Nov 2017 00:52:15 +0000 (00:52 +0000)]
Auto merge of #45721 - nikomatsakis:hir-tree, r=arielb1

add -Zunpretty=hir-tree

This uses the debug impls to dump the raw HIR. Particularly useful when
learning how the compiler works.

cc @qmx

6 years agoadd `reachable_only` to save-analysis config
Andy Russell [Wed, 22 Nov 2017 21:09:43 +0000 (16:09 -0500)]
add `reachable_only` to save-analysis config

6 years agoadd some tests for the interaction with existential impl trait
Niko Matsakis [Wed, 22 Nov 2017 18:45:42 +0000 (13:45 -0500)]
add some tests for the interaction with existential impl trait

6 years agomodify inherent impls test to indicate `TypeckTables` do not change
Niko Matsakis [Wed, 22 Nov 2017 17:06:19 +0000 (12:06 -0500)]
modify inherent impls test to indicate `TypeckTables` do not change

I also added some comments explaining what is going on. In short, the
changes in question do not, in fact, affect the`TypeckTables` in any
semantic way. However, altering the order of lowering can cause it
appear to affect the `TypeckTables`: if we lower generics before the
body, then the `HirId` for things in the body will be affected. In
this case, we are now lowering the generics etc
*after* the body, so the hash no longer changes. This seems good.

6 years agoadd debug log with result of writeback
Niko Matsakis [Wed, 22 Nov 2017 15:08:00 +0000 (10:08 -0500)]
add debug log with result of writeback

6 years agoImplement in-band lifetime bindings
Taylor Cramer [Fri, 17 Nov 2017 06:59:45 +0000 (22:59 -0800)]
Implement in-band lifetime bindings

6 years agoAuto merge of #46035 - oli-obk:use_suggestions, r=petrochenkov
bors [Wed, 22 Nov 2017 16:14:13 +0000 (16:14 +0000)]
Auto merge of #46035 - oli-obk:use_suggestions, r=petrochenkov

Add structured suggestions for various "use" suggestions

r? @petrochenkov

6 years agoAuto merge of #45198 - oli-obk:fmt_args, r=sfackler
bors [Wed, 22 Nov 2017 12:34:56 +0000 (12:34 +0000)]
Auto merge of #45198 - oli-obk:fmt_args, r=sfackler

Prevent fmt::Arguments from being shared across threads

Fixes #45197

This is a **breaking change**! Without doing this it's very easy to create race conditions.

There's probably a way to do this without breaking valid use cases, but it would require quite an overhaul of the formatting machinery.

6 years agoAuto merge of #44781 - QuietMisdreavus:doc-include, r=GuillaumeGomez
bors [Wed, 22 Nov 2017 09:58:07 +0000 (09:58 +0000)]
Auto merge of #44781 - QuietMisdreavus:doc-include, r=GuillaumeGomez

rustdoc: include external files in documentation (RFC 1990)

Part of https://github.com/rust-lang/rfcs/pull/1990 (needs work on the error reporting, which i'm deferring to after this initial PR)

cc #44732

Also fixes #42760, because the prep work for the error reporting made it easy to fix that at the same time.

6 years agonormalize types in ADT constructor
Niko Matsakis [Mon, 20 Nov 2017 18:08:52 +0000 (13:08 -0500)]
normalize types in ADT constructor

Fixes #45940

6 years agohandle the active field index in unions
Niko Matsakis [Sun, 12 Nov 2017 12:03:18 +0000 (07:03 -0500)]
handle the active field index in unions

6 years agoavoid early return
Niko Matsakis [Sun, 12 Nov 2017 11:25:09 +0000 (06:25 -0500)]
avoid early return

6 years agoonly normalize operand types when in an ADT constructor
Niko Matsakis [Sun, 12 Nov 2017 11:02:29 +0000 (06:02 -0500)]
only normalize operand types when in an ADT constructor

6 years agoNormalize LvalueTy for ops and format code to satisfy tidy check
Paul Daniel Faria [Sun, 12 Nov 2017 05:41:29 +0000 (00:41 -0500)]
Normalize LvalueTy for ops and format code to satisfy tidy check

6 years agoRemove attributes and test comments accidentally left behind, add in span_mirbugs
Paul Daniel Faria [Sat, 11 Nov 2017 21:13:23 +0000 (16:13 -0500)]
Remove attributes and test comments accidentally left behind, add in span_mirbugs

6 years agoFix failing test
Paul Daniel Faria [Sat, 11 Nov 2017 20:32:07 +0000 (15:32 -0500)]
Fix failing test

6 years agoCheck rvalue aggregates during check_stmt in tycheck, add initial, (not passing)...
Paul Daniel Faria [Fri, 10 Nov 2017 05:07:32 +0000 (00:07 -0500)]
Check rvalue aggregates during check_stmt in tycheck, add initial, (not passing) test

6 years agoMake RegionVid use newtype_index!
Santiago Pastorino [Fri, 10 Nov 2017 09:01:22 +0000 (10:01 +0100)]
Make RegionVid use newtype_index!

Closes #45843

6 years agoAuto merge of #46040 - zilbuz:mir-misc, r=nikomatsakis
bors [Wed, 22 Nov 2017 07:27:54 +0000 (07:27 +0000)]
Auto merge of #46040 - zilbuz:mir-misc, r=nikomatsakis

MIR-borrowck: Some minor fixes

- Remove parens when printing dereference (fix #45185)
- Change argument type of `autoderef` to `bool`
- Change argument type of `field_index` to `Field`

6 years agoAuto merge of #45879 - nikomatsakis:nll-kill-cyclic-closures, r=arielb1
bors [Tue, 21 Nov 2017 22:52:19 +0000 (22:52 +0000)]
Auto merge of #45879 - nikomatsakis:nll-kill-cyclic-closures, r=arielb1

move closure kind, signature into `ClosureSubsts`

Instead of using side-tables, store the closure-kind and signature in the substitutions themselves. This has two key effects:

- It means that the closure's type changes as inference finds out more things, which is very nice.
    - As a result, it avoids the need for the `freshen_closure_like` code (though we still use it for generators).
- It avoids cyclic closures calls.
    - These were never meant to be supported, precisely because they make a lot of the fancy inference that we do much more complicated. However, due to an oversight, it was previously possible -- if challenging -- to create a setup where a closure *directly* called itself (see e.g. #21410).

We have to see what the effect of this change is, though. Needs a crater run. Marking as [WIP] until that has been assessed.

r? @arielb1

6 years agomake with_unsugared_doc preserve is_sugared_doc
QuietMisdreavus [Sat, 23 Sep 2017 16:58:06 +0000 (11:58 -0500)]
make with_unsugared_doc preserve is_sugared_doc

6 years agoallow loading external files in documentation
QuietMisdreavus [Fri, 22 Sep 2017 03:37:00 +0000 (22:37 -0500)]
allow loading external files in documentation

Partial implementation of https://github.com/rust-lang/rfcs/pull/1990
(needs error reporting work)

cc #44732

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 agocheck that def_id is a local closure in InferCtxt::fn_sig
Niko Matsakis [Tue, 21 Nov 2017 09:45:47 +0000 (04:45 -0500)]
check that def_id is a local closure in InferCtxt::fn_sig

Before we were assuming that *every* `fn_sig` must pertain to a local
closure.

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 agofix example more
Niko Matsakis [Mon, 20 Nov 2017 21:53:48 +0000 (16:53 -0500)]
fix example more

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 agoextend comment further to explain why we limit wf to `upvar_tys`
Niko Matsakis [Mon, 20 Nov 2017 18:49:18 +0000 (13:49 -0500)]
extend comment further to explain why we limit wf to `upvar_tys`

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 agofix example for E0644
Niko Matsakis [Mon, 20 Nov 2017 18:34:24 +0000 (13:34 -0500)]
fix example for E0644

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 agoadd a simple test that running with hir-tree doesn't go bonkers
Niko Matsakis [Sun, 19 Nov 2017 22:55:10 +0000 (17:55 -0500)]
add a simple test that running with hir-tree doesn't go bonkers

Akin to the existing expanded test.

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 agoAdd structured suggestions for proc macro use imports
Oliver Schneider [Thu, 16 Nov 2017 14:03:25 +0000 (15:03 +0100)]
Add structured suggestions for proc macro use imports

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 agoAdd structured suggestions for trait imports
Oliver Schneider [Thu, 16 Nov 2017 12:14:22 +0000 (13:14 +0100)]
Add structured suggestions for trait imports

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 agoinitialize `Access` with macro
Andy Russell [Thu, 16 Nov 2017 20:59:27 +0000 (15:59 -0500)]
initialize `Access` with macro

6 years agoallow filtering analysis by reachability
Andy Russell [Tue, 14 Nov 2017 22:17:09 +0000 (17:17 -0500)]
allow filtering analysis by reachability

6 years agoupgrade rls-data
Andy Russell [Tue, 14 Nov 2017 21:15:43 +0000 (16:15 -0500)]
upgrade rls-data

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