-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Clean up transmute lints' documentation #15710
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
Open
felix91gr
wants to merge
1
commit into
rust-lang:master
Choose a base branch
from
felix91gr:transmute-ptr-to-ref
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
The lint still doesn't take into account whether it's in a constant context. It would also need an MSRV check to fix this issue.
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.
Wait, I'm not sure I understand 100%.
If it doesn't check whether it's in a const context or not, but now it works properly in a const context, then this problem is effectively fixed, no?
I'm guessing this is what you mean about the MSRV, perhaps.
Though OTOH maybe the documentation could mention that "for rust versions prior to X release, this lint will have [this known issue] due to the fact that dereferencing raw pointers wasn't stable before then.". Would that be appropriate?
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.
Yes. It only works correctly if the MSRV is high enough to include const raw pointer dereferences.
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.
Ping @felix91gr. Just waiting on this.
*constpointers can be dereferenced as of1.58,*mutas of1.83.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.
@Jarcho ty for the ping. I got taken away for a bit. Where do I specify this? I think I've never have added a MSRV in Clippy before.
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.
For documenting it just keep it in the "known problems" section.
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.
@Jarcho so then, if I got you correctly, the only change needed to correct this is of documentation, right? I thought you meant that a MSRV config should be added to differentiate between all the cases.
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.
Either would be an acceptable PR. Actually adding the code to handle the MSRV would be the better fix.
If you want a to actually fix the issue you'll need to add the msrv to
clippy_utils/src/msrvs.rs. These are named by feature so you'll add something likeCONST_RAW_CONST_PTR_DEREFandCONST_RAW_MUT_PTR_DEREF. You can useis_in_const_contextto check for constness.Everything else is already done since the lint has an MSRV check for the suggestion.