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

Consequences of ptr_arg #846

Open
2 tasks
llogiq opened this issue Apr 9, 2016 · 2 comments
Open
2 tasks

Consequences of ptr_arg #846

llogiq opened this issue Apr 9, 2016 · 2 comments
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-AST Type: Requires working with the AST

Comments

@llogiq
Copy link
Contributor

llogiq commented Apr 9, 2016

Currently, following ptr_arg can lead to errors, if

  • the function is used as a Fn reference (fn foo(&Vec<u8>) { .. }; let foo : Fn(&Vec<u8>) = foo)
  • the function calls another function that expects a &Vec reference.

We could extend the lint to

  • check the whole crate if the function is referenced anywhere (we obviously cannot check across crate boundaries, but I guess, that'll be OK.
  • look into the function and check the signatures of the contained calls; if those are only functions within the crate, note if those are eligible for ptr_arg, otherwise don't lint. We should also bail on out-of-crate functions.
@llogiq llogiq added E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-AST Type: Requires working with the AST C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages labels Apr 9, 2016
@nitnelave
Copy link

+1, when a function takes a &str::string::String, it recommends changing to &str, but if the function is used in a map() of &str::string::String, the call fails.

@juliusl
Copy link

juliusl commented Jun 19, 2024

+1, when a crate defines a trait and implements it for Vec<>, changing &Vec<> -> &[_] would end up leading to a complier error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-AST Type: Requires working with the AST
Projects
None yet
Development

No branches or pull requests

3 participants