Commit Graph

4068 Commits

Author SHA1 Message Date
Vadim Petrochenkov
8b1c424b6d privacy: Use common DefId visiting infra for all privacy visitors 2019-01-01 01:39:55 +03:00
bors
aeed63bf38 Auto merge of #57208 - estebank:issue-57198, r=petrochenkov
Do not complain about missing crate named as a keyword

Fix #57198.
2018-12-31 08:06:15 +00:00
bors
f39bd9b9cb Auto merge of #57044 - varkor:E0512-equal-type, r=matthewjasper
Add specific diagnostic when attempting to transmute between equal generic types

Also clarifies the wording of E0512.

Fixes https://github.com/rust-lang/rust/issues/49793.
2018-12-31 04:06:14 +00:00
varkor
7d5f6ceef0 Fix variable string size problem in transmute test 2018-12-30 23:45:58 +00:00
bors
953a9cf10d Auto merge of #57205 - petrochenkov:extrecov, r=estebank
Improve error recovery for some built-in macros

Fixes https://github.com/rust-lang/rust/issues/55897
2018-12-30 16:06:30 +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
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
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
Vadim Petrochenkov
df4690ddf4 Improve error recovery for some built-in macros 2018-12-30 01:43:35 +03: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
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
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
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
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
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
Vadim Petrochenkov
ddb550a0e3 resolve: Never override real bindings with Def::Errs from error recovery 2018-12-29 03:04:25 +03:00
Vadim Petrochenkov
2af1d6f4dd resolve: Fix another ICE in import validation 2018-12-29 00:15:19 +03: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
Oliver Scherer
39f95fa7c7
Update src/test/ui/consts/const-nonzero.rs
Co-Authored-By: Dylan-DPC <dylan.dpc@gmail.com>
2018-12-28 17:45:49 +05:30
dylan_DPC
d11a58b676 Make the getter for NonZero types into a const fn 2018-12-28 16:58:55 +05:30
bors
e8ca35e63d 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
2018-12-28 02:54:14 +00:00
Vadim Petrochenkov
ce73bc7d47 resolve: Fix an ICE in import validation 2018-12-28 05:43:31 +03:00
Ian Douglas Scott
0c58eec86c
Update references to closed issue
Issue #28979 was closed with a link to #55467.
2018-12-27 16:49:12 -08:00
bors
f8caa321c7 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.
2018-12-27 22:27:27 +00:00
Vadim Petrochenkov
e40d7d9643 Resolve $crates for pretty-printing at more appropriate time 2018-12-28 00:44:47 +03:00
Vadim Petrochenkov
24af9f88a5 Add test demonstrating disintegration of $crate into $ and crate 2018-12-28 00:34:24 +03:00
scalexm
993d213fda Set a def_id in ParamEnv only with -Z chalk 2018-12-27 19:21:17 +01:00
scalexm
81d6f9cc81 Add tests 2018-12-27 19:21:16 +01:00
Vadim Petrochenkov
bc16edeb28 Fix rebase and more CI failures 2018-12-27 15:51:37 +03:00
Vadim Petrochenkov
37af04ff8d Address review comments and CI failures 2018-12-27 15:51:37 +03:00
Vadim Petrochenkov
15cefe4b2a Make sure feature gate errors are recoverable 2018-12-27 15:51:37 +03:00
Vadim Petrochenkov
4ac592516f Get rid of Block::recovered 2018-12-27 15:51:36 +03:00
Vadim Petrochenkov
fff01ccfa8 Do not abort compilation if expansion produces errors
Fix a number of uncovered deficiencies in diagnostics
2018-12-27 15:51:36 +03:00
bors
d174173552 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.
2018-12-27 12:01:08 +00:00
csmoe
8d77c7c037 retrieve ty info from place_ty
describe index with _
2018-12-27 17:25:45 +08:00
Esteban Küber
5e952e3479 Add span label to unused string formatting argument
Fix #55350.
2018-12-26 20:36:02 -08:00
Esteban Küber
5e75001c59 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.
2018-12-26 20:36:02 -08:00
Esteban Küber
862ebc4c38 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
2018-12-26 14:29:43 -08:00
Alexander Regueiro
5adf8c358a Changed resolution of enum variants to low priority. 2018-12-26 21:56:47 +00:00
Alexander Regueiro
67a30d2d70 Fixed ICE when type arguments are specified on Self type. 2018-12-26 21:54:18 +00:00
Alexander Regueiro
6a3f96d302 Fixed type inference for tuple struct variants. 2018-12-26 21:54:18 +00:00
Alexander Regueiro
fa07e62389 Fixed handling of unit variants of aliased enums in type NS. 2018-12-26 21:54:18 +00:00
Alexander Regueiro
8eb1a9e4e7 Added regression test for using generic parameters on modules. 2018-12-26 21:54:18 +00:00
Alexander Regueiro
5a36f9e6e1 Fixed several ICEs. 2018-12-26 21:40:22 +00:00
Alexander Regueiro
37e7f0a629 Expanded tests for enum variants with generic args. 2018-12-26 21:40:22 +00:00