Commit Graph

88108 Commits

Author SHA1 Message Date
David Wood
95c18382cb
Fix unresolved inference variable ICE.
This commit moves well-formedness check for the
`UserTypeAnnotation::Ty(..)` case from always running to only when the
code is reachable. This solves the ICE that resulted from
`src/test/ui/issue-54943-1.rs` (a minimal repro of `dropck-eyepatch`
run-pass tests that failed).

The main well-formedness check that was intended to be run despite
unreachable code still is, that being the
`UserTypeAnnotation::TypeOf(..)` case. Before this PR, the other case
wasn't being checked at all.

It is possible to fix this ICE while still always checking
well-formedness for the `UserTypeAnnotation::Ty(..)` case but that
solution will ICE in unreachable code for that case, the diff for
that change [can be found here](0).

[0]: https://gist.github.com/davidtwco/f9751ffd9c0508f7251c0f17adc3af53
2018-12-30 14:30:59 +01:00
David Wood
6092d92d70
Add explicit error annotations to test.
This commit adds explicit error annotations to tests after rebasing
which is now required.
2018-12-30 14:30:58 +01:00
David Wood
dc41606ff4
Support user type annotations in ref bindings.
This commit adds support for user type annotations in variables declared
using `ref` bindings. When a variable declared using a `ref` binding,
then the `LocalDecl` has the type `&T` where the `&` was introduced by
the `ref` binding but the canonicalized type annotation has only a
`T` since the reference is implicit with the `ref` binding.

Therefore, to support type annotations, the canonicalized type
annotation either needs wrapped in a reference, or the `LocalDecl` type
must have a wrapped reference removed for comparison. It is easier to
remove the outer reference from the `LocalDecl` for the purpose of
comparison, so that is the approach this commit takes.
2018-12-30 14:30:58 +01:00
David Wood
162dcdc16f
Add user type annotations to MIR dump.
This commit writes the user type annotations to the MIR dump so that
they are visible again.
2018-12-30 14:30:58 +01:00
David Wood
4be7214d30
Type annotations in associated constant patterns.
This commit adds support for respecting user type annotations with
associated constants in patterns.
2018-12-30 14:30:58 +01:00
David Wood
b182a21163
Add test for unreachable well-formedness.
This commit adds a test for checking that types are well-formed when
unreachable.
2018-12-30 14:25:25 +01:00
David Wood
f2532012dd
Always check well-formedness.
This commit uses the map introduced by the previous commit to ensure
that types are always checked for well-formedness by the NLL type check.
Previously, without the map introduced by the previous commit, types
would not be checked for well-formedness if the `AscribeUserType`
statement that would trigger that check was removed as unreachable code.
2018-12-30 14:25:25 +01:00
David Wood
24a7a010d1
Refactor UserTypeAnnotation.
This commit refactors the `UserTypeAnnotation` type to be referred to by
an index within `UserTypeProjection`. `UserTypeAnnotation` is instead
kept in an `IndexVec` within the `Mir` struct.

Further, instead of `UserTypeAnnotation` containing canonicalized types,
it now contains normal types and the entire `UserTypeAnnotation` is
canonicalized. To support this, the type was moved from the `rustc::mir`
module to `rustc::ty` module.
2018-12-30 14:25:20 +01:00
bors
3ce6f6eca6 Auto merge of #57204 - czipperz:ord_docs_must_agree, r=sfackler
Make std::cmp::Ord documentation specify what it means to agree with ParitalEq

Resolves #57157
2018-12-30 13:24:11 +00:00
bors
7155690ffc Auto merge of #57158 - estebank:as-ref, r=zackmdavis
Suggest `.as_ref()` when appropriate for `Option` and `Result`

Fix #55198.
2018-12-30 09:51:44 +00:00
bors
0e6f8987aa Auto merge of #57195 - czipperz:mention_ToString_in_std_fmt_docs, r=SimonSapin
Mention ToString in std::fmt docs

I believe this should be added because `x.to_string()` is preferred over `format!("{}", x)` as the recommended way to convert a value to a string.  `std::fmt` and the `format` macro is where people look for documentation about this, and thus we should include references to this preferred functions there.

Resolves #55065
2018-12-30 07:12:13 +00:00
bors
171c1fc25e Auto merge of #57185 - petrochenkov:impice4, r=estebank
resolve: Fix one more ICE in import validation

So if you have an unresolved import
```rust
mod m {
    use foo::bar;
}
```
error recovery will insert a special item with `Def::Err` definition into module `m`, so other things depending on `bar` won't produce extra errors.

The issue was that erroneous `bar` was overwriting legitimate `bar`s coming from globs, e.g.
```rust
mod m {
    use baz::*; // imports real existing `bar`
    use foo::bar;
}
```
causing some unwanted diagnostics talking about "unresolved items", and producing inconsistent resolutions like https://github.com/rust-lang/rust/issues/57015.
This PR stops overwriting real successful resolutions with `Def::Err`s.

Fixes https://github.com/rust-lang/rust/issues/57015
2018-12-30 03:12:16 +00:00
Esteban Küber
5a2c301106 Do not complain about missing crate named as a keyword 2018-12-29 17:23:19 -08:00
Czipperz
56d6ff0634 Mention ToString in std::fmt docs 2018-12-29 19:17:03 -05:00
Czipperz
445dadca33 Specify criterion for PartialOrd 2018-12-29 19:14:06 -05:00
bors
a35cf79fcb Auto merge of #56843 - csmoe:non-copy, r=davidtwco
Add a note describing the type of the non-Copy moved variable

Closes #56654
r?@davidtwco
2018-12-29 23:45:45 +00:00
Czipperz
cf3959c5b0 Make std::cmp::Ord documentation specify what it means to agree with PartialEq 2018-12-29 17:48:43 -05:00
Vadim Petrochenkov
df4690ddf4 Improve error recovery for some built-in macros 2018-12-30 01:43:35 +03:00
Simonas Kazlauskas
087083e8a4 Remove mention of required memory to build
Because it, obviously, changes all the time and 600MiB is way
out-of-date now.
2018-12-30 00:17:31 +02:00
bors
59183180f7 Auto merge of #56225 - alexreg:type_alias_enum_variants, r=petrochenkov
Implement RFC 2338, "Type alias enum variants"

This PR implements [RFC 2338](https://github.com/rust-lang/rfcs/pull/2338), allowing one to write code like the following.

```rust
#![feature(type_alias_enum_variants)]

enum Foo {
    Bar(i32),
    Baz { i: i32 },
}

type Alias = Foo;

fn main() {
    let t = Alias::Bar(0);
    let t = Alias::Baz { i: 0 };
    match t {
        Alias::Bar(_i) => {}
        Alias::Baz { i: _i } => {}
    }
}
```

Since `Self` can be considered a type alias in this context, it also enables using `Self::Variant` as both a constructor and pattern.

Fixes issues #56199 and #56611.

N.B., after discussing the syntax for type arguments on enum variants with @petrochenkov and @eddyb (there are also a few comments on the [tracking issue](https://github.com/rust-lang/rust/issues/49683)), the consensus seems to be treat the syntax as follows, which ought to be backwards-compatible.

```rust
Option::<u8>::None; // OK
Option::None::<u8>; // OK, but lint in near future (hard error next edition?)
Alias::<u8>::None; // OK
Alias::None::<u8>; // Error
```

I do not know if this will need an FCP, but let's start one if so.
2018-12-29 21:03:11 +00:00
Esteban Küber
0ecc128ccb Use same_type instead of duplicating logic 2018-12-29 10:54:32 -08:00
bors
007115746c Auto merge of #57197 - kennytm:rollup, r=kennytm
Rollup of 7 pull requests

Successful merges:

 - #57149 (Fix typo in pin documentation)
 - #57153 (Small: Fix span in char documentation)
 - #57159 (Update references to closed issue)
 - #57163 (Give the crate select chevron room to breathe.)
 - #57168 (Removed aligned ZST requirement from docs of read_/write_unaligned.)
 - #57174 (Update link to rustc guide)
 - #57177 (Fix warning when compiling rustc)

Failed merges:

r? @ghost
2018-12-29 18:12:57 +00:00
Vadim Petrochenkov
06f22ba427 resolve: Simplify treatment of ambiguity errors 2018-12-29 19:26:29 +03:00
bors
d969c61e8c Auto merge of #56924 - ehuss:update-cargo-rls-miri, r=alexcrichton
Update cargo, rls, miri

Update cargo, rls, miri

Added `rustc-workspace-hack` to miri so that it shares the same features for serde as other tools.

cc @alexcrichton

## cargo

25 commits in 2cf1f5dda2f7ed84e94c4d32f643e0f1f15352f0..0d1f1bbeabd5b43a7f3ecfa16540af8e76d5efb4
2018-12-11 03:44:04 +0000 to 2018-12-19 14:45:14 +0000
- Remove Stale bot's configuration (rust-lang/cargo#6463)
- Add labels to issue templates (rust-lang/cargo#6464)
- Fix new man page links. (rust-lang/cargo#6459)
- Fix metabuild compile errors with --message-format=json. (rust-lang/cargo#6432)
- Support alt-registry names in [patch] table. (rust-lang/cargo#6456)
- Update the rustup URL (rust-lang/cargo#6455)
- New man pages. (rust-lang/cargo#6405)
- Reify the DepFingerprint type (rust-lang/cargo#6451)
- Extract Fingerprint::new (rust-lang/cargo#6449)
- Upgrade the metabuild to Rust 2018 (rust-lang/cargo#6448)
- Make edition comparing code consistent (rust-lang/cargo#6450)
- Document `name` and `authors` in [package] (rust-lang/cargo#6447)
- Travis: only use mdbook 0.1.7. (rust-lang/cargo#6443)
- Update git2-curl requirement from 0.8.1 to 0.9.0 (rust-lang/cargo#6439)
- Update git2 requirement from 0.7.5 to 0.8.0 (rust-lang/cargo#6438)
- Display errors when `cargo fix` fails. (rust-lang/cargo#6419)
- cargo fix: fix targets with shared sources. (rust-lang/cargo#6434)
- Fix panic-in-panic in tests. (rust-lang/cargo#6431)
- More Rust 2018 edition cleanups (rust-lang/cargo#6422)
- Cleanup some trait impls for SourceId (rust-lang/cargo#6429)
- Remove a nightly check from doc tests (rust-lang/cargo#6427)
- Replace CargoError with failure::Error (rust-lang/cargo#6425)
- Allow testsuite warnings in dev (rust-lang/cargo#6426)
- add `--dry-run` option to cargo update (rust-lang/cargo#6371)
- Migrate to some Rust 2018 idioms (rust-lang/cargo#6416)

## rls

16 commits in bd5b899afb05e14d33e210ede3da241ca1ca088f..6f5e4bba7b1586fca6e0ea7724cadb5683b2f308
2018-12-10 08:53:00 +0100 to 2018-12-21 17:11:08 +0100
- Update jsonrpc-core (rust-lang-nursery/rls#1206)
- Use `home_dir` from `home` crate (rust-lang-nursery/rls#1207)
- Update cargo. (rust-lang-nursery/rls#1204)
- Fix deprecated `trim_{left,right}` warnings (rust-lang-nursery/rls#1203)
- Respect ${CARGO,RUSTUP}_HOME for tooltip relative dirs (rust-lang-nursery/rls#1201)
- Separate tooltip tests that require Racer fallback (rust-lang-nursery/rls#1200)
- tests: Don't generate tooltip results in tests/fixtures (rust-lang-nursery/rls#1199)
- Overhaul fixture handling in tests (rust-lang-nursery/rls#1190)
- Don't return symbols with empty names (rust-lang-nursery/rls#1193)
- Don't check AppVeyor CI status for bors
- Properly infer full_docs (rust-lang-nursery/rls#1192)
- Update cargo (rust-lang-nursery/rls#1191)
- Improve hover test_tooltip tests (rust-lang-nursery/rls#1175)
- Fix unused warnings (rust-lang-nursery/rls#1185)
- Workaround rust-lang-nursery/rls#703 to prevent obscure failures due to sccache. (rust-lang-nursery/rls#1177)
- Disable travis cache (rust-lang-nursery/rls#1182)

## miri

14 commits in bccadeb4f7cbeeb14097a365653148afe8bbd159..6c2fc6daf1ac6849d1243b213f5a3fb07feeef29
2018-12-08 11:07:22 +0100 to 2018-12-26 14:28:25 +0100
- use memory::check_bounds_ptr for offset check (solson/miri#589)
- Fix comparing function pointers (solson/miri#587)
- fix for infallible allocation (solson/miri#586)
- fix test for latest nightly (solson/miri#585)
- Treat ref-to-raw cast like a reborrow: do a special kind of retag (solson/miri#572)
- Test cargo-miri on Windows (solson/miri#578)
- Cargo miri tweaks and test that we can exclude tests (solson/miri#580)
- Fix cargo miri test (solson/miri#550)
- fix for latest nightly (solson/miri#574)
- Add rustc-workspace-hack. (solson/miri#575)
- use RUSTC_WRAPPER for the cargo hook (solson/miri#573)
- do not auto-detect the targets in the sysroot, instead specify target manually through env var (solson/miri#570)
- Cleanup: Avoid repeating signatures, get rid of to_bytes hack (solson/miri#568)
- Support building and running with full MIR on foreign architectures, drop support for missing MIR (solson/miri#566)
2018-12-29 15:35:59 +00:00
bors
419044956a Auto merge of #57181 - petrochenkov:impice3, r=estebank
resolve: Fix another ICE in import validation

Imports are allowed to have ambiguous resolutions as long as all of them have same `Def`.
As it turned out, it's possible for different `Module`s to have same `Def` when `extern crate` items are involved.

Fixes https://github.com/rust-lang/rust/issues/56596
2018-12-29 12:55:48 +00:00
Matthew Jasper
49e52e71de Remove unused types from rustc::mir::interpret
The types are no longer used with the change to stacked borrows for
validation.
2018-12-29 11:55:00 +00:00
kennytm
68f370ce05
Rollup merge of #57177 - varkor:fix-duration_as_u128-warning, r=estebank
Fix warning when compiling rustc
2018-12-29 18:50:32 +08:00
kennytm
aed3eaafee
Rollup merge of #57174 - linclark:patch-1, r=varkor
Update link to rustc guide
2018-12-29 18:50:30 +08:00
kennytm
9a67b18888
Rollup merge of #57168 - kennytm:fix-unaligned-docs, r=rkruppe
Removed aligned ZST requirement from docs of read_/write_unaligned.

This is just a copy-paste error.
2018-12-29 18:50:29 +08:00
kennytm
af56d2bf1a
Rollup merge of #57163 - JohnHeitmann:chevron-fix, r=estebank
Give the crate select chevron room to breathe.

Before:
![screen shot 2018-12-27 at 10 26 10 pm](https://user-images.githubusercontent.com/4282480/50505100-9ff24300-0a26-11e9-9b74-37bdee6faf83.png)

After:
![screen shot 2018-12-27 at 10 25 57 pm](https://user-images.githubusercontent.com/4282480/50505110-a54f8d80-0a26-11e9-9fa2-7fed21773207.png)
2018-12-29 18:50:28 +08:00
kennytm
291d51c92d
Rollup merge of #57159 - ids1024:closed-issue, r=Centril
Update references to closed issue

Issue #28979 was closed with a link to #55467.
2018-12-29 18:50:27 +08:00
kennytm
97e591ae0c
Rollup merge of #57153 - estebank:doc, r=cramertj
Small: Fix span in char documentation
2018-12-29 18:50:26 +08:00
kennytm
72b27a7254
Rollup merge of #57149 - rust-lang:sgrif-patch-1, r=rkruppe
Fix typo in pin documentation

Affect is a verb, effect is a noun
2018-12-29 18:50:24 +08:00
bors
d5175f4405 Auto merge of #57160 - petrochenkov:impice2, r=estebank
resolve: Fix an ICE in import validation

Fixes ICE reported in the comment https://github.com/rust-lang/rust/issues/56596#issuecomment-449866807
2018-12-29 10:17:10 +00:00
Matthias Krüger
8d727b267d update tests line numbers 2018-12-29 08:52:25 +01:00
bors
35a64f8bbf Auto merge of #57140 - estebank:str-err, r=varkor
Tweaks to format string diagnostics

Add label spans and fix incorrect spans.

Fix #55155, fix #55350.
2018-12-29 07:28:15 +00:00
Alexander Regueiro
a4fa7ef2b9 Fixed stderr files for ui tests. 2018-12-29 05:45:45 +00:00
csmoe
48de0ff333 add non-copy note to stderr 2018-12-29 10:36:23 +08:00
Eric Huss
5739364784 Update cargo, rls, miri 2018-12-28 17:23:01 -08:00
bors
43d26b1f35 Auto merge of #57006 - GuillaumeGomez:no-crate-filter, r=QuietMisdreavus
Add no-crate filter option on rustdoc

@onur asked me about it so here it is!

r? @QuietMisdreavus
2018-12-29 01:22:04 +00:00
Vadim Petrochenkov
ddb550a0e3 resolve: Never override real bindings with Def::Errs from error recovery 2018-12-29 03:04:25 +03:00
Matthew Jasper
2149d73358 Remove unnecessary borrow generation 2018-12-28 23:39:14 +00:00
bors
d9e3edb74b Auto merge of #57138 - matthiaskrgr:clippy, r=oli-obk
submodules: update clippy from fc24fce7 to 721f688e

Fixes clippy toolstate.

Changes:
````
rustup https://github.com/rust-lang/rust/pull/57069
Rustfmt.
fix breakage from rust-lang/rust#57088
fix a couple of ftrivial typos (NFC).
update CARGO_CLIPPY_HELP string to suggest tool lints.
rustc_tools_util: add readme
rustc_tool_utils: expand Cargo.toml with a few keywords in preparation for crates.io release
Fix macro detection in `empty_loop`.
Changed `macro_backtrace()` to `in_macro()`.
Fix lint detection on macro expansion.
````

r? @oli-obk
2018-12-28 22:41:04 +00:00
Vadim Petrochenkov
2af1d6f4dd resolve: Fix another ICE in import validation 2018-12-29 00:15:19 +03:00
Matthias Krüger
68860989eb remove remaining copyright headers 2018-12-28 21:50:33 +01:00
bors
60e825389d Auto merge of #57118 - Zoxc:query-stats, r=wesleywiser
Add a command line flag to print some query stats

r? @michaelwoerister
2018-12-28 20:02:23 +00:00
varkor
04c1a92fa0 Fix warning when compiling rustc 2018-12-28 19:28:57 +00:00
varkor
d178fce5fc Add specific diagnostic for transmuting between equal associated types 2018-12-28 19:23:22 +00:00
varkor
6cb1d953fd Clarify wording of E0512 2018-12-28 19:23:22 +00:00
Esteban Küber
8da6727e96 Suggest .as_ref() when appropriate for Option and Result 2018-12-28 11:16:23 -08:00