Commit graph

30 commits

Author SHA1 Message Date
Michael Goulet
3e7e1b1f83 Avoid InferCtxt::build in suggest_missing_break_or_return_expr 2022-12-02 04:11:48 +00:00
Esteban Küber
ab04080b56 Change multiline span ASCII art visual order 2022-11-28 00:11:12 -08:00
Caio
c74165d443 Move some tests for more reasonable places 2022-10-20 11:08:44 -03:00
Esteban Kuber
474626af50 Eagerly replace {integer}/{float} with i32/f64 for suggestion 2022-03-27 02:20:16 +00:00
Nilstrieb
4bed7485da Suggest impl Trait return type
Address #85991

Suggest the `impl Trait` return type syntax if the user tried to return a generic parameter and we get a type mismatch

The suggestion is not emitted if the param appears in the function parameters, and only get the bounds that actually involve `T: ` directly

It also checks whether the generic param is contained in any where bound (where it isn't the self type), and if one is found (like `Option<T>: Send`), it is not suggested.

This also adds `TyS::contains`, which recursively vistits the type and looks if the other type is contained anywhere
2022-02-18 20:40:08 +01:00
ThePuzzlemaker
ab7c446492
Add regression test for #92308
This amends off of an existing test introduced in #81769, if you think I
should make a separate test I will.
2021-12-28 19:43:36 -06:00
Michael Goulet
f29fb4792b Make TyS::is_suggestable more structual 2021-12-14 11:32:06 -08: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
Fabian Wolff
11fd8579e4 Emit explanatory note for functions in trait and impl items as well 2021-06-30 13:56:26 +02:00
Fabian Wolff
bdddaebd76 Fix type checking of return expressions outside fn bodies 2021-06-11 01:20:00 +02:00
Yuki Okushi
9adb462e6c Erase late bound regions to avoid ICE 2021-02-28 22:20:15 +09:00
Esteban Küber
fc6c19e2dc fix rebase 2021-02-21 23:15:59 -08:00
Esteban Küber
86b3f3f2b3 tidy 2021-02-21 16:34:37 -08:00
Esteban Küber
d669882f38 Do not suggest ; if expression is side effect free
When a tail expression isn't unit, we previously always suggested adding
a trailing `;` to turn it into a statement. This suggestion isn't
appropriate for any expression that doesn't have side-effects, as the
user will have likely wanted to call something else or do something with
the resulting value, instead of just discarding it.
2021-02-21 16:34:37 -08:00
Esteban Küber
020edd91a9 reword ; suggestions to have consistent wording 2021-02-21 16:27:29 -08:00
Esteban Küber
796ce9fcb7 Suggest returning tail expressions that match return type
Some newcomers are confused by the behavior of tail expressions,
interpreting that "leaving out the `;` makes it the return value".
To help them go in the right direction, suggest using `return` instead
when applicable.
2021-02-21 16:27:29 -08:00
Dylan MacKenzie
d6139f76c0 Update tests 2020-06-28 10:08:10 -07:00
Matthias Prechtl
7b555178ae --bless --compare-mode=nll 2020-02-09 20:43:49 +01:00
Dylan MacKenzie
5c377f37e4 Reorganize, bless and add tests for const control flow
This creates a new test directory, `ui/consts/control-flow` to hold
tests related to control flow in a const context. It also blesses all
existing tests with the new error messages, and adds new tests for the
`const_if_match` feature.
2019-11-21 16:55:13 -08:00
Esteban Küber
6f8f70624b Surround types with backticks in type errors 2019-11-18 11:03:04 -08:00
Esteban Küber
94c6425464 Remove E0308 note when primary label has all info 2019-11-18 11:03:03 -08:00
Esteban Küber
b2e6aef073 review comments: tweak prefix strings 2019-11-18 11:02:44 -08:00
Esteban Küber
83ffda5216 Specific labels when referring to "expected" and "found" types 2019-11-18 11:02:22 -08:00
Dylan MacKenzie
3ce8ca45d6 Bless const tests with improved diagnostics 2019-11-13 10:44:14 -08:00
varkor
7f0f0e31ec Remove double trailing newlines 2019-04-22 16:57:01 +01:00
Vadim Petrochenkov
fa72a81bea Update tests 2019-03-11 23:10:26 +03:00
Esteban Küber
2e06d9c91b Point at return type when appropriate 2019-01-18 00:12:09 -08:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Esteban Küber
59f643fc5f Point to return span when writing return; on non-() fn 2018-12-20 14:00:30 -08:00
David Wood
3fc7ab2373
Merged migrated compile-fail tests and ui tests. Fixes #46841. 2018-08-14 11:12:09 +02:00