about summary refs log tree commit diff
path: root/src/test/ui/suggestions
AgeCommit message (Collapse)AuthorLines
2022-11-10add 'is_assign_rhs' to avoid weird suggesting 'let'yukang-4/+24
2022-11-09Rollup merge of #103919 - nnethercote:unescaping-cleanups, r=matkladDylan DPC-12/+12
Unescaping cleanups Some code improvements, and some error message improvements. Best reviewed one commit at a time. r? ````@matklad````
2022-11-09fix tests and code cleanupyukang-16/+70
2022-11-09Fix #104086, Tighten the 'introduce new binding' suggestionyukang-0/+91
2022-11-08fix #103587, Recover from common if let syntax mistakes/typosyukang-0/+15
2022-11-05Rebase and update testclubby789-1/+1
2022-11-05Update UI testclubby789-2/+2
2022-11-05Split non-fixable case to different testclubby789-11/+38
2022-11-05Attempt to fix arguments of associated functionsclubby789-54/+67
2022-11-05Use `FmtPrinter` instead of creating `Instance`clubby789-5/+115
2022-11-05Update UI testclubby789-1/+1
2022-11-04Make non-ASCII errors more consistent.Nicholas Nethercote-12/+12
There are three kinds of "byte" literals: byte literals, byte string literals, and raw byte string literals. None are allowed to have non-ASCII chars in them. Two `EscapeError` variants exist for when that constraint is violated. - `NonAsciiCharInByte`: used for byte literals and byte string literals. - `NonAsciiCharInByteString`: used for raw byte string literals. As a result, the messages for raw byte string literals use different wording, without good reason. Also, byte string literals are incorrectly described as "byte constants" in some error messages. This commit eliminates `NonAsciiCharInByteString` so the three cases are handled similarly, and described correctly. The `mode` is enough to distinguish them. Note: Some existing error messages mention "byte constants" and some mention "byte literals". I went with the latter here, because it's a more correct name, as used by the Reference.
2022-11-01Rollup merge of #103706 - zbyrn:issue-101637-fix, r=estebankDylan DPC-11/+7
Fix E0433 No Typo Suggestions Fixes #48676 Fixes #87791 Fixes #96625 Fixes #95462 Fixes #101637 Follows up PR #72923 Several open issues refer to the problem that E0433 does not suggest typos like other errors normally do. This fix augments the implementation of PR #72923. **Background** When the path of a function call, e.g. `Struct::foo()`, involves names that cannot be resolved, there are two errors that could be emitted by the compiler: - If `Struct` is not found, it is ``E0433: failed to resolve: use of undeclared type `Struct` ``. - If `foo` is not found in `Struct`, it is ``E0599: no function or associated item named `foo` found for struct `Struct` in the current scope`` When a name is used as a type, `e.g. fn foo() -> Struct`, and the name cannot be resolved, it is ``E0412: cannot find type `Struct` in this scope``. Before #72923, `E0433` does not implement any suggestions, and the PR introduces suggestions for missing `use`s. When a resolution error occurs in the path of a function call, it tries to smart resolve just the type part of the path, e.g. `module::Struct` of a call to `module::Struct::foo()`. However, along with the suggestions, the smart-resolve function will report `E0412` since it only knows that it is a type that we cannot resolve instead of being a part of the path. So, the original implementation swap out `E0412` errors returned by the smart-resolve function with the real `E0433` error, but keeps the "missing `use`" suggestions to be reported to the programmer. **Issue** The current implementation only reports if there are "missing `use`" suggestions returned by the smart-resolve function; otherwise, it would fall back the normal reporting, which does not emit suggestions. But the smart-resolve function could also produce typo suggestions, which are omitted currently. Also, it seems like that not all info has been swapped out when there are missing suggestions. The error message underlining the name in the snippet still says ``not found in this scope``, which is a `E0412` messages, if there are `use` suggestions, but says the normal `use of undeclared type` otherwise. **Fixes** This fix swaps out all fields in `Diagnostic` returned by the smart-resolve function except for `suggestions` with the current error, and merges the `suggestions` of the returned error and that of the current error together. If there are `use` suggestions, the error is saved to `use_injection` to be reported at the end; otherwise, the error is emitted immediately as `Resolver::report_error` does. Some tests are updated to use the correct underlining error messages, and one additional test for typo suggestion is added to the test suite. r? rust-lang/diagnostics
2022-10-28Rollup merge of #103550 - notriddle:notriddle/no-suggest-static-candidates, ↵Matthias Krüger-0/+34
r=wesleywiser diagnostics: do not suggest static candidates as traits to import If it's a static candidate, then it's already implemented. Do not suggest it a second time for implementing. Partial fix for #102354
2022-10-27Correct inconsistent error messages in testsByron Zhong-11/+7
2022-10-26Rollup merge of #103416 - compiler-errors:rpit-named, r=cjgillotDylan DPC-3/+3
Name the `impl Trait` in region bound suggestions Slightly more descriptive message
2022-10-25diagnostics: add test case for issue 102354Michael Howell-0/+34
2022-10-26suggest calling the method of the same name when method not foundyukang-2/+7
2022-10-25Name impl trait in region bound suggestionMichael Goulet-3/+3
2022-10-24suggest type annotation for local statement initialed by ref expressionSparrowLii-0/+98
2022-10-23Rollup merge of #103140 - chenyukang:yukang/fix-103112, r=estebankMichael Howell-0/+19
Add diagnostic for calling a function with the same name with unresolved Macro Fixes #103112
2022-10-20fix rust-lang#101880: suggest let for assignment, and some code refactoryukang-0/+94
2022-10-20fix span for suggestionyukang-2/+3
2022-10-20fix #103112, add diagnostic for calling a function with the same name when a ↵yukang-0/+18
Macro is not found
2022-10-19instantiate -> constructMichael Goulet-5/+5
2022-10-19Generalize call suggestion for unsatisfied predicateMichael Goulet-19/+42
2022-10-19Standardize arg suggestions between typeck and trait selectionMichael Goulet-2/+2
2022-10-19Suggest calling ctor when trait is unimplementedMichael Goulet-0/+41
2022-10-10Rollup merge of #102323 - Stoozy:master, r=cjgillotYuki Okushi-2/+10
Trying to suggest additional lifetime parameter ``@cjgillot`` This is what I have so far for #100615
2022-10-06Rollup merge of #102694 - compiler-errors:fn-to-method, r=davidtwcoMatthias Krüger-6/+63
Suggest calling method if fn does not exist I tried to split this up into two commits, the first where we stash the resolution error until typeck (which causes a bunch of diagnostics changes because the ordering of error messages change), then the second commit is the actual logic that actually implements the suggestion. I am not in love with the presentation of the suggestion, so I could use some advice for how to format the actual messaging. r? diagnostics Fixes #102518
2022-10-05Rollup merge of #102496 - compiler-errors:into-suggestion, r=davidtwcoDylan DPC-5/+70
Suggest `.into()` when all other coercion suggestions fail Also removes some bogus suggestions because we now short-circuit when offering coercion suggestions(instead of, for example, suggesting every one that could possibly apply) Fixes #102415
2022-10-05Suggest calling method if fn does not existMichael Goulet-0/+57
2022-10-05Delay function resolution error until typeckMichael Goulet-6/+6
2022-10-04Rollup merge of #102650 - ↵Michael Howell-1/+1
Rageking8:slightly-improve-no-return-for-returning-function-error, r=compiler-errors Slightly improve no return for returning function error Fixes #100607 The rationale is that absolute beginners will be slightly confused as to why certain lines of code in a function does not require a semicolon. (I have actually witness a beginner having this confusion). Hence, a slight rationale is added "to return this value", which signals to the user that after removing said semicolon the value is returned resolving that error. However, if this is not desirable, I welcome any other suggestions. Thanks.
2022-10-05Suggest `.into()` when all other coercion suggestions failMichael Goulet-5/+70
2022-10-04slightly improve no return for returning function errorRageking8-1/+1
2022-10-02fix #102320, suggest unwrap_or_else when a closure is passed to unwrap_or ↵yukang-0/+39
instead of suggesting calling it
2022-10-01bless ui testsMaybe Waffle-3/+3
2022-09-28Proper span for new generic param suggestionstoozy-2/+10
2022-09-28Rollup merge of #102338 - ↵Yuki Okushi-2/+10
compiler-errors:assoc-ty-binding-in-assoc-ty-binding, r=cjgillot Deny associated type bindings within associated type bindings Fixes #102335 This was made worse by #100865, which unified the way we generate substs for GATs and non-generic associated types. However, the issue was not _caused_ by #100865, evidenced by the test I added for GATs: ```rust trait T { type A: S<C<(), i32 = ()> = ()>; //~^ ERROR associated type bindings are not allowed here } trait Q {} trait S { type C<T>: Q; } fn main() {} ``` ^ which passes on beta (where GATs are stable) and presumably ever since GATs support was added to `create_substs_for_associated_item` in astconv.
2022-09-28Rollup merge of #102288 - mejrs:inner, r=compiler-errorsYuki Okushi-0/+218
Suggest unwrapping `???<T>` if a method cannot be found on it but is present on `T`. This suggests various ways to get inside wrapper types if the method cannot be found on the wrapper type, but is present on the wrappee. For this PR, those wrapper types include `Localkey`, `MaybeUninit`, `RefCell`, `RwLock` and `Mutex`.
2022-09-28Rollup merge of #100747 - ↵Yuki Okushi-1/+2
MatthewPeterKelly:mpk/add-long-error-message-for-E0311, r=MatthewPeterKelly Add long description and test for E0311 Adds a long description and unit test for the E0311 compiler error. Fixes one line-item in https://github.com/rust-lang/rust/issues/61137.
2022-09-28Deduplicate some logicmejrs-15/+15
2022-09-27Add newlinemejrs-3/+3
2022-09-27Address feedbackmejrs-12/+64
2022-09-27Wrapper suggestionsmejrs-0/+166
2022-09-27Deny associated type bindings within associated type bindingsMichael Goulet-2/+10
2022-09-27Auto merge of #102306 - lcnr:rustc_hir_analysis, r=compiler-errorsbors-1/+1
rename rustc_typeck to rustc_hir_analysis first part of https://github.com/rust-lang/compiler-team/issues/529 r? `@compiler-errors`
2022-09-27rustc_typeck to rustc_hir_analysislcnr-1/+1
2022-09-27add a label to struct/enum/union ident nameTakayuki Maeda-0/+4