-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Two improvements to disallowed_*
#13669
Conversation
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 add tests to ensure the spaces change works on disallowed_types
? DisallowedPath
is used there too, but it does its own parsing to get the DefId
of types.
1c5ef1b
to
f3401bd
Compare
disallowed_methods
disallowed_*
☔ The latest upstream changes (presumably 627363e) made this pull request unmergeable. Please resolve the merge conflicts. |
f3401bd
to
b97ad4e
Compare
@Centri3 Just so that we are on the same page, I am assuming I have done all I can with this PR. Please let me know if I have misunderstood. Also, thanks very much for reviewing. 🙏 |
Sorry, forgot to say. I haven't looked closely at the new changes but this definitely feels like too much when we could just have two for now. One where replacements are allowed and one where they aren't. Maybe with a shared trait to make the implementation less cumbersome and annoying... I don't know. Using const generics is definitely less understandable than that even if it's not exactly ideal. No solution really feels ideal, actually. |
@Centri3 Is this better? I pushed on top of the const generic stuff, but can squash once we arrive at a solution. |
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 I've found a pretty good solution: Using const generics is okay and probably ideal if we use type aliases. Let's do that vs this struct solution. Unfortunate it took a while for me :P
My main concern with const generics was how they had to be specified everywhere and how it's not immediately clear what it is.
With this, I think we can have just the enum afaik.
Is this what you are suggesting, or something more elaborate? type DisallowedPathWithoutReplacement = DisallowedPath<false>; |
Ah, forgot to respond; yes pretty much. |
The most recent commit undoes most of the commit before it (including getting rid of the Could you please tell me what else is needed? |
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.
Just two small things. Happy with this version
clippy_config/src/types.rs
Outdated
#[serde(untagged)] | ||
pub enum DisallowedPath { | ||
pub enum DisallowedPathEnum { |
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 do find this to be an odd implementation detail. I assume this is just a workaround to both derive Deserialize
and have our const generic, but imo it adds way too much confusion. It should be clearer that it's not to be used elsewhere and ideally wouldn't be here at all.
Let's make this private.
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 made the enum private and I added a comment that it is not meant to be used outside of this file.
I assume this is just a workaround to both derive
Deserialize
and have our const generic, but imo it adds way too much confusion. It should be clearer that it's not to be used elsewhere and ideally wouldn't be here at all.
I'm not wed to this approach. Can you think of another way to do this?
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.
Or is there something I could do to make the code more clear?
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.
Current approach is ok, just talking about a perfect world. Making it private is more than good enough
LGTM in this state 👍 I'll look one last time tomorrow and will likely merge then.
The improvements are as follows:
compile-flags
directive intests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs
changelog: support replacements in
disallowed_methods