about summary refs log tree commit diff
path: root/src/test/ui/suggestions
AgeCommit message (Collapse)AuthorLines
2022-12-13Remove invalid case for mutable borrow suggestionDeep Majumder-0/+26
If we have a call such as `foo(&mut buf)` and after reference collapsing the type is inferred as `&T` where-as the required type is `&mut T`, don't suggest `foo(&mut mut buf)`. This is wrong syntactically and the issue lies elsewhere, not in the borrow. Fixes #105645
2022-12-13Clarify what "this" meansOli Scherer-6/+6
2022-12-13Inform the user which trait is meant in the diagnostic itself instead of ↵Oli Scherer-2/+2
relying on the span making it obvious
2022-12-13Make some diagnostics not depend on the source of what they reference being ↵Oli Scherer-148/+18
available
2022-12-13Rollup merge of #105332 - estebank:iterator-chains, r=oli-obkMatthias Krüger-4/+2
Point out the type of associated types in every method call of iterator chains Partially address #105184 by pointing out the type of associated types in every method call of iterator chains: ``` note: the expression is of type `Map<std::slice::Iter<'_, {integer}>, [closure@src/test/ui/iterators/invalid-iterator-chain.rs:12:18: 12:21]>` --> src/test/ui/iterators/invalid-iterator-chain.rs:12:14 | 10 | vec![0, 1] | ---------- this expression has type `Vec<{integer}>` 11 | .iter() | ------ associated type `std::iter::Iterator::Item` is `&{integer}` here 12 | .map(|x| { x; }) | ^^^^^^^^^^^^^^^ associated type `std::iter::Iterator::Item` is `()` here ``` We also reduce the number of impls we mention when any of the candidates is an "exact match". This benefits the output of cases with numerics greatly. Outstanding work would be to provide a structured suggestion for appropriate changes, like in this case detecting the spurious `;` in the closure.
2022-12-11Point at method call when it is the source of the bound errorEsteban Küber-4/+2
2022-12-11Rollup merge of #105369 - chenyukang:yukang/fix-105226, r=TaKO8KiMatthias Krüger-0/+53
Detect spurious ; before assoc fn body Fixes #105226 r? ``@TaKO8Ki``
2022-12-10Introduce `with_forced_trimmed_paths`Esteban Küber-7/+7
2022-12-08Point at LHS on binop type err if relevantEsteban Küber-2/+7
2022-12-07fix #105226, Detect spurious ; before assoc fn bodyyukang-0/+53
2022-12-06Rollup merge of #105349 - compiler-errors:point-at-assoc-ct-fn-ptr-arg, ↵Matthias Krüger-2/+4
r=cjgillot Point at args in associated const fn pointers Tiny follow-up to #105201, not so sure it's worth it but :shrug: The UI test example is a bit more compelling when it's `GlUniformScalar::FACTORY` r? `@cjgillot`
2022-12-06Rollup merge of #105174 - chenyukang:yukang/fix-105028-unused, r=eholkMatthias Krüger-1/+30
Suggest removing struct field from destructive binding only in shorthand scenario Fixes #105028
2022-12-06Point at args in associated const fn pointersMichael Goulet-2/+4
2022-12-04Rollup merge of #101975 - chenyukang:fix-101749, r=compiler-errorsMatthias Krüger-6/+6
Suggest to use . instead of :: when accessing a method of an object Fixes #101749 Fixes #101542
2022-12-04Rollup merge of #104856 - luqmana:associated-const-bad-suggestion, ↵Matthias Krüger-7/+1
r=compiler-errors Don't suggest associated function call for associated const. Fixes #104801. r? `@compiler-errors`
2022-12-03fix #101749, use . instead of :: when accessing a method of an objectyukang-6/+6
2022-12-03Do not call fn_sig on non-functions.Camille GILLOT-0/+32
2022-12-01fix #105028, Only suggest removing struct field from destructive binding in ↵yukang-1/+30
shorthand scenario
2022-11-29clean up pr 104954Rageking8-3/+2
2022-11-28Rollup merge of #104954 - vincenzopalazzo:macros/prinf, r=estebankMatthias Krüger-0/+23
make simple check of prinf function Fixes https://github.com/rust-lang/rust/issues/92898 With this commit we start to make some simple check when the name resolution fails, and we generate some helper messages in case the name is a C name like in the case of the `printf` and suggest the correct rust method. `@rustbot` r? `@pnkfelix` Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2022-11-28Rollup merge of #104795 - estebank:multiline-spans, r=TaKO8KiDylan DPC-5/+5
Change multiline span ASCII art visual order Tweak the ASCII art for nested multiline spans so that we minimize line overlaps. Partially addresses https://github.com/rust-lang/rust/issues/61017.
2022-11-28Tweak outputEsteban Küber-3/+3
2022-11-28Change multiline span ASCII art visual orderEsteban Küber-8/+8
2022-11-27Auto merge of #104983 - matthiaskrgr:rollup-018sk73, r=matthiaskrgrbors-1/+1
Rollup of 8 pull requests Successful merges: - #95836 (Use `rust_out{exe_suffix}` for doctests) - #104882 (notify lcnr on changes to `ObligationCtxt`) - #104892 (Explain how to get the discriminant out of a `#[repr(T)] enum` with payload) - #104917 (Allow non-org members to label `requires-debug-assertions`) - #104931 (Pretty-print generators with their `generator_kind`) - #104934 (Remove redundant `all` in cfg) - #104944 (Support unit tests for jsondoclint) - #104946 (rustdoc: improve popover focus handling JS) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-11-27Auto merge of #104048 - cjgillot:split-lifetime, r=compiler-errorsbors-45/+207
Separate lifetime ident from lifetime resolution in HIR Drive-by: change how suggested generic args are computed. Fixes https://github.com/rust-lang/rust/issues/103815 I recommend reviewing commit-by-commit.
2022-11-27make simple check of prinf function.Vincenzo Palazzo-0/+23
With this commit we start to make some simple check when the name resolution fails, and we generate some helper message in case the name is a C name like in the case of the `printf` and suggest the correct rust method. Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2022-11-26Pretty-print generators with their `generator_kind`Arpad Borsos-1/+1
After removing `GenFuture`, I special-cased async generators to pretty-print as `impl Future<Output = X>` mainly to avoid too much diagnostics changes originally. This now reverses that change so that async fn/blocks are pretty-printed as `[$movability `async` $something@$source-position]` in various diagnostics, and updates the tests that this touches.
2022-11-24Don't suggest associated function call for associated const.Luqman Aden-7/+1
2022-11-24Use kw::Empty for elided lifetimes in path.Camille GILLOT-33/+195
2022-11-24Change how suggested lifetime args are computed.Camille GILLOT-12/+12
2022-11-24Auto merge of #104321 - Swatinem:async-gen, r=oli-obkbors-11/+12
Avoid `GenFuture` shim when compiling async constructs Previously, async constructs would be lowered to "normal" generators, with an additional `from_generator` / `GenFuture` shim in between to convert from `Generator` to `Future`. The compiler will now special-case these generators internally so that async constructs will *directly* implement `Future` without the need to go through the `from_generator` / `GenFuture` shim. The primary motivation for this change was hiding this implementation detail in stack traces and debuginfo, but it can in theory also help the optimizer as there is less abstractions to see through. --- Given this demo code: ```rust pub async fn a(arg: u32) -> Backtrace { let bt = b().await; let _arg = arg; bt } pub async fn b() -> Backtrace { Backtrace::force_capture() } ``` I would get the following with the latest stable compiler (on Windows): ``` 4: async_codegen::b::async_fn$0 at .\src\lib.rs:10 5: core::future::from_generator::impl$1::poll<enum2$<async_codegen::b::async_fn_env$0> > at /rustc/897e37553bba8b42751c67658967889d11ecd120\library\core\src\future\mod.rs:91 6: async_codegen::a::async_fn$0 at .\src\lib.rs:4 7: core::future::from_generator::impl$1::poll<enum2$<async_codegen::a::async_fn_env$0> > at /rustc/897e37553bba8b42751c67658967889d11ecd120\library\core\src\future\mod.rs:91 ``` whereas now I get a much cleaner stack trace: ``` 3: async_codegen::b::async_fn$0 at .\src\lib.rs:10 4: async_codegen::a::async_fn$0 at .\src\lib.rs:4 ```
2022-11-24Avoid `GenFuture` shim when compiling async constructsArpad Borsos-11/+12
Previously, async constructs would be lowered to "normal" generators, with an additional `from_generator` / `GenFuture` shim in between to convert from `Generator` to `Future`. The compiler will now special-case these generators internally so that async constructs will *directly* implement `Future` without the need to go through the `from_generator` / `GenFuture` shim. The primary motivation for this change was hiding this implementation detail in stack traces and debuginfo, but it can in theory also help the optimizer as there is less abstractions to see through.
2022-11-23Account for `x @ y` and suggest `ref x @ ref y`Esteban Küber-0/+145
2022-11-23Tweak output in for loopsEsteban Küber-4/+0
Do not suggest `.clone()` as we already suggest borrowing the iterated value.
2022-11-23Suggest `.clone()` or `ref binding` on E0382Esteban Küber-0/+5
2022-11-21Unreserve braced enum variants in value namespaceVadim Petrochenkov-27/+11
2022-11-20Rollup merge of #104467 - ↵Yuki Okushi-0/+45
fuzzypixelz:fix/attempt-to-substract-with-overflow, r=compiler-errors Fix substraction with overflow in `wrong_number_of_generic_args.rs` Fixes #104287 This issue happens in the `suggest_moving_args_from_assoc_fn_to_trait_for_qualified_path` function, which seems to run before the error checking facilities can catch an invalid use of generic arguments. Thus we get a subtraction with overflow because the code implicitly assumes that the source program makes sense (or is this assumption not true even if the program is correct?).
2022-11-19Add a UI test to ensure rustc doesn't do arithmetic overflowsMahmoud Mazouz-0/+45
This relies on the CI testing a rustc that's compiled with overflow-checks = true
2022-11-18diagnostics: only show one suggestion for method -> assoc fnMichael Howell-9/+4
Fixes #102354
2022-11-14Add regression testMichael Goulet-0/+19
2022-11-14Do autoderef to match impl against rcvrMichael Goulet-0/+49
2022-11-12Rollup merge of #104144 - TaKO8Ki:suggest-removing-unnecessary-dot, r=fee1-deadGuillaume Gomez-0/+65
Suggest removing unnecessary `.` to use a floating point literal Fixes a part of #101883
2022-11-11Rollup merge of #103531 - chenyukang:yukang/fix-103474, r=estebankManish Goregaokar-2/+7
Suggest calling the instance method of the same name when method not found Fixes #103474
2022-11-11emit errors when using `RangeFrom` and `RangeTo`Takayuki Maeda-6/+13
2022-11-11suggest removing unnecessary . to use a floating point literalTakayuki Maeda-0/+58
2022-11-10Rollup merge of #104186 - chenyukang:yukang/fix-104086-let-binding-issue, ↵Manish Goregaokar-0/+165
r=oli-obk Tighten the 'introduce new binding' suggestion Fixes #104086
2022-11-10Rollup merge of #104036 - compiler-errors:option-sugg, r=petrochenkovManish Goregaokar-0/+25
Suggest `is_some` when we've found `Option` but expected `bool` Thanks `@lunasorcery` for the suggestion.
2022-11-10Auto merge of #103636 - chenyukang:yukang/fix-103587-sugg-if-let, ↵bors-0/+15
r=jackh276,davidtwco Recover from common if let syntax mistakes/typos Fixes #103587
2022-11-10Auto merge of #101990 - clubby789:dont-machine-apply-placeholder-method, ↵bors-13/+163
r=compiler-errors Fix auto-application of associated generic functions with placeholders Fixes #101920
2022-11-09Suggest is_some or let when encountering Option and bool type mismatchMichael Goulet-0/+25