Better suggestions when user tries to collect into an unsized [_]#91443
Better suggestions when user tries to collect into an unsized [_]#91443bors merged 2 commits intorust-lang:masterfrom
[_]#91443Conversation
|
(rust-highfive has picked a reviewer for you, use r? to override) |
|
Could you add a test case demonstrating the new behavior? |
c526bb7 to
aa23424
Compare
|
@Aaron1011 added a test. Still unclear what the best wording for this specific suggestion is, but demonstrating that it works. |
|
☔ The latest upstream changes (presumably #93352) made this pull request unmergeable. Please resolve the merge conflicts. |
|
howdy @matthewjasper, should I reassign this PR to someone else on the high-five queue? |
|
Yes please |
|
reassigning per reviewer request r? rust-lang/compiler |
|
@compiler-errors This looks great! My only suggestion was going to be to mention the |
aa23424 to
dea99b3
Compare
dea99b3 to
fea0015
Compare
|
Alright @wesleywiser, rebased and confirmed tests still pass! |
|
@bors r+ |
|
📌 Commit fea0015 has been approved by |
…ice, r=wesleywiser Better suggestions when user tries to collect into an unsized `[_]` 1. Extend the predicate on `rustc_on_unimplemented` to support substitutions like note, label, etc (i.e. treat it as a `OnUnimplementedFormatString`) so we can have slightly more general `rustc_on_unimplemented` special-cases. 2. Add a `rustc_on_unimplemented` if we fail on `FromIterator<A> for [A]` which happens when we don't explicitly collect into a `vec<A>`, but then pass the return from a `.collect` call into something that takes a slice. Fixes rust-lang#91423
…askrgr Rollup of 6 pull requests Successful merges: - rust-lang#91443 (Better suggestions when user tries to collect into an unsized `[_]`) - rust-lang#91504 (`#[used(linker)]` attribute) - rust-lang#93503 (debuginfo: Fix DW_AT_containing_type vtable debuginfo regression) - rust-lang#93753 (Complete removal of #[main] attribute from compiler) - rust-lang#93799 (Fix typo in `std::fmt` docs) - rust-lang#93813 (Make a few cleanup MIR passes public) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
|
What would it take to add a structured suggestion to this diagnostic? |
|
@NieDzejkob, what do you mean by this? I don't think the If you're interested in that route, you probably have a good bet putting some logic to detect this case in |
rustc_on_unimplementedto support substitutions like note, label, etc (i.e. treat it as aOnUnimplementedFormatString) so we can have slightly more generalrustc_on_unimplementedspecial-cases.rustc_on_unimplementedif we fail onFromIterator<A> for [A]which happens when we don't explicitly collect into avec<A>, but then pass the return from a.collectcall into something that takes a slice.Fixes #91423