Add primitive type support to disallowed_type lint#7488
Add primitive type support to disallowed_type lint#7488bors merged 1 commit intorust-lang:masterfrom
Conversation
|
r? @camsteffen (rust-highfive has picked a reviewer for you, use r? to override) |
|
Closes #6845 |
camsteffen
left a comment
There was a problem hiding this comment.
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.
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.
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.
I think that's okay if it doesn't match the config exactly.
There was a problem hiding this comment.
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.
No problem! cx.get_def_path gets the absolute path so it's confusing.
beaf60e to
6e7d679
Compare
camsteffen
left a comment
There was a problem hiding this comment.
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]