-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Implement a lint for implicit autoref of raw pointer dereference - take 2 #123239
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
The Miri subtree was changed cc @rust-lang/miri |
Sorry, I can't take on more reviews currently. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bb6ab41
to
2b3fe45
Compare
This comment was marked as outdated.
This comment was marked as outdated.
2b3fe45
to
57f6416
Compare
This comment has been minimized.
This comment has been minimized.
57f6416
to
824c1f5
Compare
This comment was marked as outdated.
This comment was marked as outdated.
824c1f5
to
c2d6e62
Compare
This comment was marked as outdated.
This comment was marked as outdated.
@Urgau if you can rebase the latest conflicts we can push this forward and maybe get it reviewed by another reviewer |
c2d6e62
to
78288af
Compare
@Dylan-DPC rebased. @rustbot review |
78288af
to
d060615
Compare
This comment has been minimized.
This comment has been minimized.
…=jdonszelmann,traviscross Implement a lint for implicit autoref of raw pointer dereference - take 2 *[t-lang nomination comment](rust-lang#123239 (comment) This PR aims at implementing a lint for implicit autoref of raw pointer dereference, it is based on rust-lang#103735 with suggestion and improvements from rust-lang#103735 (comment). The goal is to catch cases like this, where the user probably doesn't realise it just created a reference. ```rust pub struct Test { data: [u8], } pub fn test_len(t: *const Test) -> usize { unsafe { (*t).data.len() } // this calls <[T]>::len(&self) } ``` Since rust-lang#103735 already went 2 times through T-lang, where they T-lang ended-up asking for a more restricted version (which is what this PR does), I would prefer this PR to be reviewed first before re-nominating it for T-lang. ---- Compared to the PR it is as based on, this PR adds 3 restrictions on the outer most expression, which must either be: 1. A deref followed by any non-deref place projection (that intermediate deref will typically be auto-inserted) 2. A method call annotated with `#[rustc_no_implicit_refs]`. 3. A deref followed by a `addr_of!` or `addr_of_mut!`. See bottom of post for details. There are several points that are not 100% clear to me when implementing the modifications: - ~~"4. Any number of automatically inserted deref/derefmut calls." I as never able to trigger this. Am I missing something?~~ Fixed - Are "index" and "field" enough? ---- cc `@JakobDegen` `@WaffleLapkin` r? `@RalfJung` try-job: dist-various-1 try-job: dist-various-2
The job Click to see the possible cause of the failure (guessed by this bot)
|
💔 Test failed - checks-actions |
CI error is unrelated to this PR. Seems spurious. @bors retry |
⌛ Testing commit 05f2b22 with merge af9aa86f909dbc0990a114148a12f36a9ff4828f... |
…=jdonszelmann,traviscross Implement a lint for implicit autoref of raw pointer dereference - take 2 *[t-lang nomination comment](rust-lang#123239 (comment) This PR aims at implementing a lint for implicit autoref of raw pointer dereference, it is based on rust-lang#103735 with suggestion and improvements from rust-lang#103735 (comment). The goal is to catch cases like this, where the user probably doesn't realise it just created a reference. ```rust pub struct Test { data: [u8], } pub fn test_len(t: *const Test) -> usize { unsafe { (*t).data.len() } // this calls <[T]>::len(&self) } ``` Since rust-lang#103735 already went 2 times through T-lang, where they T-lang ended-up asking for a more restricted version (which is what this PR does), I would prefer this PR to be reviewed first before re-nominating it for T-lang. ---- Compared to the PR it is as based on, this PR adds 3 restrictions on the outer most expression, which must either be: 1. A deref followed by any non-deref place projection (that intermediate deref will typically be auto-inserted) 2. A method call annotated with `#[rustc_no_implicit_refs]`. 3. A deref followed by a `addr_of!` or `addr_of_mut!`. See bottom of post for details. There are several points that are not 100% clear to me when implementing the modifications: - ~~"4. Any number of automatically inserted deref/derefmut calls." I as never able to trigger this. Am I missing something?~~ Fixed - Are "index" and "field" enough? ---- cc `@JakobDegen` `@WaffleLapkin` r? `@RalfJung` try-job: dist-various-1 try-job: dist-various-2
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
@bors retry |
☀️ Test successful - checks-actions |
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 0134651 (parent) -> a932eb3 (this PR) Test differencesShow 1165 test diffsStage 1
Stage 2
Additionally, 1163 doctest diffs were found. These are ignored, as they are noisy. Job group index
Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard a932eb36f8adf6c8cdfc450f063943da3112d621 --output-dir test-dashboard And then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
t-lang nomination comment
This PR aims at implementing a lint for implicit autoref of raw pointer dereference, it is based on #103735 with suggestion and improvements from #103735 (comment).
The goal is to catch cases like this, where the user probably doesn't realise it just created a reference.
Since #103735 already went 2 times through T-lang, where they T-lang ended-up asking for a more restricted version (which is what this PR does), I would prefer this PR to be reviewed first before re-nominating it for T-lang.
Compared to the PR it is as based on, this PR adds 3 restrictions on the outer most expression, which must either be:
#[rustc_no_implicit_refs]
.addr_of!
oraddr_of_mut!
. See bottom of post for details.There are several points that are not 100% clear to me when implementing the modifications:
"4. Any number of automatically inserted deref/derefmut calls." I as never able to trigger this. Am I missing something?Fixedcc @JakobDegen @WaffleLapkin
r? @RalfJung
try-job: dist-various-1
try-job: dist-various-2