Skip to content

Build complete usable type from a type-relative prefix #14586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2025

Conversation

samueltardieu
Copy link
Contributor

@samueltardieu samueltardieu commented Apr 10, 2025

Instead of looking for angle brackets in the source code, use the HIR and Ty interfaces to either copy the original type, or complete it with _ placeholders if all type and const generic arguments are inferred.

Fixes #14581

changelog: [from_iter_instead_of_collect]: show correct type in suggestion

Instead of looking for angle brackets in the source code, use the HIR
and Ty interfaces to either copy the original type, or complete it with
`_` placeholders if all type and const generic arguments are inferred.
@rustbot
Copy link
Collaborator

rustbot commented Apr 10, 2025

r? @blyxyas

rustbot has assigned @blyxyas.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Apr 10, 2025
Copy link
Member

@blyxyas blyxyas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent patch Samuel, like always! LGTM, thanks! ❤️ 🌈

let mut ty_str = itertools::join(ty_path.segments.iter().map(|s| s.ident), "::");
let mut first = true;
let mut append = |arg: &str| {
write!(&mut ty_str, "{}{arg}", [", ", "<"][usize::from(first)]).unwrap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really smart way to determine if we should use a comma or not!

@blyxyas blyxyas added this pull request to the merge queue Apr 17, 2025
Merged via the queue into rust-lang:master with commit 222660b Apr 17, 2025
13 of 15 checks passed
@samueltardieu samueltardieu deleted the issue-14581 branch April 17, 2025 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

from_iter_instead_of_collect help output invalid rust code
3 participants