Commit Graph

36 Commits

Author SHA1 Message Date
varkor
0810210bcb Diagnostics should start lowercase 2020-01-12 15:36:40 +00:00
bors
234c9f21d9 Auto merge of #66911 - eddyb:nicer-rustc_regions, r=matthewjasper
rustc_mir: use nicer path printing for #[rustc_regions] NLL tests.

Similar to #66850, spotted while working on #66907.

r? @matthewjasper
2019-12-06 00:22:54 +00:00
Eduard-Mihai Burtescu
84bad09420 rustc_mir: use nicer path printing for #[rustc_regions] NLL tests. 2019-11-30 18:47:21 +02:00
Eduard-Mihai Burtescu
9034efe3f7 rustc: don't just show raw DefIndex's in BrNamed's fmt::Debug impl. 2019-11-30 17:29:56 +02:00
bors
0ccee30773 Auto merge of #58281 - mark-i-m:synthesis, r=estebank
Add outlives suggestions for some lifetime errors

This PR implements suggestion diagnostics for some lifetime mismatch errors. When the borrow checker finds that some lifetime 'a doesn't outlive some other lifetime 'b that it should outlive, then in addition to the current lifetime error, we also emit a suggestion for how to fix the problem by adding a bound:

- If a and b are normal named regions, suggest to add the bound `'a: 'b`
- If b is static, suggest to replace a with static
- If b also needs to outlive a, they must be the same, so suggest unifying  them

We start with a simpler implementation that avoids diagnostic regression or implementation complexity:
- We only makes suggestions for lifetimes the user can already name (eg not closure regions or elided regions)
- For now, we only emit a help note, not an actually suggestion because it is significantly easier.

Finally, there is one hack: it seems that implicit regions in async fn are given the name '_ incorrectly. To avoid suggesting '_: 'x, we simply filter out such lifetimes by name.

For more info, see this internals thread:

https://internals.rust-lang.org/t/mechanical-suggestions-for-some-borrow-checker-errors/9049/3

TL;DR Make suggestions to add a `where 'a: 'b` constraint for some lifetime errors. Details are in the paper linked from the internals thread above.

r? @estebank

TODO
- [x] Clean up code
- [x] Only make idiomatic suggestions
     - [x] don't suggest naming `&'a self`
     - [x] rather than `'a: 'static`, suggest replacing `'a` with `'static`
     - [x] rather than `'a: 'b, 'b: 'a`, suggest replacing `'a` with `'b` or vice versa
- [x] Performance (maybe need a perf run when this is closer to the finish line?)
     - perf run was clean...
     - EDIT: perf run seems to only check non-error performance... How do we check that error performance didn't regress?
- [x] Needs ui tests
- [x] Integrate the `help` message into the main lifetime `error`
2019-11-18 22:08:31 +00:00
Eduard-Mihai Burtescu
25953321c0 rustc: remove "GlobalMetaData" dead code from hir::map::definitions. 2019-11-05 21:00:38 +02:00
Mark Mansi
cba0761e5f update tests 2019-10-27 09:39:14 -05:00
Mark Mansi
3a1847b07d implement outlive suggestions 2019-10-27 08:47:22 -05:00
Vadim Petrochenkov
ee6d315200 cleanup: Remove DefIndexAddressSpace 2019-05-09 00:46:38 +03:00
David Tolnay
cfd31fb4df
Include trailing comma in multiline Debug representation
This commit changes the behavior of Formatter::debug_struct,
debug_tuple, debug_list, debug_set, and debug_map to render trailing
commas in {:#?} mode, which is the dominant style in modern Rust code.

Before:

    Language {
        name: "Rust",
        trailing_commas: false
    }

After:

    Language {
        name: "Rust",
        trailing_commas: true,
    }
2019-04-05 06:45:40 -07:00
Vadim Petrochenkov
fa72a81bea Update tests 2019-03-11 23:10:26 +03:00
Mark Mansi
274d293cab Update tests 2019-01-17 20:39:06 -06:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Matthew Jasper
825810734b Improve closure region bound errors
Now use the category and span that are associated to the most
interesting bound that led to the closure bound.
2018-10-06 10:00:26 +01:00
Matthew Jasper
bd0895d7d0 Update ui tests 2018-09-19 20:50:09 +01:00
Niko Matsakis
bb8c4c0db9 print less info to stabilize tests 2018-09-07 17:24:46 -04:00
Niko Matsakis
db169e53e5 move annotate onto a method of UniversalRegions
This allows it to print out the "late-bound regions" from the closure
context more easily. Besides, all the state that is being printed it
is private to the `UniversalRegions`.
2018-09-07 17:08:21 -04:00
Basile Desloges
b01550a718 Update tests 2018-09-01 12:58:18 +02:00
David Wood
37ba9ca334
Disable some nice region errors in NLL mode. 2018-08-06 20:43:16 +02:00
Mikhail Modin
bb66d70b89 fix issues #51351 and #52133 2018-07-29 11:42:50 +01:00
Niko Matsakis
4fce59f0fd remove unnecessary blame_span from report_region_errors 2018-07-25 06:38:20 +03:00
Fabian Drinck
a06870eb78 Fix typo DebrujinIndex -> DebruijnIndex 2018-06-14 18:44:37 +02:00
Fabian Drinck
54b2228778 Add DEBUG_FORMAT for DebruijnIndex 2018-06-14 18:44:37 +02:00
Fabian Drinck
0ad3600700 Declare DebruijnIndex via newtype_index macro 2018-06-14 18:44:36 +02:00
Niko Matsakis
783fe4f880 change to 0-based indices
Co-authored-by: csmoe <35686186+csmoe@users.noreply.github.com>
2018-05-28 19:47:05 -04:00
Niko Matsakis
45d281d7fa remove -Znll -- borrowck=mir implies nll now 2018-04-15 07:13:42 -04:00
Guillaume Gomez
2e104a77cf update tests 2018-03-14 00:53:24 +01:00
Vadim Petrochenkov
7ba5fd168a Update UI tests 2018-02-26 20:24:42 +03:00
Vadim Petrochenkov
fa2d9fc4b9 Update UI tests 2018-02-26 20:24:02 +03:00
Guillaume Gomez
5747fd6611 Update ui tests 2018-02-25 12:15:05 +01:00
Niko Matsakis
6b39781df6 connect NLL machinery to the NiceRegionError code 2017-12-20 14:38:12 -05:00
Niko Matsakis
0d6bd42abb make blame_span deterministic 2017-12-15 10:27:54 -05:00
Niko Matsakis
a30e2259da fix closure tests now that MIR typeck works properly
These tests had FIXMEs for errors that were not previously being
reported.
2017-12-13 12:20:27 -05:00
Tommy Ip
2ad5bf056c Update ui tests' line numbers. 2017-12-10 21:14:57 +00:00
Niko Matsakis
47b8ef51d4 don't print self symbol's internal index unless gensymed
It's just not useful. It also makes it hard to have tests that probe
internal state, since the interning number is very sensitive.

Dumping the number in the case of gensym is not ideal but will do for
now.
2017-12-07 05:28:01 -05:00
Niko Matsakis
05441abd2b add closure requirement tests, improve debugging output
The overall format is now easier to read. Also, There is now graphviz
output, as well as a `#[rustc_regions]` annotation that dumps internal
state.
2017-12-07 05:28:00 -05:00