Commit Graph

116 Commits

Author SHA1 Message Date
Noah Lev
0fa3b4f940 Make E0023 spans even more precise 2021-08-21 16:15:09 -07:00
Noah Lev
da25af2940 Make spans for tuple patterns in E0023 more precise
As suggested in #86307.
2021-08-17 14:27:48 -07:00
Caio
6aa9937a76 Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
Esteban Küber
99f2977031 Modify structured suggestion output
* On suggestions that include deletions, use a diff inspired output format
* When suggesting addition, use `+` as underline
* Color highlight modified span
2021-08-11 09:46:24 +00:00
Aaron Hill
fad2242ff7
Add variance-related information to lifetime error messages 2021-06-06 12:37:42 -05:00
Fabian Wolff
57291b8c5e Improve error message for non-exhaustive matches on non-exhaustive enums 2021-05-12 19:25:12 +02:00
Aliénore Bouttefeux
5cc21d9051 add suggestion for unit enum variant when matched with a patern 2021-05-02 13:58:38 +02:00
Smitty
fc97ce6dae add tests for new behavior 2021-04-23 14:06:02 -04:00
mark
b9ecba30bc update tests 2021-03-19 19:45:42 -05:00
Camelid
e8c87935e0 Include .. suggestion if fields are all wildcards 2021-01-12 21:20:26 -08:00
Camelid
d7307a71f5 Always show suggestions in their own subwindows 2021-01-12 19:25:51 -08:00
Camelid
9959d6deed Only suggest .. if more than one field is missing 2021-01-12 19:25:51 -08:00
Camelid
fe82cc38a0 Specialize .. help message for all fields vs. the rest 2021-01-12 19:25:50 -08:00
Camelid
f3d9df54ee Suggest Variant(..) if all of the mentioned fields are _ 2021-01-12 19:25:50 -08:00
Camelid
16692ab66a Suggest _ and .. if a pattern has too few fields
For example, this code:

    struct S(i32, f32);

    let S(x) = S(0, 1.0);

will make the compiler suggest either:

    let S(x, _) = S(0, 1.0);

or:

    let S(x, ..) = S(0, 1.0);
2021-01-12 19:25:49 -08:00
Nadrieril
82bf5b61cd Regroup many usefulness-related test in the same folder 2020-11-19 19:52:54 +00:00
Mara Bos
b6f52410bb
Rollup merge of #79072 - oli-obk:byte_str_pat, r=estebank
Fix exhaustiveness in case a byte string literal is used at slice type

fixes #79048
2020-11-17 16:13:53 +01:00
oli
a1cdf722f4 Fix exhaustiveness in case a byte string literal is used at slice type 2020-11-17 09:07:23 +00:00
Who? Me?!
b825ae7d28
Style nit
Co-authored-by: matthewjasper <20113453+matthewjasper@users.noreply.github.com>
2020-11-14 07:20:25 -06:00
mark
43e4783ce3 address reviewer comments 2020-11-09 12:19:34 -06:00
mark
459dae94a1 fix #72680 by explicitly checking for or-pattern before test 2020-11-07 23:22:47 -06:00
David Tolnay
b0059500f6
Reduce diagram mess in 'match arms have incompatible types' error 2020-10-22 16:16:02 -07:00
David Tolnay
f82adf5bdb
Add test of incompatible match arm types with multiline arm 2020-10-22 16:11:57 -07:00
Oliver Scherer
ce6c25da58 References to ZSTs may be at arbitrary aligned addresses 2020-09-30 10:40:49 +02:00
varkor
94c789b275 char not char 2020-09-26 13:34:49 +01:00
Oliver Scherer
177d0cef48 Deduplicate errors in const to pat conversion 2020-09-23 17:03:31 +02:00
Oliver Scherer
adf98ab2dc Use precise errors during const to pat conversion instead of a catch-all on the main constant 2020-09-20 18:42:15 +02:00
Oliver Scherer
b2532a8730 Implement destructuring for all aggregates and for references 2020-09-20 13:28:18 +02:00
Wonwoo Choi
c4fb3f297b Provide better spans for the match arm without tail expression 2020-08-18 15:28:56 +09:00
Ayaz Hafiz
3c63fba03d
Correctly mark the ending span of a match arm
Closes #74050

r? @matthewjasper
2020-07-08 07:28:07 -07:00
Bastian Kauschke
29508ce3ad normalize adt fields during structural match check 2020-06-02 00:23:47 +02:00
Yuki Okushi
9a164ff4c5
Skip tests on emscripten 2020-05-08 00:39:02 +09:00
Yuki Okushi
e69748ba4f
Move tests from test/run-fail to UI 2020-05-06 14:02:55 +09:00
Bastian Kauschke
2f5c0f59a9 emit err when using trait objects in pat 2020-04-29 19:33:50 +02:00
Mazdak Farrokhzad
c858593ed0 non-exhastive diagnostic: add note re. scrutinee type 2020-03-27 06:49:07 +01:00
Mark Mansi
b6518f0f66 update tests 2020-03-12 15:47:36 -05:00
Esteban Küber
125159f30a When encountering an Item in a pat context, point at the item def 2020-03-06 15:29:26 -08:00
Mazdak Farrokhzad
e9f6bb7f79 check_pat_path: use pattern_cause 2020-02-25 05:41:03 +01:00
Mazdak Farrokhzad
5da3a2f354 enhance check_pat_lit with TopInfo 2020-02-25 04:10:58 +01:00
Eduard-Mihai Burtescu
4c7eb59e81 rustc_macros: don't limit the -Zmacro-backtrace suggestion to extern macros. 2020-02-06 21:46:38 +02:00
Eduard-Mihai Burtescu
f6fc80206e rustc: rename -Zexternal-macro-backtrace to -Zmacro-backtrace. 2020-02-06 21:32:07 +02:00
varkor
24a2929ed1 Normalise notes with the/is 2020-01-24 16:24:50 +00:00
Mazdak Farrokhzad
e3c2f8fc57 slice_patterns: organize some tests 2020-01-18 19:33:47 +01:00
Mazdak Farrokhzad
a1eadca88f slice_patterns: remove gates in tests 2020-01-18 19:33:47 +01:00
Vadim Petrochenkov
642669c74d Update tests 2020-01-09 21:23:12 +03:00
varkor
0c2cf07d6e Add backticks to various diagnostics 2020-01-05 00:17:46 +00:00
Mazdak Farrokhzad
ab050d6a83 MatchExpressionArmPattern: Use more generic wording.
The existing wording was inappropriate for e.g.
`if let Ok(_) = expr { .. }`. The diagnostic would
leak the fact that we desugar to a `match`.
2019-12-30 13:50:20 +01:00
Mazdak Farrokhzad
c4b6de2d6a note other end-point when typeck range pats 2019-12-30 02:48:35 +01:00
bors
53712f8637 Auto merge of #66389 - estebank:type-err-labels, r=petrochenkov
Specific labels when referring to "expected" and "found" types
2019-11-21 17:53:19 +00: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