]> git.lizzy.rs Git - rust.git/log
rust.git
6 years agoAuto merge of #46117 - SimonSapin:min-align, r=alexcrichton
bors [Sat, 25 Nov 2017 06:16:19 +0000 (06:16 +0000)]
Auto merge of #46117 - SimonSapin:min-align, r=alexcrichton

allocators: don’t assume MIN_ALIGN for small sizes

See individual commit messages.

6 years agoAuto merge of #46081 - GuillaumeGomez:fix-path-search, r=QuietMisdreavus
bors [Sat, 25 Nov 2017 02:43:48 +0000 (02:43 +0000)]
Auto merge of #46081 - GuillaumeGomez:fix-path-search, r=QuietMisdreavus

Fix path search

Fixes #46015.

r? @QuietMisdreavus

6 years agoAuto merge of #46008 - alexcrichton:update-llvm, r=Mark-Simulacrum
bors [Sat, 25 Nov 2017 00:17:03 +0000 (00:17 +0000)]
Auto merge of #46008 - alexcrichton:update-llvm, r=Mark-Simulacrum

rustbuild: Update LLVM and enable ThinLTO

This commit updates LLVM to fix #45511 (https://reviews.llvm.org/D39981) and
also reenables ThinLTO for libtest now that we shouldn't hit #45768. This also
opportunistically enables ThinLTO for libstd which was previously blocked
(#45661) on test failures related to debuginfo with a presumed cause of #45511.

Closes #45511

6 years agostd: Flag Windows TLS dtor symbol as #[used]
Alex Crichton [Fri, 24 Nov 2017 17:18:22 +0000 (09:18 -0800)]
std: Flag Windows TLS dtor symbol as #[used]

Turns out ThinLTO was internalizing this symbol and eliminating it. Worse yet if
you compiled with LTO turns out no TLS destructors would run on Windows! The
`#[used]` annotation should be a more bulletproof implementation (in the face of
LTO) of preserving this symbol all the way through in LLVM and ensuring it makes
it all the way to the linker which will take care of it.

6 years agoAuto merge of #46111 - michaelwoerister:promote-green, r=nikomatsakis
bors [Fri, 24 Nov 2017 21:50:09 +0000 (21:50 +0000)]
Auto merge of #46111 - michaelwoerister:promote-green, r=nikomatsakis

incr.comp.: Make sure we don't lose unused green results from the query cache.

In its current implementation, the query result cache works by bulk-writing the results of all cacheable queries into a monolithic binary file on disk. Prior to this PR, we would potentially lose query results during this process because only results that had already been loaded into memory were serialized. In contrast, results that were not needed during the given compilation session were not serialized again.

This PR will do one pass over all green `DepNodes` that represent a cacheable query and execute the corresponding query in order to make sure that the query result gets loaded into memory before cache serialization.

In the future we might want to look into a serialization format the can be updated in-place so that we don't have to load unchanged results just for immediately storing them again.

r? @nikomatsakis

6 years agoAuto merge of #46093 - scottmcm:lower-128-mir, r=nagisa
bors [Fri, 24 Nov 2017 15:11:11 +0000 (15:11 +0000)]
Auto merge of #46093 - scottmcm:lower-128-mir, r=nagisa

Add a MIR pass to lower 128-bit operators to lang item calls

Runs only with `-Z lower_128bit_ops` since it's not hooked into targets yet.

This isn't really useful on its own, but the declarations for the lang items need to be in the compiler before compiler-builtins can be updated to define them, so this is part 1 of at least 3.

cc https://github.com/rust-lang/rust/issues/45676 @est31 @nagisa

6 years agorustbuild: Update LLVM and enable ThinLTO
Alex Crichton [Wed, 15 Nov 2017 13:16:23 +0000 (05:16 -0800)]
rustbuild: Update LLVM and enable ThinLTO

This commit updates LLVM to fix #45511 (https://reviews.llvm.org/D39981) and
also reenables ThinLTO for libtest now that we shouldn't hit #45768. This also
opportunistically enables ThinLTO for libstd which was previously blocked
(#45661) on test failures related to debuginfo with a presumed cause of #45511.

Closes #45511

6 years agoAuto merge of #46116 - oli-obk:json_ui, r=nikomatsakis
bors [Fri, 24 Nov 2017 12:38:11 +0000 (12:38 +0000)]
Auto merge of #46116 - oli-obk:json_ui, r=nikomatsakis

Check //~ERROR comments in ui tests

r? @nikomatsakis

cc #44844 @Phlosioneer @estebank @petrochenkov

this depends on https://github.com/rust-lang/rust/pull/46052 getting merged first (the commits are included in here)

The relevant changes of this PR are c2f0af7 and 979269b

6 years agoMerge cfail and ui tests into ui tests
Oliver Schneider [Mon, 20 Nov 2017 12:13:27 +0000 (13:13 +0100)]
Merge cfail and ui tests into ui tests

6 years agoAuto merge of #46012 - Gankro:float-conv-transmute, r=sfackler
bors [Fri, 24 Nov 2017 10:06:09 +0000 (10:06 +0000)]
Auto merge of #46012 - Gankro:float-conv-transmute, r=sfackler

Make float::from_bits transmute

See commit message for details.

See also this discussion here: https://github.com/rust-lang/rust/issues/40470#issuecomment-343803381

(may require libs team discussion before merging)

6 years agoUI tests extract the regular output from the 'rendered' field in json
Oliver Schneider [Mon, 20 Nov 2017 11:49:03 +0000 (12:49 +0100)]
UI tests extract the regular output from the 'rendered' field in json

6 years agoThis method of once-diagnostics doesn't allow nesting
Oliver Schneider [Mon, 20 Nov 2017 11:48:08 +0000 (12:48 +0100)]
This method of once-diagnostics doesn't allow nesting

6 years agoSimplify an Iterator::fold to Iterator::any
Oliver Schneider [Mon, 20 Nov 2017 11:46:45 +0000 (12:46 +0100)]
Simplify an Iterator::fold to Iterator::any

6 years agoAuto merge of #45946 - estebank:crate-conflict-diag, r=arielb1
bors [Fri, 24 Nov 2017 04:03:36 +0000 (04:03 +0000)]
Auto merge of #45946 - estebank:crate-conflict-diag, r=arielb1

Use multiline text for crate conflict diagnostics

After:
```
error[E0464]: multiple matching crates for `libc`
 --> /checkout/src/rustc/dlmalloc_shim/../../dlmalloc/src/linux.rs:1:1
  |
1 | extern crate libc;
  | ^^^^^^^^^^^^^^^^^^
  |
  = note: candidates:
          crate `libc`: /checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-658d35794c10b003.rlib
          crate `libc`: /checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-f32a17a3111b01aa.rlib
```
Before:
```
error[E0464]: multiple matching crates for `libc`
 --> /checkout/src/rustc/dlmalloc_shim/../../dlmalloc/src/linux.rs:1:1
  |
1 | extern crate libc;
  | ^^^^^^^^^^^^^^^^^^
  |
  = note: candidates:
  = note: path: /checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-658d35794c10b003.rlib
  = note: crate name: libc
  = note: path: /checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-f32a17a3111b01aa.rlib
  = note: crate name: libc
```

6 years agoAuto merge of #45942 - Menschenkindlein:master, r=estebank
bors [Fri, 24 Nov 2017 01:44:19 +0000 (01:44 +0000)]
Auto merge of #45942 - Menschenkindlein:master, r=estebank

Add hints for the case of confusing enum with its variants

A solution for https://github.com/rust-lang/rust/issues/43871. When one uses an enum in a place that accepts variants (e.g., `Option(result)` instead of `Some(result)`), suggest one of this enum's variants.

cc @estebank

6 years agoMake float::from_bits transmute (and update the documentation to reflect this).
Alexis Beingessner [Wed, 15 Nov 2017 20:05:47 +0000 (15:05 -0500)]
Make float::from_bits transmute (and update the documentation to reflect this).

The current implementation/documentation was made to avoid sNaN because of
potential safety issues implied by old/bad LLVM documentation. These issues
aren't real, so we can just make the implementation transmute (as permitted
by the existing documentation of this method).

Also the documentation didn't actually match the behaviour: it said we may
change sNaNs, but in fact we canonicalized *all* NaNs.

Also an example in the documentation was wrong: it said we *always* change
sNaNs, when the documentation was explicitly written to indicate it was
implementation-defined.

This makes to_bits and from_bits perfectly roundtrip cross-platform, except
for one caveat: although the 2008 edition of IEEE-754 specifies how to
interpet the signaling bit, earlier editions didn't. This lead to some platforms
picking the opposite interpretation, so all signaling NaNs on x86/ARM are quiet
on MIPS, and vice-versa.

NaN-boxing is a fairly important optimization, while we don't even guarantee
that float operations properly preserve signalingness. As such, this seems like
the more natural strategy to take (as opposed to trying to mangle the signaling
bit on a per-platform basis).

This implementation is also, of course, faster.

6 years agoAuto merge of #46225 - GuillaumeGomez:rollup, r=GuillaumeGomez
bors [Thu, 23 Nov 2017 21:48:30 +0000 (21:48 +0000)]
Auto merge of #46225 - GuillaumeGomez:rollup, r=GuillaumeGomez

Rollup of 5 pull requests

- Successful merges: #45635, #46177, #46190, #46218, #46220
- Failed merges:

6 years agoRollup merge of #46220 - rust-lang:frewsxcv-issue-44929, r=kennytm
Guillaume Gomez [Thu, 23 Nov 2017 20:51:13 +0000 (21:51 +0100)]
Rollup merge of #46220 - rust-lang:frewsxcv-issue-44929, r=kennytm

Clarify stdin behavior of `Command::output`.

Fixes #44929.

6 years agoRollup merge of #46218 - rust-lang:frewsxcv-rename-slice-swap-param, r=kennytm
Guillaume Gomez [Thu, 23 Nov 2017 20:51:12 +0000 (21:51 +0100)]
Rollup merge of #46218 - rust-lang:frewsxcv-rename-slice-swap-param, r=kennytm

Rename param in `[T]::swap_with_slice` from `src` to `other`.

The idea of ‘source’ and ‘destination’ aren’t very applicable for this
operation since both slices can both be considered sources and
destinations.

6 years agoRollup merge of #46190 - steveklabnik:fix-releases, r=aturon
Guillaume Gomez [Thu, 23 Nov 2017 20:51:11 +0000 (21:51 +0100)]
Rollup merge of #46190 - steveklabnik:fix-releases, r=aturon

Amend RELEASES for 1.22.1

and fix the date for 1.22.0

6 years agoRollup merge of #46177 - ollie27:std_unicode_debug, r=estebank
Guillaume Gomez [Thu, 23 Nov 2017 20:51:10 +0000 (21:51 +0100)]
Rollup merge of #46177 - ollie27:std_unicode_debug, r=estebank

Add missing Debug impls to std_unicode

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

cc #31869

6 years agoRollup merge of #45635 - virgil-palanciuc:master, r=kennytm
Guillaume Gomez [Thu, 23 Nov 2017 20:51:09 +0000 (21:51 +0100)]
Rollup merge of #45635 - virgil-palanciuc:master, r=kennytm

Add test for #44953

Added the requested test - trying to see if it passes; my local build fails, but not sure why - the nightly shows this output, but in my build the compilation error changed.

Fixes #44953.

6 years agoAuto merge of #45881 - Centril:box-leak, r=alexcrichton
bors [Thu, 23 Nov 2017 19:18:15 +0000 (19:18 +0000)]
Auto merge of #45881 - Centril:box-leak, r=alexcrichton

Add Box::leak<'a>(Box<T>) -> &'a mut T where T: 'a

Adds:

```rust
impl<T: ?Sized> Box<T> {
    pub fn leak<'a>(b: Box<T>) -> &'a mut T where T: 'a {
        unsafe { &mut *Box::into_raw(b) }
    }
}
```

which is useful for when you just want to put some stuff on the heap and then have a reference to it for the remainder of the program.

r? @sfackler
cc @durka

6 years agoUse for_each_child_stable in find_module
Maxim Zholobak [Thu, 23 Nov 2017 19:09:27 +0000 (21:09 +0200)]
Use for_each_child_stable in find_module

6 years agoAuto merge of #46087 - vramana:fix-46003, r=arielb1
bors [Thu, 23 Nov 2017 14:48:14 +0000 (14:48 +0000)]
Auto merge of #46087 - vramana:fix-46003, r=arielb1

Fix borrowck compiler errors for upvars contain "spurious" dereferences

Fixes #46003

6 years agoFix borrowck compiler errors for upvars contain "spurious" dereferences
Ramana Venkata [Sat, 18 Nov 2017 22:32:05 +0000 (04:02 +0530)]
Fix borrowck compiler errors for upvars contain "spurious" dereferences

Fixes #46003

6 years agoAdd module population and case of enum in place of expression
Maxim Zholobak [Thu, 23 Nov 2017 13:10:23 +0000 (15:10 +0200)]
Add module population and case of enum in place of expression

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 agoUse multiline text for crate conflict diagnostics
Esteban Küber [Sun, 12 Nov 2017 19:56:59 +0000 (11:56 -0800)]
Use multiline text for crate conflict diagnostics

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 agoClarify stdin behavior of `Command::output`.
Corey Farwell [Thu, 23 Nov 2017 01:47:31 +0000 (20:47 -0500)]
Clarify stdin behavior of `Command::output`.

Fixes #44929.

6 years agoRename param in `[T]::swap_with_slice` from `src` to `other`.
Corey Farwell [Thu, 23 Nov 2017 00:56:48 +0000 (19:56 -0500)]
Rename param in `[T]::swap_with_slice` from `src` to `other`.

The idea of ‘source’ and ‘destination’ aren’t very applicable for this
operation since both slices can both be considered sources and
destinations.

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 agoAmend RELEASES for 1.22.1
steveklabnik [Wed, 22 Nov 2017 19:04:41 +0000 (14:04 -0500)]
Amend RELEASES for 1.22.1

and fix the date for 1.22.0

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 agoBox::leak: update unstable issue number (46179).
Mazdak [Wed, 22 Nov 2017 06:21:30 +0000 (07:21 +0100)]
Box::leak: update unstable issue number (46179).

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 #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 agoAdd test for #44953
Virgil Palanciuc [Mon, 30 Oct 2017 17:52:10 +0000 (19:52 +0200)]
Add test for #44953

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 agoStrongly improve search path
Guillaume Gomez [Sun, 19 Nov 2017 12:41:56 +0000 (13:41 +0100)]
Strongly improve search path

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`