39 Commits

Author SHA1 Message Date
Esteban Küber
3fb1810476 Use better bound names in -Zverbose mode 2020-01-25 13:25:19 -08:00
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
Niko Matsakis
f87189dd3c update tests and add stderr files 2018-09-26 09:38:26 -04:00
Niko Matsakis
689b791422 use approx. bounds to decide whether to add outlives obligations
Before, if we had a projection like `<T as Foo<'0>>::Bar: 'x` and a
where clause like `<T as Foo<'a>>::Bar: 'a`, we considered those to
have nothing to do with one another. Therefore, we would use the
"overconstrained" path of adding `T: 'x` and `'0: 'x` requirements. We
now do a "fuzzy" match where we erase regions first and hence we see
the env bound `'a`.
2018-09-26 09:38:26 -04: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
Wesley Wiser
b1211e8703 Fix tests 2018-09-06 22:57:05 -04:00
Basile Desloges
b01550a718 Update tests 2018-09-01 12:58:18 +02:00
David Wood
2488cb6b10
Explicitly label any named lifetimes mentioned in error messages. 2018-08-02 12:00:15 +02:00
Felix S. Klock II
6787e25c29 Blindly update the #[rustc_region] tests which got touched by the NLL diagnostic change. 2018-07-31 14:35:43 +02:00
Mikhail Modin
bb66d70b89 fix issues #51351 and #52133 2018-07-29 11:42:50 +01:00
Niko Matsakis
727f01700b write code to extract region names and emit new style message 2018-07-04 05:09:33 -04:00
David Wood
a11245f80e
Ensure that changed errors are lower case. 2018-07-01 16:14:25 +01:00
David Wood
59e64e9085
Updated affected tests. 2018-07-01 16:14:25 +01:00
Christian Poveda
4bf35f93c9 updated stderr files and removed feature-gate test for dyn_trait 2018-04-27 10:05:51 -05: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
9f9183d34d Fix rebase 2018-02-26 21:20:31 +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
2370b60529 update tests and reference files
The type checker invokes the borrow checker for closures it finds, so
removing the NLL type checker affects ordering of errors somewhat.
2018-02-23 10:40:57 -05:00
Jonas Platte
78493ed21a Add GenericParam, refactor Generics in ast, hir, rustdoc
The Generics now contain one Vec of an enum for the generic parameters,
rather than two separate Vec's for lifetime and type parameters.

Additionally, places that previously used Vec<LifetimeDef> now use
Vec<GenericParam> instead.
2017-12-21 13:38:10 +01:00
Niko Matsakis
508a831dca use report_generic_bound_failure when we can in the compiler 2017-12-20 14:38:12 -05:00
Niko Matsakis
6b39781df6 connect NLL machinery to the NiceRegionError code 2017-12-20 14:38:12 -05:00
Niko Matsakis
4f43c5b1e7 stop dumping DefPath into "failed type test" errors
The prior messages were not stable across platforms.
2017-12-15 17:04:48 -05:00
Niko Matsakis
3fcb13ae45 handle projections with regions 2017-12-15 10:27:52 -05:00