Commit Graph

449 Commits

Author SHA1 Message Date
Mark Simulacrum
b5b7266b78 Rollup merge of #42959 - SimonSapin:nonzero-checked, r=sfackler
Make the "main" constructors of NonZero/Shared/Unique return Option

Per discussion in https://github.com/rust-lang/rust/issues/27730#issuecomment-303939441.

This is a breaking change to unstable APIs.

The old behavior is still available under the name `new_unchecked`. Note that only that one can be `const fn`, since `if` is currently not allowed in constant contexts.

In the case of `NonZero` this requires adding a new `is_zero` method to the `Zeroable` trait. I mildly dislike this, but it’s not much worse than having a `Zeroable` trait in the first place. `Zeroable` and `NonZero` are both unstable, this can be reworked later.
2017-07-26 06:15:01 -06:00
bors
afe145d227 Auto merge of #43096 - estebank:ascription-help, r=nikomatsakis
Point at `:` when using it instead of `;`

When triggering type ascription in such a way that we can infer a
statement end was intended, add a suggestion for the change. Always
point out the reason for the expectation of a type is due to type
ascription.

Fix #42057, #41928.
2017-07-23 20:56:20 +00:00
bors
f3e26a02eb Auto merge of #43386 - oli-obk:suggestions, r=nikomatsakis
Adjust new suggestions to the suggestion guidelines

Addresses https://github.com/rust-lang/rust/pull/42033#discussion_r127694915

guidelines are https://github.com/rust-lang/rust/blob/master//src/librustc_errors/diagnostic.rs#L212-L224
2017-07-23 18:13:20 +00:00
Simon Sapin
0d1864b8cf Remove unnecessary unsafe in test/ui/print_type_sizes/nullable.rs 2017-07-22 20:38:40 +02:00
Simon Sapin
ff7f220a43 Don’t create NonZero(0) in test/ui/print_type_sizes/nullable.rs 2017-07-22 20:38:40 +02:00
Simon Sapin
0a08ad0443 Rename {NonZero,Shared,Unique}::new to new_unchecked 2017-07-22 20:38:16 +02:00
bors
35f64996ad Auto merge of #43352 - estebank:macro-span-replacement, r=petrochenkov
Use the macro structure spans instead of the invocation

Fix #42104, CC #2887.
2017-07-22 13:30:19 +00:00
bors
066a0ae99b Auto merge of #43343 - petrochenkov:methlife3, r=estebank
Add an extra note to `late_bound_lifetime_arguments` error/lint

Fixes https://github.com/rust-lang/rust/issues/42868#issuecomment-316368538
2017-07-22 08:36:11 +00:00
bors
f0b07cac2f Auto merge of #43323 - perryprog:master, r=estebank
Less verbose output for unused arguments

Closes #37718

This is my first contribution to rust, so sorry if I'm missing anything!

The output now looks like this:
<img width="831" alt="screen shot 2017-07-18 at 5 01 32 pm" src="https://user-images.githubusercontent.com/12972285/28347566-dbfa9962-6c05-11e7-8730-c2e8062a04cc.png">

It's not the prettiest, but whenever #41850 gets resolved, this should be able to be improved.

**EDIT:** This also does not seem
r? @Mark-Simulacrum
2017-07-22 04:41:10 +00:00
Perry Fraser
5c10db3f94 More tests 2017-07-21 18:11:44 -04:00
Oliver Schneider
401ab612c2 Adjust new suggestions to the suggestion guidelines 2017-07-21 13:59:17 +02:00
Esteban Küber
09c712dae3 Fix test 2017-07-20 21:28:53 -07:00
Esteban Küber
e99d309c56 Use the macro structure spans instead of the invocation 2017-07-20 21:27:22 -07:00
bors
1beaea26ff Auto merge of #43251 - gaurikholkar:span_reorder, r=nikomatsakis
Reorder span suggestions to appear below main labels

A fix to #41698

r? @nikomatsakis
2017-07-20 03:36:14 +00:00
Vadim Petrochenkov
18d9701645 Add an extra note to late_bound_lifetime_arguments error/lint 2017-07-19 23:12:58 +03:00
bors
582af6e1ad Auto merge of #43178 - zackmdavis:some_suggestion, r=eddyb
suggest one-argument enum variant to fix type mismatch when applicable

Following @est31's [suggestion](https://github.com/rust-lang/rust/issues/42764#issuecomment-309680886).

![some_suggestion](https://user-images.githubusercontent.com/1076988/28101064-ee83f51e-667a-11e7-9e4f-d8f9eb2fb6c3.png)

Resolves #42764.
2017-07-19 20:12:56 +00:00
Perry Fraser
0fcb4fca19 Change the error message for multiple unused print params 2017-07-18 22:06:24 -04:00
Esteban Küber
e39bcecf79 Handle type ascription cases with a method call instead of a type 2017-07-18 13:33:36 -07:00
gaurikholkar
26a8357f5c reorder span labels 2017-07-18 00:07:37 +05:30
Esteban Küber
faf90351b7 Add flag to hide code on inline suggestions
Now there's a way to add suggestions that hide the suggested code when
presented inline, to avoid weird wording when short code snippets are
added at the end.
2017-07-17 09:27:51 -07:00
bors
028569ab1b Auto merge of #43266 - feadoor:issue-43253-exclusive-range-warning, r=nikomatsakis
Fix `range_covered_by_constructor` for exclusive ranges.

This resolves #43253
2017-07-17 13:31:37 +00:00
Oliver Schneider
eb7f429ea5 Move resolve diagnostic instability to compile-fail
The produced paths aren't stable between builds, since
reporting paths inside resolve, before resolve is finished
might produce paths resolved to type aliases instead of
the concrete type.

Compile-fail tests can match just parts of messages, so they
don't "suffer" from this issue.

This is just a workaround, the instability should be fixed
in the future.
2017-07-17 10:16:08 +02:00
Oliver Schneider
a9d9a4aab4
Change some helps to suggestions 2017-07-17 10:03:37 +02:00
Oliver Schneider
4a286639e8
Move some tests from compile-fail to ui 2017-07-17 08:38:54 +02:00
Esteban Küber
7239d77171 Point at : when using it instead of ;
When triggering type ascription in such a way that we can infer a
statement end was intended, add a suggestion for the change. Always
point out the reason for the expectation of a type is due to type
ascription.
2017-07-16 11:49:10 -07:00
Sam Cappleman-Lynes
b11596867d Fix range_covered_by_constructor for exclusive ranges.
This resolves #43253
2017-07-16 17:34:09 +01:00
Zack M. Davis
80c603fc65 path, not name, in sole-argument variant type mismatch suggestion
We want the suggested replacement (which IDE tooling and such might offer to
automatically swap in) to, like, actually be correct: suggesting `MyVariant(x)`
when the actual fix is `MyEnum::MyVariant(x)` might be better than nothing, but
Rust is supposed to be the future of computing: we're better than better than
nothing.

As an exceptional case, we excise the prelude path, preferring to suggest
`Some` or `Ok` rather than `std::prelude::v1::Some` and
`std::prelude::v2::Ok`. (It's not worth the effort to future-proof against
hypothetical preludes v2, v3, &c.: we trust our successors to grep—excuse me,
ripgrep—for that.)

Also, don't make this preëmpt the existing probe-for-return-type suggestions,
despite their being looked unfavorably upon, at least in this situation
(https://github.com/rust-lang/rust/issues/42764#issuecomment-311388958): Cody
Schafer pointed out that that's a separate issue
(https://github.com/rust-lang/rust/pull/43178#issuecomment-314953229).

This is in the matter of #42764.
2017-07-15 12:46:03 -07:00
Zack M. Davis
eac7410405 suggest one-argument enum variant to fix type mismatch when applicable
Most notably, this will suggest `Some(x)` when the expected type was
an Option<T> but we got an x: T.

Resolves #42764.
2017-07-12 17:36:22 -07:00
Mark Simulacrum
1a7dc0a2cb Rollup merge of #43000 - estebank:on-unimplemented-path, r=arielb1
`rustc_on_unimplemented` supports referring to trait

Add support to `rustc_on_unimplemented` to reference the full path of
the annotated trait. For the following code:

```rust
pub mod Bar {
    #[rustc_on_unimplemented = "test error `{Self}` with `{Bar}` `{Baz}` `{Quux}` in `{Foo}`"]
    pub trait Foo<Bar, Baz, Quux> {}
}
```

the error message will be:

```
test error `std::string::String` with `u8` `_` `u32` in `Bar::Foo`
```
2017-07-12 06:58:44 -06:00
kennytm
34209b0eaa
Merge ui/README.md into COMPILER_TESTS.md and describe how custom UI normalization works. 2017-07-11 16:57:53 +08:00
kennytm
4582ecda64
compiletest: Support custom normalization rules. 2017-07-11 16:57:52 +08:00
bors
1e5162ce5b Auto merge of #42996 - Boreeas:merge-e0609-e0612, r=GuillaumeGomez
Fold E0612, E0613 into E0609

As discussed in #42945, with PR 1506 tuple indices are no longer considered a separate case from normal field. This PR folds E06012 ("tuple index out of bounds") and E0613 ("type is not a tuple") into E0609 ("type does not have field with that name")

Resolves #42945
2017-07-08 15:18:46 +00:00
Vadim Petrochenkov
96bcdac9e4 Make sufficiently old or low-impact compatibility lints deny-by-default 2017-07-08 01:56:27 +03:00
Vadim Petrochenkov
affb8ee831 Remove more anonymous trait method parameters 2017-07-08 01:56:27 +03:00
boreeas
c215d08c4c Fold E0613 into E0609
Resolves #42945
2017-07-07 21:47:39 +02:00
bors
13157c4ebc Auto merge of #42809 - seanmonstar:stable-associated-consts, r=nikomatsakis
remove associated_consts feature gate

Currently struggling to run tests locally (something about jemalloc target missing).

cc #29646
2017-07-07 18:42:14 +00:00
Vadim Petrochenkov
4323877e92 syntax: Apply recovery for casts to type ascription
Fix spans, add some comments
2017-07-07 11:53:12 +03:00
Vadim Petrochenkov
5fa1c1b5f3 Fix spans for binary operator expression with interpolated identifiers 2017-07-07 11:21:57 +03:00
Esteban Küber
697c85a4f1 Only underline suggestion if it is not the only code being shown 2017-07-06 14:36:49 -07:00
Esteban Küber
eb478e2381 Add extra whitespace for suggestions 2017-07-06 14:36:48 -07:00
Esteban Küber
7c84914635 Make suggestion include the line number
When there're more than one suggestions in the same diagnostic, they are
displayed in their own block, instead of inline. In order to reduce
confusion, those blocks now display the line number.
2017-07-06 14:36:48 -07:00
Sean McArthur
74b2d69358 remove associated_consts feature gate 2017-07-06 11:52:25 -07:00
Esteban Küber
d71caadee2 Add rustc_on_unimplemented message to std::ops::Try 2017-07-05 22:28:35 -07:00
Esteban Küber
05d3526132 rustc_on_unimplemented supports referring to trait
Add support to `rustc_on_unimplemented` to reference the full path of
the annotated trait. For the following code:

```rust
pub mod Bar {
    #[rustc_on_unimplemented = "test error `{Self}` with `{Bar}` `{Baz}` `{Quux}` in `{Foo}`"]
    pub trait Foo<Bar, Baz, Quux> {}
}
```

the error message will be:

```
test error `std::string::String` with `u8` `_` `u32` in `Bar::Foo`
```
2017-07-05 16:46:59 -07:00
Alex Crichton
fd95db25b3 Merge remote-tracking branch 'origin/master' into proc_macro_api 2017-07-05 08:42:13 -07:00
Ariel Ben-Yehuda
fb7ab9e43d report the total number of errors on compilation failure
Prior to this PR, when we aborted because a "critical pass" failed, we
displayed the number of errors from that critical pass. While that's the
number of errors that caused compilation to abort in *that place*,
that's not what people really want to know. Instead, always report the
total number of errors, and don't bother to track the number of errors
from the last pass that failed.

This changes the compiler driver API to handle errors more smoothly,
and therefore is a compiler-api-[breaking-change].

Fixes #42793.
2017-07-02 16:16:44 +03:00
Ariel Ben-Yehuda
77f4022303 Revert "Change error count messages"
This reverts commit 5558c64f33.
2017-07-02 13:49:30 +03:00
Guillaume Gomez
fc0fb0328b Rollup merge of #42669 - gaurikholkar:master, r=nikomatsakis
Adding diagnostic code 0611 for lifetime errors with one named, one anonymous lifetime parameter

This is a fix for #42517
Note that this only handles the above case for **function declarations** and **traits**.
`impl items` and `closures` will be handled in a later PR.
Example
```
fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
    if x > y { x } else { y }
}
```
now displays the following error message. ui tests have been added for the same.
```
error[E0611]: explicit lifetime required in the type of `x`
11 | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
   |                     ^ consider changing the type of `x` to `&'a i32`
12 |     if x > y { x } else { y }
   |                  - lifetime `'a` required
```
#42516
r? @nikomatsakis
2017-06-30 22:44:43 +02:00
bors
e72580cf09 Auto merge of #42807 - arielb1:consistent-coercion, r=eddyb
Coerce fields to the expected field type

Fully fixes #31260.

This needs a crater run. I was supposed to do this last month but it slipped. Let's get this done.
2017-06-30 13:39:25 +00:00
gaurikholkar
4abcf28d2b adding compile-fail test 2017-06-29 14:13:53 -07:00