about summary refs log tree commit diff
path: root/src/test/ui/suggestions
AgeCommit message (Collapse)AuthorLines
2022-08-24Rollup merge of #100826 - ↵Matthias Krüger-0/+31
vincenzopalazzo:macros/wrong_sugg_with_positional_arg, r=TaKO8Ki sugg: take into count the debug formatting Closes https://github.com/rust-lang/rust/issues/100648 This PR will fix a suggestion error by taking into consideration also the `:?` symbol and act in a different way ``@rustbot`` r? ``@compiler-errors`` N.B: I did not find a full way to test the change, any idea?
2022-08-23sugg: take into count the debug formattingVincenzo Palazzo-0/+31
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2022-08-22sugg: suggest the usage of boolean value when there is a typo in the keywordVincenzo Palazzo-0/+37
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2022-08-21Suggest moving redundant generic args of an assoc fn to its traitHirochika Matsumoto-0/+101
2022-08-21Bless tests after #100769Michael Goulet-2/+2
2022-08-21Adjust messages, address some nitsMichael Goulet-12/+12
2022-08-21Deduplicate errors that come from places like normalization, sizedMichael Goulet-14/+1
2022-08-21Account for relative pathsMichael Goulet-12/+33
2022-08-21Rework point-at-argMichael Goulet-35/+35
2022-08-20Rollup merge of #100769 - ↵Matthias Krüger-0/+55
TaKO8Ki:suggest-adding-reference-to-trait-assoc-item, r=cjgillot Suggest adding a reference to a trait assoc item fixes #100289
2022-08-20Rollup merge of #99935 - CAD97:unstable-syntax-lints, r=petrochenkovMatthias Krüger-0/+30
Reenable disabled early syntax gates as future-incompatibility lints - MCP: https://github.com/rust-lang/compiler-team/issues/535 The approach taken by this PR is - Introduce a new lint, `unstable_syntax_pre_expansion`, and reenable the early syntax gates to emit it - Use the diagnostic stashing mechanism to stash warnings the early warnings - When the hard error occurs post expansion, steal and cancel the early warning - Don't display any stashed warnings if errors are present to avoid the same noise problem that hiding type ascription errors is avoiding Commits are working commits, but in a coherent steps-to-implement manner. Can be squashed if desired. The preexisting `soft_unstable` lint seems like it would've been a good fit, but it is deny-by-default (appropriate for `#[bench]`) and these gates should be introduced as warn-by-default. It may be desirable to change the stash mechanism's behavior to not flush lint errors in the presence of other errors either (like is done for warnings here), but upgrading a stash-using lint from warn to error perhaps is enough of a request to see the lint that they shouldn't be hidden; additionally, fixing the last error to get new errors thrown at you always feels bad, so if we know the lint errors are present, we should show them. Using a new flag/mechanism for a "weak diagnostic" which is suppressed by other errors may also be desirable over assuming any stashed warnings are "weak," but this is the first user of stashing warnings and seems an appropriate use of stashing (it follows the "know more later to refine the diagnostic" pattern; here we learn that it's in a compiled position) so we get to define what it means to stash a non-hard-error diagnostic. cc `````@petrochenkov````` (seconded MCP)
2022-08-20Rollup merge of #100186 - compiler-errors:or-as_mut, r=fee1-deadMatthias Krüger-72/+8
Mention `as_mut` alongside `as_ref` in borrowck error message Kinda fixes #99426 but I guess that really might be better staying open to see if we could make it suggest `as_mut` in a structured way. Not sure how to change borrowck to know that info tho.
2022-08-20suggest adding a reference to a trait assoc itemTakayuki Maeda-0/+55
2022-08-19fix updated stderr outputsMatthew Kelly-1/+2
2022-08-18Reword "Required because of the requirements on the impl of ..."Andy Wang-25/+25
2022-08-17New ui tests for new soft feature gatesChristopher Durham-0/+30
2022-08-16Make as_ref suggestion a noteMichael Goulet-72/+8
2022-08-16Do not report cycle error when inferring return type for suggestionMichael Goulet-0/+52
2022-08-15Rollup merge of #100458 - compiler-errors:fn-argument-span, r=estebankMatthias Krüger-8/+2
Adjust span of fn argument declaration Span of a fn argument declaration goes from: ``` fn foo(i : i32 , ...) ^^^^^^^^ ``` to: ``` fn foo(i : i32 , ...) ^^^^^^^ ``` That is, we don't include the extra spacing up to the trailing comma, which I think is more correct. cc https://github.com/rust-lang/rust/pull/99646#discussion_r944568074 r? ``@estebank`` --- The two tests that had dramatic changes in their rendering I think actually are improved, though they are kinda poor spans both before and after the changes. :shrug: Thoughts?
2022-08-15Rollup merge of #100031 - GoldsteinE:try-removing-the-field, r=michaelwoeristerMatthias Krüger-0/+56
improve "try ignoring the field" diagnostic Closes #95795
2022-08-14Suggest as_ref or as_mutMichael Goulet-3/+3
2022-08-13Rollup merge of #100479 - compiler-errors:argument-type-error-improvements, ↵Michael Goulet-6/+12
r=lcnr Argument type error improvements Motivated by this interesting code snippet: ```rust #[derive(Copy, Clone)] struct Wrapper<T>(T); fn foo(_: fn(i32), _: Wrapper<i32>) {} fn f(_: u32) {} fn main() { let w = Wrapper::<isize>(1isize); foo(f, w); } ``` Which currently errors like: ``` error[E0308]: arguments to this function are incorrect --> src/main.rs:10:5 | 10 | foo(f, w); | ^^^ - - expected `i32`, found `isize` | | | expected `i32`, found `u32` | = note: expected fn pointer `fn(i32)` found fn item `fn(u32) {f}` = note: expected struct `Wrapper<i32>` found struct `Wrapper<isize>` note: function defined here --> src/main.rs:4:4 | 4 | fn foo(_: fn(i32), _: Wrapper<i32>) {} | ^^^ ---------- --------------- ``` Specifically, that double `expected .. found ..` which is very difficult to correlate to the types in the arguments. Also, the fact that "expected `i32`, found `isize`" and the other argument mismatch label don't even really explain what's going on here. After this PR: ``` error[E0308]: arguments to this function are incorrect --> $DIR/two-mismatch-notes.rs:10:5 | LL | foo(f, w); | ^^^ | note: expected fn pointer, found fn item --> $DIR/two-mismatch-notes.rs:10:9 | LL | foo(f, w); | ^ = note: expected fn pointer `fn(i32)` found fn item `fn(u32) {f}` note: expected struct `Wrapper`, found a different struct `Wrapper` --> $DIR/two-mismatch-notes.rs:10:12 | LL | foo(f, w); | ^ = note: expected struct `Wrapper<i32>` found struct `Wrapper<isize>` note: function defined here --> $DIR/two-mismatch-notes.rs:4:4 | LL | fn foo(_: fn(i32), _: Wrapper<i32>) {} | ^^^ ---------- --------------- error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. ``` Yeah, it's a bit verbose, but much clearer IMO. --- Open to discussions about how this could be further improved. Motivated by `@jyn514's` [tweet](https://mobile.twitter.com/joshuayn514/status/1558042020601634816) here.
2022-08-13Do not inline non-simple argument type errors into labelsMichael Goulet-6/+12
2022-08-12Adjust span of fn argumentsMichael Goulet-8/+2
2022-08-12improve "try ignoring the field" diagnosticGoldstein-0/+56
Closes #95795
2022-08-11Suggest path separator when a dot is used on a traitLeón Orell Valerian Liehr-3/+1
2022-08-10Rollup merge of #100349 - TaKO8Ki:remove-type-string-comparison, r=lcnrMichael Goulet-1/+68
Refactor: remove a type string comparison
2022-08-10remove a type string comparisonTakayuki Maeda-1/+68
2022-08-10Rollup merge of #100098 - compiler-errors:field-suggestion-fixups, r=davidtwcoMatthias Krüger-0/+49
Some "this expression has a field"-related fixes Each commit does something different and is worth reviewing, but the final diff from `master..HEAD` contains the sum of the changes to the UI tests, since some commits added UI tests "regressions" which were later removed in other commits. The only change I could see adding on top of this is suppressing `Clone::clone` from the "this expression has a field that has this method" suggestion, since it's so commonly implemented by types that it's not worthwhile suggesting in general.
2022-08-05Rollup merge of #100168 - ↵Dylan DPC-31/+31
WaffleLapkin:improve_diagnostics_for_missing_type_in_a_const_item, r=compiler-errors Improve diagnostics for `const a: = expr;` Adds a suggestion to write a type when there is a colon, but the type is not present. I've also shrunk spans a little, so the suggestions are a little nicer. Resolves #100146 r? `@compiler-errors`
2022-08-05Improve diagnostics for `const a: = expr;`Maybe Waffle-31/+31
2022-08-03Skip over structs with no private fields that impl DerefMichael Goulet-0/+49
2022-08-03Consider privacy more carefully when suggesting accessing fieldsMichael Goulet-22/+0
2022-08-03Suggest expressions' fields even if they're not ADTsMichael Goulet-0/+22
2022-07-31Improve `cannot move out of` error messageObei Sideg-24/+24
2022-07-31Rollup merge of #99974 - ↵Dylan DPC-0/+200
TaKO8Ki:suggest-removing-semicolon-and-boxing-the-expressions, r=compiler-errors Suggest removing a semicolon and boxing the expressions for if-else `InferCtxt::suggest_remove_semi_or_return_binding` was not working well, so I fixed it and added a ui test.
2022-07-31Rollup merge of #99741 - compiler-errors:copy-impl-impl-generics, r=fee1-deadDylan DPC-0/+95
Use `impl`'s generics when suggesting fix on bad `impl Copy` See the UI test for a more complicated example, but we weren't correctly suggesting to add bounds given a manual `impl` whose generics didn't match the struct generics. ```rust #[derive(Clone)] struct Wrapper<T>(T); impl<S> Copy for Wrapper<S> {} ``` Coincidentally this fix didn't cause any regressions for `derive(Copy)` impls, I think because those use the same spans in the impl generics as the struct generics, so the machinery still applies the same change.
2022-07-31add a test to check if `suggest_remove_semi_or_return_binding` is working ↵Takayuki Maeda-0/+200
well for if-else
2022-07-30Rollup merge of #99891 - compiler-errors:suggest-slicing-carefully, r=oli-obkYuki Okushi-1/+17
Adjust an expr span to account for macros Fix this erroneous suggestion: ``` error[E0529]: expected an array or slice, found `Vec<{integer}>` --> /home/gh-compiler-errors/test.rs:2:9 | 2 | let [..] = vec![1, 2, 3]; | ^^^^ pattern cannot match with input type `Vec<{integer}>` | help: consider slicing here --> /home/gh-compiler-errors/rust2/library/alloc/src/macros.rs:50:36 | 50~ $crate::__rust_force_expr!(<[_]>::into_vec( 51+ #[rustc_box] 52+ $crate::boxed::Box::new([$($x),+]) 53~ )[..]) ```
2022-07-30Rollup merge of #99671 - TaKO8Ki:suggest-dereferencing-index, r=compiler-errorsYuki Okushi-0/+31
Suggest dereferencing index when trying to use a reference of usize as index fixes #96678
2022-07-29Adjust an expr span to account for macrosMichael Goulet-1/+17
2022-07-29check if T is sliceTakayuki Maeda-1/+1
fix msg
2022-07-27Rollup merge of #99698 - compiler-errors:no-doc-hidden, r=cjgillotYuki Okushi-0/+69
Prefer visibility map parents that are not `doc(hidden)` first Far simpler approach to #98876. This only fixes the case where the parent is `doc(hidden)`, not where the child is `doc(hidden)` since I don't know how to get the attrs on the import statement given a `ModChild`... I'll try to follow up with that, but this is a good first step.
2022-07-26Use real opaque type instead of just saying impl TraitMichael Goulet-2/+2
2022-07-26Use impl generics when suggesting fix on copy implMichael Goulet-0/+95
2022-07-25Auto merge of #97313 - cjgillot:ast-lifetimes-anon, r=petrochenkovbors-334/+189
Resolve function lifetime elision on the AST ~Based on https://github.com/rust-lang/rust/pull/97720~ Lifetime elision for functions is purely syntactic in nature, so can be resolved on the AST. This PR replicates the elision logic and diagnostics on the AST, and replaces HIR-based resolution by a `delay_span_bug`. This refactor allows for more consistent diagnostics, which don't have to guess the original code from HIR. r? `@petrochenkov`
2022-07-25Report elision failures on the AST.Camille GILLOT-334/+189
2022-07-24Do not prefer module parents which are `doc(hidden)` in visibility mapMichael Goulet-3/+3
2022-07-24Add failing testAlik Aslanyan-0/+69
2022-07-24suggest dereferencing index when trying to use a reference of usize as indexTakayuki Maeda-0/+31