-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix/12035 silence struct field names #12190
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1846,6 +1846,14 @@ pub fn is_lint_allowed(cx: &LateContext<'_>, lint: &'static Lint, id: HirId) -> | |
cx.tcx.lint_level_at_node(lint, id).0 == Level::Allow | ||
} | ||
|
||
/// Returns `true` if any of the `impl`s for the given `item` has the lint allowed | ||
pub fn any_impl_has_lint_allowed(cx: &LateContext<'_>, lint: &'static Lint, id: DefId) -> bool { | ||
cx.tcx | ||
.inherent_impls(id) | ||
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, a bit late, but does this also return trait impls? Though reading #12035 (comment), it doesn't seem uncontroversial that serde should annotate its impls with this anyway and maybe deserves more discussion in general for the ser/de case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh yeah good point. perhaps we should wait on this PR for now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also looking up all trait impls can be an expensive operation |
||
.iter() | ||
.any(|imp| is_lint_allowed(cx, lint, cx.tcx.hir().expect_item(imp.expect_local()).hir_id())) | ||
} | ||
|
||
pub fn strip_pat_refs<'hir>(mut pat: &'hir Pat<'hir>) -> &'hir Pat<'hir> { | ||
while let PatKind::Ref(subpat, _) = pat.kind { | ||
pat = subpat; | ||
|
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.
thought: unsure if we should perform this check before or after the field name check
this is a bunch of queries, that is some string comparisons, so probably before makes sense.