Skip to content
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

Check usages in ptr_arg #8271

Merged
merged 2 commits into from
Jan 21, 2022
Merged

Check usages in ptr_arg #8271

merged 2 commits into from
Jan 21, 2022

Conversation

Jarcho
Copy link
Contributor

@Jarcho Jarcho commented Jan 13, 2022

fixes #214
fixes #1981
fixes #3381
fixes #6406
fixes #6964

This does not take into account the return type of the function currently, so (&Vec<_>) -> &Vec<_> functions may still be false positives.

The name given for the type also has to match the real type name, so type Foo = Vec<u32> won't trigger the lint, but type Vec = Vec<u32> will. I'm not sure if this is the best way to handle this, or if a note about the actual type should be added instead.

changelog: Check if the argument is used in a way which requires the original type in ptr_arg
changelog: Lint mutable references in ptr_arg

* Track the argument when used to initialize simple `let` bindings
* Check if the argument is passed to a function requiring the original type
* Use `multipart_suggestion` rather than multiple suggestions
* Check if the name given in the source code matches the name of the actual type
@rust-highfive
Copy link

r? @flip1995

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 13, 2022
Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. I left some minor comments.

tests/ui/ptr_arg.rs Outdated Show resolved Hide resolved
clippy_lints/src/ptr.rs Outdated Show resolved Hide resolved
clippy_lints/src/ptr.rs Outdated Show resolved Hide resolved
clippy_lints/src/ptr.rs Outdated Show resolved Hide resolved
@flip1995 flip1995 added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Jan 20, 2022
@flip1995
Copy link
Member

@bors r+

Thanks!

@bors
Copy link
Collaborator

bors commented Jan 21, 2022

📌 Commit 048297b has been approved by flip1995

@bors
Copy link
Collaborator

bors commented Jan 21, 2022

⌛ Testing commit 048297b with merge 4992548...

@bors
Copy link
Collaborator

bors commented Jan 21, 2022

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: flip1995
Pushing 4992548 to master...

@bors bors merged commit 4992548 into rust-lang:master Jan 21, 2022
hhirtz added a commit to LIHPC-Computational-Geometry/coupe that referenced this pull request Apr 8, 2022
Update to Rust 1.60 extended clippy::ptr_arg somehow and now this
triggers a false positive.

See rust-lang/rust-clippy#8482

maybe relevant PR: rust-lang/rust-clippy#8271
hhirtz added a commit to LIHPC-Computational-Geometry/coupe that referenced this pull request Apr 8, 2022
Update to Rust 1.60 extended clippy::ptr_arg somehow and now this
triggers a false positive.

See rust-lang/rust-clippy#8482

maybe relevant PR: rust-lang/rust-clippy#8271
superatomic added a commit to superatomic/xshe that referenced this pull request Apr 28, 2022
Move shell script conversion to a separate file, `convert.rs`.
They were previously in `main.rs`. Additionally, implement unsetting
environment variables as described in #31.
Note: until rust-lang/rust-clippy#8271 is added
to Rust in 1.61, `#![allow(clippy::ptr_arg)]` has been added to the top
of the file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status)
Projects
None yet
4 participants