Skip to content
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

Fix MappingToUnit to support no span of arg_ty #109154

Merged
merged 1 commit into from
Mar 15, 2023

Conversation

chenyukang
Copy link
Member

Fixes #109152

@rustbot
Copy link
Collaborator

rustbot commented Mar 15, 2023

r? @jackh726

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 15, 2023
pub func_label: MappingToUnitFuncLabel,
}

pub struct MappingToUnitFuncLabel {
Copy link
Member

Choose a reason for hiding this comment

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

Can you make an enum with two variants, and then you can derive(Subdiagnostic)

tests/ui/lint/issue-109152.rs Show resolved Hide resolved
argument_label: args[0].span,
map_label: arg_ty.default_span(cx.tcx),
suggestion: path.ident.span,
replace: "for_each".to_string(),
func_label: MappingToUnitFuncLabel {
span: cx.tcx.span_of_impl(*id).map_or(None, |s| Some(s)),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
span: cx.tcx.span_of_impl(*id).map_or(None, |s| Some(s)),
span: cx.tcx.span_of_impl(*id).ok(),

But I would prefer if you made MappingToUnitFuncLabel have two variants

LL | vec![42].iter().map(drop);
| ^^^^----^
| | |
| | this function returns `()`, which is likely not what you wanted
Copy link
Member Author

Choose a reason for hiding this comment

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

Use args[0].span as the default span seems reasonable and code is more clean.
@compiler-errors how do you think.

@compiler-errors
Copy link
Member

fine by me i guess -- overlapping spans aren't great, but this is clear enough.

r=me when ci is green

@chenyukang
Copy link
Member Author

@bors r=compiler-errors

@bors
Copy link
Contributor

bors commented Mar 15, 2023

📌 Commit b3af5e2 has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 15, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 15, 2023
Rollup of 7 pull requests

Successful merges:

 - rust-lang#108991 (add `enable-warnings` flag for llvm, and disable it by default.)
 - rust-lang#109109 (Use `unused_generic_params` from crate metadata)
 - rust-lang#109111 (Create dirs for build_triple)
 - rust-lang#109136 (Simplify proc macro signature validity check)
 - rust-lang#109150 (Update cargo)
 - rust-lang#109154 (Fix MappingToUnit  to support no span of arg_ty)
 - rust-lang#109157 (Remove mw from review rotation for a while)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 19d5758 into rust-lang:master Mar 15, 2023
@rustbot rustbot added this to the 1.70.0 milestone Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE: Err on value: "core", map_unit_fn.rs
5 participants