Commit Graph

88914 Commits

Author SHA1 Message Date
Igor Matuszewski
ff41abcf8b linkchecker: Update deprecated trim_left_matches usage 2019-01-20 00:05:10 +01:00
Igor Matuszewski
c14508fd25 Add missing #![feature(rustc_private)] annotation 2019-01-20 00:04:28 +01:00
bors
0c0c585281 Auto merge of #57761 - Centril:rollup, r=Centril
Rollup of 4 pull requests

Successful merges:

 - #57452 (Improve docs for Formatter)
 - #57689 (Redo `hir::Stmt`)
 - #57723 (Point at cause for expectation in return type type error)
 - #57736 (Remove delay_span_bug from qualify_min_const_fn)

Failed merges:

r? @ghost
2019-01-19 21:21:12 +00:00
Yuki Okushi
e9af312932 [WIP] Fix tests 2019-01-20 04:37:58 +09:00
Yuki Okushi
c502a79fa1 [WIP] Improve error behavior 2019-01-20 04:37:29 +09:00
Matthew Jasper
1593ac9b9f Don't ignore _ in type casts and ascriptions 2019-01-19 19:33:41 +00:00
Mazdak Farrokhzad
d27224e0d8
Rollup merge of #57736 - phansch:remove_delay, r=oli-obk
Remove delay_span_bug from qualify_min_const_fn

This is causing issues with a new Clippy lint that will be able to
detect possible const functions.

As per https://github.com/rust-lang/rust-clippy/pull/3648#discussion_r247927450

r? @oli-obk
2019-01-19 19:41:24 +01:00
Mazdak Farrokhzad
5b9e02a39c
Rollup merge of #57723 - estebank:fix, r=davidtwco
Point at cause for expectation in return type type error

Various improvements and fixes for type errors in return expressions.

Fix #57664.
2019-01-19 19:41:22 +01:00
Mazdak Farrokhzad
3bc61cd13c
Rollup merge of #57689 - nnethercote:redo-hir-Stmt, r=petrochenkov
Redo `hir::Stmt`

A couple of changes that make things simpler and more consistent.

This should probably wait until after 1.32 lands to land, to avoid late breakage for tools.
2019-01-19 19:41:21 +01:00
Mazdak Farrokhzad
286ce3c36a
Rollup merge of #57452 - steveklabnik:improve-formatter-docs, r=frewsxcv
Improve docs for Formatter

Some improvements to `std::fmt::Formatter` to make it a bit more consistent with other documentation, as well as calling out that you don't ever instantiate one yourself.
2019-01-19 19:41:20 +01:00
bors
52fec814db Auto merge of #57721 - ehuss:update-cargo, r=alexcrichton
Update cargo

Unblocks #56884  cc @euclio

6 commits in 2b4a5f1f0bb6e13759e88ea9512527b0beba154f..ffe65875fd05018599ad07e7389e99050c7915be
2019-01-12 04:13:12 +0000 to 2019-01-17 23:57:50 +0000
- Better error message for bad manifest with `cargo install`. (rust-lang/cargo#6560)
- relax rustdoc output assertion (rust-lang/cargo#6559)
- touch some files when we use them (rust-lang/cargo#6477)
- Add documentation for new package/publish feature flags. (rust-lang/cargo#6553)
- Update chat link to Discord. (rust-lang/cargo#6554)
- Fix typo (rust-lang/cargo#6552)

r? @alexcrichton
2019-01-19 18:37:03 +00:00
Matthew Jasper
c76e55747b Type check unnanotated constant items with NLL 2019-01-19 16:30:45 +00:00
Matthew Jasper
65fe251634 Handle lifetime annotations in unreachable code
We  equate the type in the annotation with the inferred type first so
that we have a fully inferred type to perform the well-formedness check
on.
2019-01-19 16:30:45 +00:00
bors
93234994b8 Auto merge of #57755 - Centril:rollup, r=Centril
Rollup of 7 pull requests

Successful merges:

 - #57486 (Simplify `TokenStream` some more)
 - #57502 (make trait-aliases work across crates)
 - #57598 (Add missing unpretty option help message)
 - #57649 (privacy: Account for associated existential types)
 - #57659 (Fix release manifest generation)
 - #57699 (add applicability to remaining suggestions)
 - #57719 (Tweak `expand_node`)

Failed merges:

r? @ghost
2019-01-19 15:52:58 +00:00
Matthew Jasper
ed871cb368 Use a struct for user type annotations 2019-01-19 15:15:07 +00:00
Matthew Jasper
5ca6bd50b5 Rename CanonicalUserTypeAnnotation -> CanonicalUserType
We want the name `CanonicalUserTypeAnnotation` for our own use.
2019-01-19 15:15:07 +00:00
Matthew Jasper
ab7bc3a23d Rename UserTypeAnnotation -> UserType 2019-01-19 15:15:07 +00:00
Mazdak Farrokhzad
92fecfbd60
Rollup merge of #57719 - nnethercote:expand_node-FIDDLING, r=nikomatsakis
Tweak `expand_node`

These commits speed up the `unicode_normalization` benchmark a little.
2019-01-19 14:21:24 +01:00
Mazdak Farrokhzad
e78bde4015
Rollup merge of #57699 - euclio:applicability-ify, r=petrochenkov
add applicability to remaining suggestions

Fixes #50723.

I noticed that the suggestion methods on `DiagnosticBuilder` weren't actually deprecated due to #57679. This PR deprecates them properly and fixes the remaining usages.

There's also a PR for clippy at rust-lang/rust-clippy#3667.
2019-01-19 14:21:23 +01:00
Mazdak Farrokhzad
c8c03afa57
Rollup merge of #57659 - jethrogb:jb/release-manifest, r=alexcrichton
Fix release manifest generation

r? @alexcrichton
2019-01-19 14:21:22 +01:00
Mazdak Farrokhzad
4eeb095437
Rollup merge of #57649 - petrochenkov:privexist, r=arielb1
privacy: Account for associated existential types

Turns out they *can* be associated (but only in impls, not traits).
Fixes https://github.com/rust-lang/rust/issues/53546#issuecomment-454372879

r? @arielb1
2019-01-19 14:21:21 +01:00
Mazdak Farrokhzad
bce56888e9
Rollup merge of #57598 - h-michael:unpretty-help, r=oli-obk
Add missing unpretty option help message

There are some missing help messages that is printed `ructc -Zunpretty help` and receiving invalid option.

related with #16419, #45721, #21085, #31916
2019-01-19 14:21:19 +01:00
Mazdak Farrokhzad
5272be5b5e
Rollup merge of #57502 - nikomatsakis:fix-trait-alias-1b, r=nikomatsakis
make trait-aliases work across crates

This is rebase of a small part of @alexreg's PR #55994. It focuses just on the changes that integrate trait aliases properly into crate metadata, excluding the stylistic edits and the trait objects.

The stylistic edits I also rebased and can open a separate PR.

The trait object stuff I found challenging and decided it basically needed to be reimplemented. For now I've excluded it.

Since this is really @alexreg's work (I really just rebased) I am going to make it r=me once it is working.

Fixes #56488.
Fixes #57023.
2019-01-19 14:21:18 +01:00
Mazdak Farrokhzad
349c9eeb35
Rollup merge of #57486 - nnethercote:simplify-TokenStream-more, r=petrochenkov
Simplify `TokenStream` some more

These commits simplify `TokenStream`, remove `ThinTokenStream`, and avoid some clones. The end result is simpler code and a slight perf win on some benchmarks.

r? @petrochenkov
2019-01-19 14:21:17 +01:00
bors
286ac62939 Auto merge of #57370 - petrhosek:llvm-flags, r=alexcrichton
Support passing cflags/cxxflags/ldflags to LLVM build

This may be needed with some host compilers.
2019-01-19 13:11:53 +00:00
bors
c87144f3ca Auto merge of #57752 - Centril:rollup, r=Centril
Rollup of 10 pull requests

Successful merges:

 - #57268 (Add a target option "merge-functions", and a corresponding -Z flag (works around #57356))
 - #57476 (Move glob map use to query and get rid of CrateAnalysis)
 - #57501 (High priority resolutions for associated variants)
 - #57573 (Querify `entry_fn`)
 - #57610 (Fix nested `?` matchers)
 - #57634 (Remove an unused function argument)
 - #57653 (Make the contribution doc reference the guide more)
 - #57666 (Generalize `huge-enum.rs` test and expected stderr for more cross platform cases)
 - #57698 (Fix typo bug in DepGraph::try_mark_green().)
 - #57746 (Update README.md)

Failed merges:

r? @ghost
2019-01-19 10:27:59 +00:00
Alexis Hunt
c7d25a2a40 Make str indexing generic on SliceIndex. 2019-01-19 04:16:05 -05:00
Mazdak Farrokhzad
f7b9084e6e
Rollup merge of #57746 - mark-i-m:patch-2, r=Centril
Update README.md

Point contributors to the rustc-guide...

r? @steveklabnik
2019-01-19 09:03:34 +01:00
Mazdak Farrokhzad
c7686b787f
Rollup merge of #57698 - michaelwoerister:issue57692, r=Zoxc
Fix typo bug in DepGraph::try_mark_green().

r? @Zoxc

Fixes #57692.
2019-01-19 09:03:33 +01:00
Mazdak Farrokhzad
83921c31b8
Rollup merge of #57666 - pnkfelix:generalize-huge-enum-test-to-work-cross-platform, r=nikomatsakis
Generalize `huge-enum.rs` test and expected stderr for more cross platform cases

With this change, I am able to build and test cross-platform `rustc`

In particular, I can use the following in my `config.toml`:

```
[build]
host = ["i686-unknown-linux-gnu", "x86_64-unknown-linux-gnu"]
target = ["i686-unknown-linux-gnu", "x86_64-unknown-linux-gnu"]
```

Before this change, my attempt to run the test suite would fail
because the error output differs depending on what your host and
targets are.

----

To be concrete, here are the actual messages one can observe:

```
% ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc ../src/test/ui/huge-enum.rs -Aunused  --target=x86_64-unknown-linux-gnu
error: the type `std::option::Option<[u32; 35184372088831]>` is too big for the current architecture

error: aborting due to previous error

% ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc ../src/test/ui/huge-enum.rs -Aunused  --target=i686-unknown-linux-gnu
error: the type `std::option::Option<[u32; 536870911]>` is too big for the current architecture

error: aborting due to previous error

% ./build/i686-unknown-linux-gnu/stage1/bin/rustc ../src/test/ui/huge-enum.rs -Aunused  --target=i686-unknown-linux-gnu
error: the type `std::option::Option<[u32; 536870911]>` is too big for the current architecture

error: aborting due to previous error

% ./build/i686-unknown-linux-gnu/stage1/bin/rustc ../src/test/ui/huge-enum.rs -Aunused  --target=x86_64-unknown-linux-gnu
error: the type `[u32; 35184372088831]` is too big for the current architecture

error: aborting due to previous error
```

To address these variations, I changed the test to be more aggressive
in its normalization strategy. We cannot (and IMO should not)
guarantee that `Option` will appear in the error output here. So I
normalized both types `Option<[u32; N]>` and `[u32; N]` to just `TYPE`
2019-01-19 09:03:32 +01:00
Mazdak Farrokhzad
36a34e3dda
Rollup merge of #57653 - mark-i-m:contrib-doc, r=nikomatsakis
Make the contribution doc reference the guide more

and also remove a lot of redundant info already in the guide
2019-01-19 09:03:31 +01:00
Mazdak Farrokhzad
e00932a38d
Rollup merge of #57634 - oli-obk:remove_unused_argument, r=davidtwco
Remove an unused function argument

The only use was a debug printing, which might help someone with debugging dataflow problems, but seems otherwise useless
2019-01-19 09:03:29 +01:00
Mazdak Farrokhzad
fd779d3f76
Rollup merge of #57610 - mark-i-m:nested-matchers, r=petrochenkov
Fix nested `?` matchers

fix #57597

I'm not 100% if this works yet...

cc @alercah

When  this is ready (but perhaps not yet):
2019-01-19 09:03:28 +01:00
Mazdak Farrokhzad
64eb69b904
Rollup merge of #57573 - Xanewok:querify-entry-fn, r=Zoxc
Querify `entry_fn`

Analogous to https://github.com/rust-lang/rust/pull/57570 but this will also require few fixups in Miri so I decided to separate that (and it seems [CI doesn't let us break tools anymore](https://github.com/rust-lang/rust/pull/57392#issuecomment-453801540)? Or was that because it was a rollup PR?)

r? @nikomatsakis
2019-01-19 09:03:27 +01:00
Mazdak Farrokhzad
b941f290ac
Rollup merge of #57501 - petrochenkov:highvar, r=alexreg
High priority resolutions for associated variants

In https://github.com/rust-lang/rust/pull/56225 variants were assigned lowest priority during name resolution to avoid crater run and potential breakage.

This PR changes the rules to give variants highest priority instead.
Some motivation:
- If variants (and their constructors) are treated as associated items, then they are obviously *inherent* associated items since they don't come from traits.
- Inherent associated items have higher priority during resolution than associated items from traits.
- The reason is that there is a way to disambiguate in favor of trait items (`<Type as Trait>::Ambiguous`), but there's no way to disambiguate in favor of inherent items, so they became unusable in case of ambiguities if they have low priority.
- It's technically problematic to fallback from associated types to anything until lazy normalization (?) is implemented.

Crater found some regressions from this change, but they are all in type positions, e.g.
```rust
fn f() -> Self::Ambiguos { ... } // Variant `Ambiguous` or associated type `Ambiguous`?
```
, so variants are not usable there right now, but they may become usable in the future if https://github.com/rust-lang/rfcs/pull/2593 is accepted.
This PR keeps code like this successfully resolving, but introduces a future-compatibility lint `ambiguous_associated_items` that recommends rewriting it as `<Self as Trait>::Ambiguous`.
2019-01-19 09:03:26 +01:00
Mazdak Farrokhzad
c0ad9429ab
Rollup merge of #57476 - Xanewok:bye-crate-analysis, r=Zoxc
Move glob map use to query and get rid of CrateAnalysis

~Also includes commits from ~https://github.com/rust-lang/rust/pull/57392~ and ~https://github.com/rust-lang/rust/pull/57436~.~

With glob map calculated unconditionally in https://github.com/rust-lang/rust/pull/57392, this PR moves the calculated glob map to `GlobalCtxt` and exposes a relevant query (as we do with other queries which copy precomputed data over from the `Resolver`).

This allows us to get rid of the `CrateAnalysis` struct in an attempt to simplify the compiler interface.
cc @Zoxc

r? @nikomatsakis @Zoxc @petrochenkov
2019-01-19 09:03:24 +01:00
Mazdak Farrokhzad
1dc54b7319
Rollup merge of #57268 - peterhj:peterhj-optmergefunc, r=nagisa
Add a target option "merge-functions", and a corresponding -Z flag (works around #57356)

This commit adds a target option "merge-functions", which takes values in ("disabled", "trampolines", or "aliases" (default is "aliases")), to allow targets to opt out of the MergeFunctions LLVM pass. Additionally, the latest commit also adds an optional -Z flag, "merge-functions", which takes the same values and has precedence over the target option when both are specified.

This works around https://github.com/rust-lang/rust/issues/57356.

cc @eddyb @japaric @oli-obk @nox @nagisa

Also thanks to @denzp and @gnzlbg for discussing this on rust-cuda!

### Motivation

Basically, the problem is that the MergeFunctions pass, which rustc currently enables by default at -O2 and -O3 [1], and `extern "ptx-kernel"` functions (specific to the NVPTX target) are currently not compatible with each other. If the MergeFunctions pass is allowed to run, rustc can generate invalid PTX assembly (i.e. a PTX file that is not accepted by the native PTX assembler `ptxas`). Therefore we would like a way to opt out of the MergeFunctions pass, which is what our target option does.

### Related work

The current behavior of rustc is to enable MergeFunctions at -O2 and -O3 [1], and also to enable the use of function aliases within MergeFunctions [2] [3]. MergeFunctions seems to have some benefits, such as reducing code size and fixing a crash [4], which is why it is enabled. However, MergeFunctions both with and without function aliases is incompatible with the NVPTX target; a more detailed example for both cases is given below.

clang's "solution" is to have a "-fmerge-functions" flag that opts in to the MergeFunctions pass, but it is not enabled by default.

### Examples/more details

Consider an example Rust lib using `extern "ptx-kernel"` functions: https://github.com/peterhj/nvptx-mergefunc-bug/blob/master/nocore.rs. If we try to compile this with nightly rustc, we get the following compiler error:

    LLVM ERROR: Module has aliases, which NVPTX does not support.

This error happens because: (1) functions `foo` and `bar` have the same body, so are candidates to be merged by MergeFunctions; and (2) rustc configures MergeFunctions to generate function aliases using the "mergefunc-use-aliases" LLVM option [2] [3], but the NVPTX backend does not support those aliases.

Okay, so we can try omitting "mergefunc-use-aliases", and then rustc will happily emit PTX assembly: https://github.com/peterhj/nvptx-mergefunc-bug/blob/master/nocore-mergefunc-nousealiases-bad.ptx. However, this PTX is invalid! When we try to assemble it with `ptxas` (I'm on the CUDA 9.2 toolchain), we get an assembler error:

    ptxas nocore-mergefunc-nousealiases-bad.ptx, line 38; error   : Illegal call target, device function expected
    ptxas fatal   : Ptx assembly aborted due to errors

What's happening is that MergeFunctions rewrites the `bar` function to call `foo`. However, directly calling an `extern "ptx-kernel"` function from another `extern "ptx-kernel"` is wrong.

If we disable the MergeFunctions pass from running at all, rustc generates correct PTX assembly: https://github.com/peterhj/nvptx-mergefunc-bug/blob/master/nocore-nomergefunc-ok.ptx

[1] a36b960df6/src/librustc_codegen_ssa/back/write.rs (L155)
[2] a36b960df6/src/librustc_codegen_llvm/llvm_util.rs (L64)
[3] https://github.com/rust-lang/rust/pull/56358
[4] https://github.com/rust-lang/rust/pull/49479
2019-01-19 09:03:23 +01:00
bors
1bc6baec76 Auto merge of #57253 - Zoxc:incr-passes2, r=michaelwoerister
Make privacy checking, intrinsic checking and liveness checking incremental

Blocked on https://github.com/rust-lang/rust/pull/51487

r? @michaelwoerister
2019-01-19 07:42:43 +00:00
John Kåre Alsaker
9b5535a6f3 Fix lints in tests 2019-01-19 08:10:01 +01:00
bors
af73e64423 Auto merge of #56722 - Aaron1011:fix/blanket-eval-overflow, r=nikomatsakis
Fix stack overflow when finding blanket impls

Currently, SelectionContext tries to prevent stack overflow by keeping
track of the current recursion depth. However, this depth tracking is
only used when performing normal section (which includes confirmation).
No such tracking is performed for evaluate_obligation_recursively, which
can allow a stack overflow to occur.

To fix this, this commit tracks the current predicate evaluation depth.
This is done separately from the existing obligation depth tracking:
an obligation overflow can occur across multiple calls to 'select' (e.g.
when fulfilling a trait), while a predicate evaluation overflow can only
happen as a result of a deep recursive call stack.

Fixes #56701

I've re-used `tcx.sess.recursion_limit` when checking for predication evaluation overflows. This is such a weird corner case that I don't believe it's necessary to have a separate setting controlling the maximum depth.
2019-01-19 05:05:48 +00:00
John Kåre Alsaker
beb0c74950 Combine all builtin early lints and use a separate walk for plugin lints. Add a -Z no-interleave-lints option to allow benchmarking lints 2019-01-19 05:01:29 +01:00
John Kåre Alsaker
a5d4aeddc8 Address some comments 2019-01-19 04:29:26 +01:00
bors
53b622a48a Auto merge of #56479 - mark-i-m:unsat, r=nikomatsakis
Better lifetime error message

I propose the following error message as more user-friendly

r? @nikomatsakis
2019-01-19 02:25:38 +00:00
bors
f001287c90 Auto merge of #57747 - Centril:rollup, r=Centril
Rollup of 11 pull requests

Successful merges:

 - #57107 (Add a regression test for mutating a non-mut #[thread_local])
 - #57132 (Document that `-C opt-level=0` implies `-C debug-assertions`.)
 - #57212 (docs(rustc): Link to the book's source in rustc)
 - #57302 (Fix unused_assignments false positive)
 - #57350 (Better error note on unimplemented Index trait for string)
 - #57635 (use structured macro and path resolve suggestions)
 - #57650 (librustc_metadata: Pass a default value when unwrapping a span)
 - #57657 (Add regression test to close #53787)
 - #57658 (Two HIR tweaks)
 - #57720 (Fix suggestions given mulitple bad lifetimes)
 - #57725 (Use structured suggestion to surround struct literal with parenthesis)

Failed merges:

r? @ghost
2019-01-18 23:40:14 +00:00
Mazdak Farrokhzad
2a830e47e1
Rollup merge of #57725 - estebank:parens, r=michaelwoerister
Use structured suggestion to surround struct literal with parenthesis
2019-01-18 22:56:48 +01:00
Mazdak Farrokhzad
42accf06dc
Rollup merge of #57720 - dlrobertson:fix_57521, r=estebank
Fix suggestions given mulitple bad lifetimes

When given multiple lifetimes prior to type parameters in generic
parameters, do not ICE and print the correct suggestion.

r? @estebank

CC @pnkfelix

Fixes: #57521
2019-01-18 22:56:47 +01:00
Mazdak Farrokhzad
857d27fb14
Rollup merge of #57658 - nnethercote:rm-hir-P-Lit, r=michaelwoerister
Two HIR tweaks

Two HIR tweaks that make things slightly simpler and faster.
2019-01-18 22:56:45 +01:00
Mazdak Farrokhzad
0eb4bdc5f1
Rollup merge of #57657 - AB1908:regression-test-case, r=nikomatsakis
Add regression test to close #53787

Fixes #53787
2019-01-18 22:56:44 +01:00
Mazdak Farrokhzad
d2300afd66
Rollup merge of #57650 - AB1908:master, r=petrochenkov
librustc_metadata: Pass a default value when unwrapping a span

Fixes #57323.

When compiling with `static-nobundle` a-la

`rustc -l static-nobundle=nonexistent main.rs`

we now get a neat output in the form of:

```
error[E0658]: kind="static-nobundle" is feature gated (see issue #37403)
  |
  = help: add #![feature(static_nobundle)] to the crate attributes to enable

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.
```
The build and tests completed successfully on my machine. Should I be adding a new test?
2019-01-18 22:56:43 +01:00
Mazdak Farrokhzad
f63e3d2ef4
Rollup merge of #57635 - euclio:path-separators, r=michaelwoerister
use structured macro and path resolve suggestions
2019-01-18 22:56:42 +01:00