about summary refs log tree commit diff
path: root/src/test/ui/suggestions
AgeCommit message (Collapse)AuthorLines
2021-09-01fix(rustc): suggest `items` be borrowed in `for i in items[x..]`Michael Howell-0/+44
Fixes #87994
2021-09-01Stop sorting bodies by span.Camille GILLOT-25/+25
The definition order is already close to the span order, and only differs in corner cases.
2021-08-27Remove `Session.if_let_suggestions`Aaron Hill-1/+13
We can instead if either the LHS or RHS types contain `TyKind::Error`. In addition to covering the case where we would have previously updated `if_let_suggestions`, this might also prevent redundant errors in other cases as well.
2021-08-18Use more accurate spans when proposing adding lifetime to itemEsteban Kuber-12/+12
2021-08-16Use note to point at bound introducing requirementEsteban Küber-114/+193
2021-08-13Rollup merge of #87795 - estebank:erase-lifetimes-in-suggestion, r=oli-obkGuillaume Gomez-1/+30
Avoid ICE caused by suggestion When suggesting dereferencing something that can be iterable in a `for` loop, erase lifetimes and use a fresh `ty::ParamEnv` to avoid 'region constraints already solved' panic. Fix #87657, fix #87709, fix #87651.
2021-08-12Rollup merge of #87885 - m-ou-se:edition-guide-links, r=rylevGuillaume Gomez-2/+2
Link to edition guide instead of issues for 2021 lints. This changes the 2021 lints to not link to github issues, but to the edition guide instead. Fixes #86996
2021-08-12Avoid ICE caused by suggestionEsteban Küber-1/+30
When suggesting dereferencing something that can be iterable in a `for` loop, erase lifetimes and use a fresh `ty::ParamEnv` to avoid 'region constraints already solved' panic. Fix #87657.
2021-08-12Use smaller spans for some structured suggestionsEsteban Kuber-24/+34
Use more accurate suggestion spans for * argument parse error * fully qualified path * missing code block type * numeric casts * E0212
2021-08-11Modify structured suggestion outputEsteban Küber-284/+293
* On suggestions that include deletions, use a diff inspired output format * When suggesting addition, use `+` as underline * Color highlight modified span
2021-08-09Link to edition guide instead of issues for 2021 lints.Mara Bos-2/+2
2021-08-04Remove trailing whitespace from error messagesFabian Wolff-8/+8
2021-08-03Auto merge of #87033 - FabianWolff:issue-87017, r=estebankbors-0/+94
Provide a suggestion when trying to destructure a `Vec` as a slice Fixes #87017. r? `@estebank`
2021-08-02Auto merge of #87628 - estebank:unmet-explicit-lifetime-bound, r=oli-obkbors-3/+9
Point at unmet explicit lifetime obligation bound r? `@oli-obk` Split off of #85799.
2021-08-02Run rustfix in `pattern-slice-vec.rs` UI testFabian Wolff-4/+46
2021-08-02Rollup merge of #87673 - estebank:opaque-ty-mismatch, r=davidtwcoCameron Steffen-24/+29
Tweak opaque type mismatch error
2021-08-02Rollup merge of #87659 - FabianWolff:issue-87397, r=davidtwcoCameron Steffen-0/+51
Fix invalid suggestions for non-ASCII characters in byte constants Fixes #87397.
2021-07-31Auto merge of #87662 - FabianWolff:rb-string, r=estebankbors-0/+30
Suggest `br` if the unknown string prefix `rb` is found Currently, for the following code: ```rust fn main() { rb"abc"; } ``` we issue the following suggestion: ``` help: consider inserting whitespace here | 2 | rb "abc"; | -- ``` With my changes (only in edition 2021, where unknown prefixes became an error), I get: ``` help: use `br` for a raw byte string | 2 | br"abc"; | ^^ ```
2021-07-31Provide a suggestion when trying to destructure a `Vec` as a sliceFabian Wolff-0/+52
2021-07-31Tweak opaque type mismatch errorEsteban Küber-24/+29
2021-07-31Point at unmet explicit lifetime obligation boundEsteban Küber-3/+9
2021-07-31Suggest `br` if the unknown string prefix `rb` is foundFabian Wolff-0/+30
2021-07-31Fix invalid suggestions for non-ASCII characters in byte constantsFabian Wolff-0/+51
2021-07-30Auto merge of #86754 - estebank:use-multispans-more, r=varkorbors-54/+80
Use `multipart_suggestions` more Built on top of #86532
2021-07-30Auto merge of #87640 - JohnTitor:rollup-yq24nq5, r=JohnTitorbors-14/+37
Rollup of 9 pull requests Successful merges: - #86072 (Cross compiling rustc_llvm on Darwin requires zlib.) - #87385 (Make `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` warn by default) - #87547 (Add missing examples for NonNull) - #87557 (Fix issue with autofix for ambiguous associated function from Rust 2021 prelude when struct is generic) - #87559 (Tweak borrowing suggestion in `for` loop) - #87596 (Add warning when whitespace is not skipped after an escaped newline) - #87606 (Add some TAIT-related regression tests) - #87609 (Add docs about performance and `Iterator::map` to `[T; N]::map`) - #87616 (Fix missing word in rustdoc book) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-07-30Use multispan suggestions more oftenEsteban Küber-54/+80
* Use more accurate span for `async move` suggestion * Use more accurate span for deref suggestion * Use `multipart_suggestion` more often
2021-07-30Tweak borrowing suggestion in `for` loopEsteban Küber-14/+37
2021-07-30Do not discard `?Sized` type params and suggest their removalEsteban Küber-0/+4
2021-07-25Bless tests.Camille GILLOT-28/+28
2021-07-22Auto merge of #87265 - Aaron1011:hir-wf-fn, r=estebankbors-6/+6
Support HIR wf checking for function signatures During function type-checking, we normalize any associated types in the function signature (argument types + return type), and then create WF obligations for each of the normalized types. The HIR wf code does not currently support this case, so any errors that we get have imprecise spans. This commit extends `ObligationCauseCode::WellFormed` to support recording a function parameter, allowing us to get the corresponding HIR type if an error occurs. Function typechecking is modified to pass this information during signature normalization and WF checking. The resulting code is fairly verbose, due to the fact that we can no longer normalize the entire signature with a single function call. As part of the refactoring, we now perform HIR-based WF checking for several other 'typed items' (statics, consts, and inherent impls). As a result, WF and projection errors in a function signature now have a precise span, which points directly at the responsible type. If a function signature is constructed via a macro, this will allow the error message to point at the code 'most responsible' for the error (e.g. a user-supplied macro argument).
2021-07-20Support HIR wf checking for function signaturesAaron Hill-6/+6
During function type-checking, we normalize any associated types in the function signature (argument types + return type), and then create WF obligations for each of the normalized types. The HIR wf code does not currently support this case, so any errors that we get have imprecise spans. This commit extends `ObligationCauseCode::WellFormed` to support recording a function parameter, allowing us to get the corresponding HIR type if an error occurs. Function typechecking is modified to pass this information during signature normalization and WF checking. The resulting code is fairly verbose, due to the fact that we can no longer normalize the entire signature with a single function call. As part of the refactoring, we now perform HIR-based WF checking for several other 'typed items' (statics, consts, and inherent impls). As a result, WF and projection errors in a function signature now have a precise span, which points directly at the responsible type. If a function signature is constructed via a macro, this will allow the error message to point at the code 'most responsible' for the error (e.g. a user-supplied macro argument).
2021-07-20Get back the more precise suggestion spans of old regionckOli Scherer-2/+2
2021-07-19Various diagnostics clean ups/tweaksEsteban Küber-10/+45
* Always point at macros, including derive macros * Point at non-local items that introduce a trait requirement * On private associated item, point at definition
2021-07-15Suggest full enum variant for local modulesAlik Aslanyan-0/+26
2021-07-12Auto merge of #86815 - FabianWolff:issue-84210, r=varkorbors-8/+8
Improve error reporting for modifications behind `&` references I had a look at #84210 and noticed that #85823 has effectively already fixed #84210. However, the string matching in #85823 is _very_ crude and already breaks down when a variable name starts with `mut`. I have made this a bit more robust; further improvements could definitely be made but are complicated by the lack of information provided by an earlier pass: https://github.com/rust-lang/rust/blob/ce331ee6ee010438d1a58c7da8ced4f26d69a20e/compiler/rustc_mir_build/src/build/matches/mod.rs#L2103-L2107 I have also fixed a missing comma in the error message.
2021-07-11Do not suggest adding a semicolon after `?`Fabian Wolff-0/+60
2021-07-02Improve error reporting for modifications behind `&` referencesFabian Wolff-8/+8
2021-06-28Fix garbled suggestion for missing lifetime specifierFabian Wolff-0/+43
2021-06-25Address PR feedbackRyan Levick-4/+4
2021-06-25Change how edition based future compatibility warnings are handledRyan Levick-4/+4
2021-06-24Auto merge of #85427 - ehuss:fix-use-placement, r=jackh726bors-0/+101
Fix use placement for suggestions near main. This fixes an edge case for the suggestion to add a `use`. When running with `--test`, the `main` function will be annotated with an `#[allow(dead_code)]` attribute. The `UsePlacementFinder` would end up using the dummy span of that synthetic attribute. If there are top-level inner attributes, this would place the `use` in the wrong position. The solution here is to ignore attributes with dummy spans. In the process of working on this, I discovered that the `use_suggestion_placement` test was broken. `UsePlacementFinder` is unaware of active attributes. Attributes like `#[derive]` don't exist in the AST since they are removed. Fixing that is difficult, since the AST does not retain enough information. I considered trying to place the `use` towards the top of the module after any `extern crate` items, but I couldn't find a way to get a span for the start of a module block (the `mod` span starts at the `mod` keyword, and it seems tricky to find the spot just after the opening bracket and past inner attributes). For now, I just put some comments about the issue. This appears to have been a known issue in #44215 where the test for it was introduced, and the fix seemed to be deferred to later.
2021-06-23Auto merge of #86386 - ↵bors-2/+0
inquisitivecrystal:better-errors-for-display-traits-v3, r=estebank Better errors for Debug and Display traits Currently, if someone tries to pass value that does not implement `Debug` or `Display` to a formatting macro, they get a very verbose and confusing error message. This PR changes the error messages for missing `Debug` and `Display` impls to be less overwhelming in this case, as suggested by #85844. I was a little less aggressive in changing the error message than that issue proposed. Still, this implementation would be enough to reduce the number of messages to be much more manageable. After this PR, information on the cause of an error involving a `Debug` or `Display` implementation would suppressed if the requirement originated within a standard library macro. My reasoning was that errors originating from within a macro are confusing when they mention details that the programmer can't see, and this is particularly problematic for `Debug` and `Display`, which are most often used via macros. It is possible that either a broader or a narrower criterion would be better. I'm quite open to any feedback. Fixes #85844.
2021-06-22Updated tests to reflect specified types in E0121Deadbeef-18/+18
2021-06-16Update test stderr filesAris Merchant-2/+0
2021-06-12Pretty print generator witness only in `-Zverbose` modeTomasz Miąsko-1/+1
In release build of deeply-nested-async benchmark the size of `no-opt.bc` file is reduced from 46MB to 62kB.
2021-06-12Auto merge of #86215 - FabianWolff:unnameable-types, r=jackh726bors-0/+105
Do not suggest to add type annotations for unnameable types Consider this example: ```rust const A = || 42; struct S<T> { t: T } const B: _ = S { t: || 42 }; ``` This currently produces the following output: ``` error: missing type for `const` item --> src/lib.rs:1:7 | 1 | const A = || 42; | ^ help: provide a type for the item: `A: [closure@src/lib.rs:1:11: 1:16]` error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> src/lib.rs:4:10 | 4 | const B: _ = S { t: || 42 }; | ^ | | | not allowed in type signatures | help: replace `_` with the correct type: `S<[closure@src/lib.rs:4:21: 4:26]>` error: aborting due to 2 previous errors ``` However, these suggestions are obviously useless, because the suggested types cannot be written down. With my changes, the suggestion is replaced with a note, because there is no simple fix: ``` error: missing type for `const` item --> test.rs:1:7 | 1 | const A = || 42; | ^ | note: however, the inferred type `[closure@test.rs:1:11: 1:16]` cannot be named --> test.rs:1:11 | 1 | const A = || 42; | ^^^^^ error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> test.rs:4:10 | 4 | const B: _ = S { t: || 42 }; | ^ not allowed in type signatures | note: however, the inferred type `S<[closure@test.rs:4:21: 4:26]>` cannot be named --> test.rs:4:14 | 4 | const B: _ = S { t: || 42 }; | ^^^^^^^^^^^^^^ error: aborting due to 2 previous errors ```
2021-06-11Suggest a FnPtr type if a FnDef type is foundFabian Wolff-27/+33
2021-06-11Do not suggest to add type annotations for unnameable typesFabian Wolff-0/+99
2021-06-07Suggest a trailing comma if a 1-tuple is expectedFabian Wolff-0/+80
2021-06-05Rollup merge of #85979 - tlyu:where-no-unsized-indirection, r=estebankYuki Okushi-0/+29
don't suggest unsized indirection in where-clauses Skip where-clauses when suggesting using indirection in combination with `?Sized` bounds on type parameters. Fixes #85943. `@estebank` I think this doesn't conflict with your work in #85947; please let me know if you'd like me to cherry pick it to a new branch based on yours instead.