]> git.lizzy.rs Git - rust.git/log
rust.git
5 years agoStop well-formedness checking unreachable code.
David Wood [Tue, 18 Dec 2018 20:27:22 +0000 (21:27 +0100)]
Stop well-formedness checking unreachable code.

This commit stops well-formedness checking applying to unreachable code
and therefore stops some of the ICEs that the intended solution taken by
this PR causes.

By disabling these checks, we can land the other fixes and larger
refactors that this PR includes.

5 years agoFix unresolved inference variable ICE.
David Wood [Sun, 9 Dec 2018 02:07:31 +0000 (03:07 +0100)]
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

5 years agoAdd explicit error annotations to test.
David Wood [Fri, 7 Dec 2018 23:50:35 +0000 (00:50 +0100)]
Add explicit error annotations to test.

This commit adds explicit error annotations to tests after rebasing
which is now required.

5 years agoSupport user type annotations in `ref` bindings.
David Wood [Sun, 25 Nov 2018 14:14:39 +0000 (15:14 +0100)]
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.

5 years agoAdd user type annotations to MIR dump.
David Wood [Sun, 25 Nov 2018 12:31:34 +0000 (13:31 +0100)]
Add user type annotations to MIR dump.

This commit writes the user type annotations to the MIR dump so that
they are visible again.

5 years agoType annotations in associated constant patterns.
David Wood [Sat, 24 Nov 2018 11:56:24 +0000 (12:56 +0100)]
Type annotations in associated constant patterns.

This commit adds support for respecting user type annotations with
associated constants in patterns.

5 years agoAdd test for unreachable well-formedness.
David Wood [Fri, 23 Nov 2018 10:55:09 +0000 (11:55 +0100)]
Add test for unreachable well-formedness.

This commit adds a test for checking that types are well-formed when
unreachable.

5 years agoAlways check well-formedness.
David Wood [Thu, 22 Nov 2018 19:35:24 +0000 (20:35 +0100)]
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.

5 years agoRefactor `UserTypeAnnotation`.
David Wood [Fri, 16 Nov 2018 21:56:18 +0000 (22:56 +0100)]
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.

5 years agoAuto merge of #57158 - estebank:as-ref, r=zackmdavis
bors [Sun, 30 Dec 2018 09:51:44 +0000 (09:51 +0000)]
Auto merge of #57158 - estebank:as-ref, r=zackmdavis

Suggest `.as_ref()` when appropriate for `Option` and `Result`

Fix #55198.

5 years agoAuto merge of #57195 - czipperz:mention_ToString_in_std_fmt_docs, r=SimonSapin
bors [Sun, 30 Dec 2018 07:12:13 +0000 (07:12 +0000)]
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

5 years agoAuto merge of #57185 - petrochenkov:impice4, r=estebank
bors [Sun, 30 Dec 2018 03:12:16 +0000 (03:12 +0000)]
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

5 years agoMention ToString in std::fmt docs
Czipperz [Sat, 29 Dec 2018 07:54:05 +0000 (02:54 -0500)]
Mention ToString in std::fmt docs

5 years agoAuto merge of #56843 - csmoe:non-copy, r=davidtwco
bors [Sat, 29 Dec 2018 23:45:45 +0000 (23:45 +0000)]
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

5 years agoAuto merge of #56225 - alexreg:type_alias_enum_variants, r=petrochenkov
bors [Sat, 29 Dec 2018 21:03:11 +0000 (21:03 +0000)]
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.

5 years agoUse `same_type` instead of duplicating logic
Esteban Küber [Sat, 29 Dec 2018 18:54:32 +0000 (10:54 -0800)]
Use `same_type` instead of duplicating logic

5 years agoAuto merge of #57197 - kennytm:rollup, r=kennytm
bors [Sat, 29 Dec 2018 18:12:57 +0000 (18:12 +0000)]
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

5 years agoAuto merge of #56924 - ehuss:update-cargo-rls-miri, r=alexcrichton
bors [Sat, 29 Dec 2018 15:35:59 +0000 (15:35 +0000)]
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)

5 years agoAuto merge of #57181 - petrochenkov:impice3, r=estebank
bors [Sat, 29 Dec 2018 12:55:48 +0000 (12:55 +0000)]
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

5 years agoRollup merge of #57177 - varkor:fix-duration_as_u128-warning, r=estebank
kennytm [Sat, 29 Dec 2018 10:50:32 +0000 (18:50 +0800)]
Rollup merge of #57177 - varkor:fix-duration_as_u128-warning, r=estebank

Fix warning when compiling rustc

5 years agoRollup merge of #57174 - linclark:patch-1, r=varkor
kennytm [Sat, 29 Dec 2018 10:50:30 +0000 (18:50 +0800)]
Rollup merge of #57174 - linclark:patch-1, r=varkor

Update link to rustc guide

5 years agoRollup merge of #57168 - kennytm:fix-unaligned-docs, r=rkruppe
kennytm [Sat, 29 Dec 2018 10:50:29 +0000 (18:50 +0800)]
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.

5 years agoRollup merge of #57163 - JohnHeitmann:chevron-fix, r=estebank
kennytm [Sat, 29 Dec 2018 10:50:28 +0000 (18:50 +0800)]
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)

5 years agoRollup merge of #57159 - ids1024:closed-issue, r=Centril
kennytm [Sat, 29 Dec 2018 10:50:27 +0000 (18:50 +0800)]
Rollup merge of #57159 - ids1024:closed-issue, r=Centril

Update references to closed issue

Issue #28979 was closed with a link to #55467.

5 years agoRollup merge of #57153 - estebank:doc, r=cramertj
kennytm [Sat, 29 Dec 2018 10:50:26 +0000 (18:50 +0800)]
Rollup merge of #57153 - estebank:doc, r=cramertj

Small: Fix span in char documentation

5 years agoRollup merge of #57149 - rust-lang:sgrif-patch-1, r=rkruppe
kennytm [Sat, 29 Dec 2018 10:50:24 +0000 (18:50 +0800)]
Rollup merge of #57149 - rust-lang:sgrif-patch-1, r=rkruppe

Fix typo in pin documentation

Affect is a verb, effect is a noun

5 years agoAuto merge of #57160 - petrochenkov:impice2, r=estebank
bors [Sat, 29 Dec 2018 10:17:10 +0000 (10:17 +0000)]
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

5 years agoAuto merge of #57140 - estebank:str-err, r=varkor
bors [Sat, 29 Dec 2018 07:28:15 +0000 (07:28 +0000)]
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.

5 years agoFixed stderr files for ui tests.
Alexander Regueiro [Sat, 29 Dec 2018 05:45:45 +0000 (05:45 +0000)]
Fixed stderr files for ui tests.

5 years agoadd non-copy note to stderr
csmoe [Thu, 27 Dec 2018 11:08:51 +0000 (19:08 +0800)]
add non-copy note to stderr

5 years agoUpdate cargo, rls, miri
Eric Huss [Mon, 17 Dec 2018 18:23:04 +0000 (10:23 -0800)]
Update cargo, rls, miri

5 years agoAuto merge of #57006 - GuillaumeGomez:no-crate-filter, r=QuietMisdreavus
bors [Sat, 29 Dec 2018 01:22:04 +0000 (01:22 +0000)]
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

5 years agoresolve: Never override real bindings with `Def::Err`s from error recovery
Vadim Petrochenkov [Fri, 28 Dec 2018 23:48:38 +0000 (02:48 +0300)]
resolve: Never override real bindings with `Def::Err`s from error recovery

5 years agoAuto merge of #57138 - matthiaskrgr:clippy, r=oli-obk
bors [Fri, 28 Dec 2018 22:41:04 +0000 (22:41 +0000)]
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

5 years agoresolve: Fix another ICE in import validation
Vadim Petrochenkov [Fri, 28 Dec 2018 21:15:19 +0000 (00:15 +0300)]
resolve: Fix another ICE in import validation

5 years agoAuto merge of #57118 - Zoxc:query-stats, r=wesleywiser
bors [Fri, 28 Dec 2018 20:02:23 +0000 (20:02 +0000)]
Auto merge of #57118 - Zoxc:query-stats, r=wesleywiser

Add a command line flag to print some query stats

r? @michaelwoerister

5 years agoFix warning when compiling rustc
varkor [Fri, 28 Dec 2018 19:28:57 +0000 (19:28 +0000)]
Fix warning when compiling rustc

5 years agoSuggest `.as_ref()` when appropriate for `Option` and `Result`
Esteban Küber [Fri, 28 Dec 2018 01:04:58 +0000 (17:04 -0800)]
Suggest `.as_ref()` when appropriate for `Option` and `Result`

5 years agoUpdate link to rustc guide
Lin Clark [Fri, 28 Dec 2018 18:34:00 +0000 (13:34 -0500)]
Update link to rustc guide

5 years agosubmodules: update clippy from fc24fce7 to f7bdf500
Matthias Krüger [Thu, 27 Dec 2018 16:34:48 +0000 (17:34 +0100)]
submodules: update clippy from  fc24fce7 to f7bdf500

Fixes clippy toolstate

Changes:
````
Match on ast/hir::ExprKind::Err
Update *.stderr files
Use -Zui-testing flag
Mention S-inactive-closed PRs in the CONTRIBUTING.md
tests: fix formatting and update test output
base tests: make sure to fail CI if tests need formatting
base tests: switch to nightly toolchain before checking formatting of tests with rustfmt
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.
````

5 years agoAuto merge of #57167 - Dylan-DPC:feature/non-zero-getters, r=SimonSapin
bors [Fri, 28 Dec 2018 15:10:17 +0000 (15:10 +0000)]
Auto merge of #57167 - Dylan-DPC:feature/non-zero-getters, r=SimonSapin

Make the getter for NonZero types into a const fn

Closes https://github.com/rust-lang/rust/issues/53331

Rework of #56739

cc @Lokathor

r? @oli-obk

5 years agoRemoved aligned ZST requirement from docs of read_/write_unaligned.
kennytm [Fri, 28 Dec 2018 14:00:33 +0000 (22:00 +0800)]
Removed aligned ZST requirement from docs of read_/write_unaligned.

This is just a copy-paste error.

5 years agoUpdate src/test/ui/consts/const-nonzero.rs
Oliver Scherer [Fri, 28 Dec 2018 12:15:49 +0000 (17:45 +0530)]
Update src/test/ui/consts/const-nonzero.rs

Co-Authored-By: Dylan-DPC <dylan.dpc@gmail.com>
5 years agoMake the getter for NonZero types into a const fn
dylan_DPC [Fri, 28 Dec 2018 11:28:55 +0000 (16:58 +0530)]
Make the getter for NonZero types into a const fn

5 years agoAuto merge of #57137 - cramertj:unpin-prelude, r=SimonSapin
bors [Fri, 28 Dec 2018 10:54:16 +0000 (10:54 +0000)]
Auto merge of #57137 - cramertj:unpin-prelude, r=SimonSapin

Add Unpin to std prelude, not just core

r? @alexcrichton

5 years agoAuto merge of #55519 - fhartwig:hashmap-index-example, r=Centril
bors [Fri, 28 Dec 2018 06:52:15 +0000 (06:52 +0000)]
Auto merge of #55519 - fhartwig:hashmap-index-example, r=Centril

Add example of using the indexing operator to HashMap docs

Fixes #52575

5 years agoGive the crate select chevron room to breathe.
John Heitmann [Fri, 28 Dec 2018 06:26:54 +0000 (22:26 -0800)]
Give the crate select chevron room to breathe.

5 years agoAuto merge of #57155 - petrochenkov:dcrate3, r=dtolnay
bors [Fri, 28 Dec 2018 02:54:14 +0000 (02:54 +0000)]
Auto merge of #57155 - petrochenkov:dcrate3, r=dtolnay

Resolve `$crate`s for pretty-printing at more appropriate time

Doing it in `BuildReducedGraphVisitor` wasn't a good idea, identifiers wasn't actually visited half of the time.
As a result some `$crate`s weren't resolved and were therefore pretty-printed as `$crate` literally, which turns into two tokens during re-parsing of the pretty-printed text.

Now we are visiting and resolving `$crate` identifiers in an item right before sending that item to a proc macro attribute or derive.

Fixes https://github.com/rust-lang/rust/issues/57089

5 years agoresolve: Fix an ICE in import validation
Vadim Petrochenkov [Fri, 28 Dec 2018 02:20:11 +0000 (05:20 +0300)]
resolve: Fix an ICE in import validation

5 years agoUpdate references to closed issue
Ian Douglas Scott [Fri, 28 Dec 2018 00:49:12 +0000 (16:49 -0800)]
Update references to closed issue

Issue #28979 was closed with a link to #55467.

5 years agoAuto merge of #56999 - petrochenkov:macrecov2, r=estebank
bors [Thu, 27 Dec 2018 22:27:27 +0000 (22:27 +0000)]
Auto merge of #56999 - petrochenkov:macrecov2, r=estebank

AST/HIR: Introduce `ExprKind::Err` for better error recovery in the front-end

This way we can avoid aborting compilation if expansion produces errors and generate `ExprKind::Err`s instead.

5 years agoResolve `$crate`s for pretty-printing at more appropriate time
Vadim Petrochenkov [Thu, 27 Dec 2018 21:31:28 +0000 (00:31 +0300)]
Resolve `$crate`s for pretty-printing at more appropriate time

5 years agoAdd test demonstrating disintegration of `$crate` into `$` and `crate`
Vadim Petrochenkov [Thu, 27 Dec 2018 18:13:49 +0000 (21:13 +0300)]
Add test demonstrating disintegration of `$crate` into `$` and `crate`

5 years agoAuto merge of #56384 - scalexm:chalk, r=nikomatsakis
bors [Thu, 27 Dec 2018 19:47:56 +0000 (19:47 +0000)]
Auto merge of #56384 - scalexm:chalk, r=nikomatsakis

Implement the new-style trait solver

Final PR of what I believe to be a minimally working implementation of the new-style trait solver.

The new trait solver can be used by providing the `-Z chalk` command line flag. It is currently used everywhere in `rustc_typeck`, and for everything relying on `rustc::infer::canonical::query_response::enter_canonical_trait_query`.

The trait solver is invoked in rustc by using the `evaluate_goal` canonical query. This is not optimal because each call to `evaluate_goal` creates a new `chalk_engine::Forest`, hence rustc cannot use answers to intermediate goals produced by the root goal. We'll need to change that but I guess that's ok for now.

Some next steps, I think, are:
* handle region constraints: region constraints are computed but are completely ignored for now, I think we may need additional support from `chalk_engine` (as a side effect, types or trait references with outlive requirements cannot be proved well-formed)
* deactivate eager normalization in the presence of `-Z chalk` in order to leverage the lazy normalization strategy of the new-style trait solver
* add the remaining built-in impls (only `Sized` is supported currently)
* transition the compiler to using generic goals instead of predicates that still refer to named type parameters etc

I added a few very simple tests to check that the new solver has the right behavior, they won't be needed anymore once it is mature enough. Additionally it shows off that we get [implied bounds](https://github.com/rust-lang/rust/issues/44491) for free.

r? @nikomatsakis

5 years agoFix span in char documentation
Esteban Küber [Thu, 27 Dec 2018 19:36:05 +0000 (11:36 -0800)]
Fix span in char documentation

5 years agoSet a `def_id` in `ParamEnv` only with `-Z chalk`
scalexm [Thu, 20 Dec 2018 18:54:11 +0000 (19:54 +0100)]
Set a `def_id` in `ParamEnv` only with `-Z chalk`

5 years agoAdd tests
scalexm [Fri, 30 Nov 2018 14:07:38 +0000 (15:07 +0100)]
Add tests

5 years agoFix `tcx.environment` for inherent impls
scalexm [Fri, 30 Nov 2018 14:06:49 +0000 (15:06 +0100)]
Fix `tcx.environment` for inherent impls

5 years agoAdd `wf_clause_for_fn_def`
scalexm [Wed, 28 Nov 2018 22:29:26 +0000 (23:29 +0100)]
Add `wf_clause_for_fn_def`

5 years agoUse `TraitEngine` in `enter_canonical_trait_query`
scalexm [Wed, 28 Nov 2018 22:29:01 +0000 (23:29 +0100)]
Use `TraitEngine` in `enter_canonical_trait_query`

5 years agoHandle sub-typing in chalk-engine
scalexm [Wed, 28 Nov 2018 21:11:00 +0000 (22:11 +0100)]
Handle sub-typing in chalk-engine

5 years agoIntegrate chalk engine
scalexm [Sat, 24 Nov 2018 19:18:16 +0000 (20:18 +0100)]
Integrate chalk engine

5 years agoFix binding levels in implied bounds rules
scalexm [Sat, 24 Nov 2018 19:17:42 +0000 (20:17 +0100)]
Fix binding levels in implied bounds rules

5 years agoFix replacement of escaping bound types
scalexm [Sat, 24 Nov 2018 16:13:54 +0000 (17:13 +0100)]
Fix replacement of escaping bound types

Multiple references to the same `BoundTy` were not using the same
result.

5 years agoFix `Sized` requirement for empty tuples in `program_clauses`
scalexm [Fri, 23 Nov 2018 20:06:55 +0000 (21:06 +0100)]
Fix `Sized` requirement for empty tuples in `program_clauses`

5 years agoAdd builtin impls for `Sized` in `chalk_context::program_clauses`
scalexm [Fri, 23 Nov 2018 21:48:33 +0000 (22:48 +0100)]
Add builtin impls for `Sized` in `chalk_context::program_clauses`

5 years agoRename functions giving WF clauses for builtin types
scalexm [Fri, 23 Nov 2018 21:47:00 +0000 (22:47 +0100)]
Rename functions giving WF clauses for builtin types

5 years agoAdd utilities for creating generic types
scalexm [Fri, 23 Nov 2018 21:43:59 +0000 (22:43 +0100)]
Add utilities for creating generic types

5 years agoReturn an instantiated environment instead of a generic one
scalexm [Fri, 23 Nov 2018 20:03:27 +0000 (21:03 +0100)]
Return an instantiated environment instead of a generic one

5 years agoCorrectly lift empty lists of clauses and goals
scalexm [Fri, 23 Nov 2018 18:47:22 +0000 (19:47 +0100)]
Correctly lift empty lists of clauses and goals

5 years agoFix `visit_ex_clause_with`
scalexm [Fri, 23 Nov 2018 18:45:39 +0000 (19:45 +0100)]
Fix `visit_ex_clause_with`

The sub-visits were incorrectly combined with an `&&` instead of
an `||`.

5 years agoAdd a def-id in `ty::ParamEnv`
scalexm [Sat, 17 Nov 2018 17:56:14 +0000 (18:56 +0100)]
Add a def-id in `ty::ParamEnv`

5 years agoImplement "lifetime juggling" methods from chalk integration trait
scalexm [Fri, 23 Nov 2018 18:42:14 +0000 (19:42 +0100)]
Implement "lifetime juggling" methods from chalk integration trait

Fixes #55097.

5 years agoImplement `is_coinductive`
scalexm [Fri, 23 Nov 2018 18:16:02 +0000 (19:16 +0100)]
Implement `is_coinductive`

Fixes #55096.

5 years agoAuto merge of #56852 - kennytm:test-publish-toolstate-in-ci, r=Mark-Simulacrum
bors [Thu, 27 Dec 2018 17:16:59 +0000 (17:16 +0000)]
Auto merge of #56852 - kennytm:test-publish-toolstate-in-ci, r=Mark-Simulacrum

Added a job to dry-run the publish_toolstate.py once

Closes #56848.

Requires #56847 to be merged first.

5 years agoFix typo in pin documentation
Sean Griffin [Thu, 27 Dec 2018 15:53:43 +0000 (08:53 -0700)]
Fix typo in pin documentation

Affect is a verb, effect is a noun

5 years agoAuto merge of #56838 - Aaron1011:fix/rustdoc-infer-unify, r=nikomatsakis
bors [Thu, 27 Dec 2018 14:35:58 +0000 (14:35 +0000)]
Auto merge of #56838 - Aaron1011:fix/rustdoc-infer-unify, r=nikomatsakis

Call poly_project_and_unify_type on types that contain inference types

Commit f57247c48cb59 (Ensure that Rusdoc discovers all necessary auto
trait bounds) added a check to ensure that we only attempt to unify a
projection predicatre with inference variables. However, the check it
added was too strict - instead of checking that a type *contains* an
inference variable (e.g. '&_', 'MyType<_>'), it required the type to
*be* an inference variable (i.e. only '_' would match).

This commit relaxes the check to use 'ty.has_infer_types', ensuring that
we perform unification wherever possible.

Fixes #56822

5 years agoFix rebase and more CI failures
Vadim Petrochenkov [Thu, 27 Dec 2018 00:07:00 +0000 (03:07 +0300)]
Fix rebase and more CI failures

5 years agoAddress review comments and CI failures
Vadim Petrochenkov [Thu, 20 Dec 2018 23:58:55 +0000 (02:58 +0300)]
Address review comments and CI failures

5 years agoMake sure feature gate errors are recoverable
Vadim Petrochenkov [Thu, 20 Dec 2018 22:47:03 +0000 (01:47 +0300)]
Make sure feature gate errors are recoverable

5 years agoFix `trace_macros` and `log_syntax`
Vadim Petrochenkov [Thu, 20 Dec 2018 00:57:48 +0000 (03:57 +0300)]
Fix `trace_macros` and `log_syntax`

5 years agoGet rid of `Block::recovered`
Vadim Petrochenkov [Wed, 19 Dec 2018 23:33:56 +0000 (02:33 +0300)]
Get rid of `Block::recovered`

5 years agoDo not abort compilation if expansion produces errors
Vadim Petrochenkov [Sun, 16 Dec 2018 17:23:27 +0000 (20:23 +0300)]
Do not abort compilation if expansion produces errors

Fix a number of uncovered deficiencies in diagnostics

5 years agoAST/HIR: Introduce `ExprKind::Err` for better error recovery in the front-end
Vadim Petrochenkov [Mon, 17 Dec 2018 01:57:32 +0000 (04:57 +0300)]
AST/HIR: Introduce `ExprKind::Err` for better error recovery in the front-end

5 years agoAuto merge of #57133 - SimonSapin:zero, r=oli-obk
bors [Thu, 27 Dec 2018 12:01:08 +0000 (12:01 +0000)]
Auto merge of #57133 - SimonSapin:zero, r=oli-obk

Remove the private generic NonZero<T> wrapper type

Instead, use `#[rustc_layout_scalar_valid_range_start(1)]` directly on relevant libcore types.

5 years agoretrieve ty info from place_ty
csmoe [Thu, 27 Dec 2018 09:23:15 +0000 (17:23 +0800)]
retrieve ty info from place_ty
describe index with _

5 years agoAuto merge of #57119 - jethrogb:jb/sgx-os-mod2, r=joshtriplett
bors [Thu, 27 Dec 2018 09:21:06 +0000 (09:21 +0000)]
Auto merge of #57119 - jethrogb:jb/sgx-os-mod2, r=joshtriplett

Add `io` and `arch` modules to `std::os::fortanix_sgx`

This PR adds two more (unstable) modules to `std::os::fortanix_sgx` for the `x86_64-fortanix-unknown-sgx` target.

### io
`io` allows conversion between raw file descriptors and Rust types, similar to `std::os::unix::io`.

### arch
`arch` exposes the `ENCLU[EREPORT]` and `ENCLU[EGETKEY]` instructions. The current functions are very likely not going to be the final form of these functions (see also https://github.com/fortanix/rust-sgx/issues/15), but this should be sufficient to enable experimentation in libraries. I tried using the actual types (from the [`sgx-isa` crate](https://crates.io/crates/sgx-isa)) instead of byte arrays, but that would make `std` dependent on the `bitflags` crate which I didn't want to do at this time.

5 years agoAuto merge of #57129 - RalfJung:check-bounds, r=oli-obk
bors [Thu, 27 Dec 2018 06:48:18 +0000 (06:48 +0000)]
Auto merge of #57129 - RalfJung:check-bounds, r=oli-obk

make Alloc::check_bounds_ptr private; you should use Memory::check_bounds_ptr instead

r? @oli-obk

5 years agoAdded a job to dry-run the publish_toolstate.py once
kennytm [Sat, 15 Dec 2018 15:44:46 +0000 (23:44 +0800)]
Added a job to dry-run the publish_toolstate.py once

5 years agoAdd span label to unused string formatting argument
Esteban Küber [Thu, 27 Dec 2018 04:18:41 +0000 (20:18 -0800)]
Add span label to unused string formatting argument

Fix #55350.

5 years agoPoint at correct span for arguments in format strings
Esteban Küber [Thu, 27 Dec 2018 04:05:56 +0000 (20:05 -0800)]
Point at correct span for arguments in format strings

When a format string has escaped whitespace characters format
arguments were shifted by one per each escaped character. Account
for these escaped characters when synthesizing the spans.

Fix #55155.

5 years agoAuto merge of #57069 - estebank:str-err, r=@cramertj
bors [Thu, 27 Dec 2018 02:00:17 +0000 (02:00 +0000)]
Auto merge of #57069 - estebank:str-err, r=@cramertj

Various changes to string format diagnostics

- Point at opening mismatched formatting brace
- Account for differences between raw and regular strings
- Account for differences between the code snippet and `InternedString`
- Add more tests

```
error: invalid format string: expected `'}'`, found `'t'`
  --> $DIR/ifmt-bad-arg.rs:85:1
   |
LL | ninth number: {
   |               - because of this opening brace
LL | tenth number: {}",
   | ^ expected `}` in format string
   |
   = note: if you intended to print `{`, you can escape it using `{{`
```

Fix #53837.

5 years agoVarious changes to string format diagnostics
Esteban Küber [Fri, 21 Dec 2018 06:33:16 +0000 (22:33 -0800)]
Various changes to string format diagnostics

- Point at opening mismatched formatting brace
- Account for differences between raw and regular strings
- Account for differences between the code snippet and `InternedString`
- Add more tests

5 years agoAuto merge of #57124 - sunjay:stable_duration_as_u128, r=Centril
bors [Wed, 26 Dec 2018 22:19:40 +0000 (22:19 +0000)]
Auto merge of #57124 - sunjay:stable_duration_as_u128, r=Centril

Stabilize Duration::{as_millis, as_micros, as_nanos}

Fixes #50202. :tada:

This is the stabilization PR for the `duration_as_u128` feature. I have never made one of these before so please let me know if I missed a step. I followed the [guide in the Rust Forge](https://forge.rust-lang.org/stabilization-guide.html) and also found some old stabilization PRs ([1](https://github.com/rust-lang/rust/pull/57002), [2](https://github.com/rust-lang/rust/pull/56207)) for similar features to base my work on.

5 years agoChanged resolution of enum variants to low priority.
Alexander Regueiro [Wed, 26 Dec 2018 16:38:35 +0000 (16:38 +0000)]
Changed resolution of enum variants to low priority.

5 years agoMinor cosmetic changes
Alexander Regueiro [Wed, 26 Dec 2018 16:15:42 +0000 (16:15 +0000)]
Minor cosmetic changes

5 years agoMinor clean-up
Alexander Regueiro [Wed, 26 Dec 2018 00:07:31 +0000 (00:07 +0000)]
Minor clean-up

5 years agoFixed ICE when type arguments are specified on `Self` type.
Alexander Regueiro [Thu, 20 Dec 2018 18:38:55 +0000 (18:38 +0000)]
Fixed ICE when type arguments are specified on `Self` type.

5 years agoFixed type inference for tuple struct variants.
Alexander Regueiro [Thu, 20 Dec 2018 03:26:07 +0000 (03:26 +0000)]
Fixed type inference for tuple struct variants.

5 years agoFixed handling of unit variants of aliased enums in type NS.
Alexander Regueiro [Tue, 18 Dec 2018 18:59:00 +0000 (18:59 +0000)]
Fixed handling of unit variants of aliased enums in type NS.