Commit Graph

449 Commits

Author SHA1 Message Date
Mikhail Modin
a0e7e357a7 Improve "Doesn't live long enough" error
case with different lifetime with spans
2016-11-01 19:39:28 +03:00
bors
f26eedb571 Auto merge of #37191 - zackmdavis:we_heard_you_the_first_time_really, r=nikomatsakis
introing one-time diagnostics: only emit "lint level defined here" once

This is a revised resubmission of PR #34084 (which was closed due to inactivity on account of time constraints on the author's part).
---

We introduce a new `one_time_diagnostics` field on
`rustc::session::Session` to hold a hashset of diagnostic messages we've
set once but don't want to see again (as uniquified by span and message
text), "lint level defined here" being the motivating example dealt with
here.

This is in the matter of #24690.
---

r? @nikomatsakis
2016-10-31 10:56:25 -07:00
Zack M. Davis
ef6a07221d deduplicate one-time diagnostics on lint ID as well as span and message
Some lint-level attributes (like `bad-style`, or, more dramatically,
`warnings`) can affect more than one lint; it seems fairer to point out
the attribute once for each distinct lint affected. Also, a UI test is
added. This remains in the matter of #24690.
2016-10-26 23:24:59 -07:00
Ariel Ben-Yehuda
04a92a1f56 un-break the construct_witness logic
Fixes #35609.
2016-10-26 22:41:17 +03:00
Mikhail Modin
e85277596e improve "Doesn't live long enough" error 2016-10-20 22:51:51 +03:00
Felix S. Klock II
4124d8e48b Moved new dropck-eyepatch compile-fail tests to the ui/ subtree. 2016-10-17 18:02:23 +02:00
Andrea Corradi
d0c6172501 Better underline for E0057,E0060,E0061 2016-10-06 22:02:46 +02:00
Manish Goregaokar
5a4ecb4a0c Rollup merge of #36798 - gavinb:fix/36164, r=GuillaumeGomez
Improve error message and snippet for "did you mean `x`"

- Fixes #36164
- Part of #35233

Based on the standalone example https://is.gd/8STXMd posted by @nikomatsakis and using the third formatting option mentioned in #36164 and agreed by @jonathandturner.

Note however this does not address the question of [how to handle an empty or unknown suggestion](https://github.com/rust-lang/rust/issues/36164#issuecomment-244460024). @nikomatsakis any suggestions on how best to address that part?
2016-10-04 15:24:01 +05:30
Gavin Baker
99aae9b834 Improve error message and snippet for "did you mean x"
- Fixes #36164
- Part of #35233
- handles unknown fields
- uses UI-style tests
- update all related tests (cfail, ui, incremental)
2016-10-02 15:57:39 +11:00
Jesus Garlea
f4fdf814de Update E0220 error format
squash! Update E0220 error format

Update Error E0220 to new format
2016-09-30 15:15:16 -05:00
Jonathan Turner
2fa91b23c5 Update E0425, E0446, E0449 2016-09-26 16:05:46 -07:00
Guillaume Gomez
f17bdb7eec Rollup merge of #36498 - jonathandturner:macro_std_lib, r=nikomatsakis
Fix wording for out-of-crate macro error

This fixes the wording of the note for out-of-crate macro errors to fix https://github.com/rust-lang/rust/issues/36469

The previous wording came from older logic in the PR that was replaced without updating the note.
2016-09-24 00:15:44 +02:00
Mikhail Modin
82639d4f04 fix top level attr spans 2016-09-16 21:44:15 +03:00
Esteban Küber
68e8624d05 Specify when type parameter shadows primitive type
When a type parameter shadows a primitive type, the error message
was non obvious. For example, given the file `file.rs`:

```rust
trait Parser<T> {
    fn parse(text: &str) -> Option<T>;
}

impl<bool> Parser<bool> for bool {
    fn parse(text: &str) -> Option<bool> {
        Some(true)
    }
}

fn main() {
    println!("{}", bool::parse("ok").unwrap_or(false));
}
```

The output was:

```bash
% rustc file.rs
error[E0308]: mismatched types
 --> file.rs:7:14
  |
7 |         Some(true)
  |              ^^^^ expected type parameter, found bool
  |
  = note: expected type `bool`
  = note:    found type `bool`

error: aborting due to previous error
```

We now show extra information about the type:

```bash
% rustc file.rs
error[E0308]: mismatched types
 --> file.rs:7:14
  |
7 |         Some(true)
  |              ^^^^ expected type parameter, found bool
  |
  = note: expected type `bool` (type parameter)
  = note:    found type `bool` (bool)

error: aborting due to previous error
```

Fixes #35030
2016-09-15 20:06:29 -07:00
Jonathan Turner
d7428944c2 Fix wording for out-of-crate macro error 2016-09-15 10:12:56 -07:00
bors
5531c314a2 Auto merge of #36354 - mikhail-m1:master, r=jonathandturner
fix span for errors E0537, E0535 & E0536

fix #36182 as part of #35233
2016-09-12 14:05:41 -07:00
Mikhail Modin
fb85dd398b fix span for errors E0537, E0535 & E0536 2016-09-10 10:21:13 +03:00
Manish Goregaokar
43440a4a6e Rollup merge of #36212 - razielgn:updated-e0493-to-new-format, r=jonathandturner
Updated e0493 to new format (+ bonus).

Part of #35233.
Fixes #35999.

r? @jonathandturner

I'm not satisfied with the bonus part, there has to be an easier way to reach into the `Drop`'s span implementation. I'm all ears. :)
2016-09-04 21:00:59 +08:00
Jonathan Turner
59c0ff6314 Rollup merge of #36171 - jonathandturner:temporary_value, r=nikomatsakis
Update lifetime errors to specifically note temporaries

This PR updates the error message we give in the case of a temporary value not living long enough.

Before:

<img width="497" alt="screen shot 2016-08-31 at 10 02 47 am" src="https://cloud.githubusercontent.com/assets/547158/18138551/27a06794-6f62-11e6-9ee2-bdf8bed75ca7.png">

Now:

<img width="488" alt="screen shot 2016-08-31 at 10 03 01 am" src="https://cloud.githubusercontent.com/assets/547158/18138557/2e5cf322-6f62-11e6-9047-4a78abf3d78c.png">

Specifically, it makes the following changes:

* Detects if a temporary is being used.  If so, it changes the labels to mention that a temporary value specifically is in question
* Simplifies wording of the existing labels to focus on lifetimes rather than values being valid
* Changes the help to a note, since the help+span wasn't as helpful (and sometimes more confusing) than just a note.

r? @nikomatsakis
2016-09-02 15:28:51 -07:00
Federico Ravasio
059094f3f2 Moved test on E0493 from compile-fail to ui. 2016-09-02 19:55:14 +02:00
Jonathan Turner
439afcd974 Update error message for lifetime of borrowed values 2016-08-31 17:48:26 -07:00
CensoredUsername
d282a633fa Guard against platforms on which the sysv64 calling convention is not valid in non-codegen tests. Remove false positive in a test that relied on the exact formatting of an error string and rewrite the sysv64 register allocation test at it was triggering undefined behaviour 2016-08-30 16:03:06 +02:00
Keith Yeung
e46b09a1f9 Add UI test for E0379 2016-08-27 22:43:51 -07:00
Jonathan Turner
54d0acd2fc wording fixes in error messages 2016-08-19 16:05:37 -07:00
bors
43c090ed69 Auto merge of #35732 - jonathandturner:region_error_labels, r=nikomatsakis
Move 'doesn't live long enough' errors to labels

This patch moves the "doesn't live long enough" region-style errors to instead use labels.

An example follows.

Before:

```
error: `x` does not live long enough
  --> src/test/compile-fail/send-is-not-static-ensures-scoping.rs:26:18
   |
26 |         let y = &x;
   |                  ^
   |
note: reference must be valid for the block at 23:10...
  --> src/test/compile-fail/send-is-not-static-ensures-scoping.rs:23:11
   |
23 | fn main() {
   |           ^
note: ...but borrowed value is only valid for the block suffix following statement 0 at 25:18
  --> src/test/compile-fail/send-is-not-static-ensures-scoping.rs:25:19
   |
25 |         let x = 1;
   |                   ^
```

After:

```
error: `x` does not live long enough
  --> src/test/compile-fail/send-is-not-static-ensures-scoping.rs:26:18
   |
26 |         let y = &x;
   |                  ^ does not live long enough
...
32 |     };
   |     - borrowed value only valid until here
...
35 | }
   | - borrowed value must be valid until here
```

r? @nikomatsakis
2016-08-18 05:39:11 -07:00
bors
9d6520f97b Auto merge of #35769 - eddyb:rollup, r=eddyb
Rollup of 12 pull requests

- Successful merges: #35346, #35734, #35739, #35740, #35742, #35744, #35749, #35750, #35751, #35756, #35766, #35768
- Failed merges:
2016-08-18 00:15:11 -07:00
Keith Yeung
31d56cb144 Add UI test for E0053 2016-08-17 15:33:50 -07:00
Jonathan Turner
70ce90c320 Move 'doesn't live long enough' errors to labels 2016-08-17 15:24:42 -07:00
Jonathan Turner
54d42cc912 Rebase. Fix mutable iteration nit. 2016-08-17 15:11:18 -07:00
Jonathan Turner
61865384b8 Replace local backtrace with def-use, repair std macro spans 2016-08-17 14:26:14 -07:00
Jonathan Turner
d0a272b797 Fix merge conflict 2016-08-17 14:26:05 -07:00
Jonathan Turner
75454f72a3 Rollup merge of #35713 - sanxiyn:ui-test, r=nikomatsakis
Use UI test to test spans, instead of forced line break

There must be lots more, but these are what I could easily find.
2016-08-17 06:25:27 -07:00
Seo Sanghyeon
3aa63400a2 Use UI test to test spans, instead of forced line break 2016-08-16 20:46:50 +09:00
Seo Sanghyeon
d52eb1ab0c RUST_NEW_ERROR_FORMAT is no more 2016-08-16 16:52:30 +09:00
Seo Sanghyeon
f76a737bae Correct span for pub_restricted field 2016-08-12 21:08:02 +09:00
Ryan Scott
19e140b946 Update E0404 to new format. 2016-08-05 17:36:43 +09:00
Jeffrey Seyfried
6656a30ca1 Fix fallout in ui/codemap_tests. 2016-08-01 18:42:16 +00:00
Jonathan Turner
ea77049cfa Move to {integer} and {float} 2016-07-28 09:49:31 -07:00
Jonathan Turner
cfdaca049a Rename _ to {numerics} for unknown numeric types 2016-07-28 08:58:25 -07:00
Jonathan Turner
0b727f0801 Add unicode test to ui tests 2016-07-14 10:55:09 -04:00
Jonathan Turner
1fd014a965 Add fix for tabs. Move error unit tests->ui tests 2016-07-14 07:57:46 -04:00
Jonathan Turner
012ff15c94 Fix up some tidy-unfriendly spacing 2016-07-14 07:57:46 -04:00
Jonathan Turner
f481879d2a Fix a couple UI test failures 2016-07-14 07:57:46 -04:00
Jonathan Turner
df87a781de Satisfy tidy 2016-05-24 10:57:44 -04:00
Jonathan Turner
00b78d0d6a Back to single line between errors. Add header space to secondary files 2016-05-24 10:42:32 -04:00
Jonathan Turner
9cc8debeb7 Move issue-26480 cfail to ui test. Fix #33763 2016-05-24 07:40:09 -04:00
Jonathan Turner
428099233a Fix #33819 and update ui test 2016-05-23 14:48:11 -04:00
Niko Matsakis
24cfa1efb0 pacify the mercilous tidy 2016-05-16 16:48:48 -04:00
Niko Matsakis
cb112dc8cf add UI testing framework 2016-05-13 15:22:45 -07:00