-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add primitive type support to disallowed_type lint #7488
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
Conversation
r? @camsteffen (rust-highfive has picked a reviewer for you, use r? to override) |
Closes #6845 |
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.
Some minor requests. This is a nice enhancement!
clippy_lints/src/disallowed_type.rs
Outdated
match cx.qpath_res(path, ty.hir_id) { | ||
Res::Def(_, did) => { | ||
if let Some(name) = self.def_ids.get(&did) { | ||
emit(cx, name, path.span()); |
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 change this to use cx.tcx.def_path_str
? Also I think you should factor in check_qpath(self, qpath, span)
for repeated code.
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.
So the last commit has what I think you mean by factor check_qpath
but I'm unsure?
As for using cx.txc.def_path_str
I'm fine with it I just wanted you to be aware of my reasoning for not using it. The user seeing the exact path that they banned in the Conf
struct may be less surprising than banning a re-export and getting a different name in the warning. I'm fine either way just thought to mention it 🤷
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.
I think that's okay if it doesn't match the config exactly.
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.
Oh yeah, it seems to actually follow the re-exports (notice syn::Ident) nice thanks for putting up with all my questions!
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.
No problem! cx.get_def_path
gets the absolute path so it's confusing.
beaf60e
to
6e7d679
Compare
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.
Looks great! Please squash commits.
Fix docs of disallowed_type Add ability to name primitive types without import path Move primitive resolution to clippy_utils path_to_res fn Refactor Res matching, fix naming and docs from review Use tcx.def_path_str when emitting the lint
As always thanks for all the help! |
@bors r+ |
📌 Commit a1bab3b has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Closes #6845
changelog: Enable the banning of primitive types in [
disallowed_type
]