-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Conversation
r? @jackh726 (rustbot has picked a reviewer for you, use r? to override) |
compiler/rustc_lint/src/lints.rs
Outdated
pub func_label: MappingToUnitFuncLabel, | ||
} | ||
|
||
pub struct MappingToUnitFuncLabel { |
There was a problem hiding this comment.
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)
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)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
2ac74d2
to
b3af5e2
Compare
LL | vec![42].iter().map(drop); | ||
| ^^^^----^ | ||
| | | | ||
| | this function returns `()`, which is likely not what you wanted |
There was a problem hiding this comment.
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.
fine by me i guess -- overlapping spans aren't great, but this is clear enough. r=me when ci is green |
@bors r=compiler-errors |
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
Fixes #109152