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

Typedefs and ptr_arg lint #1981

Closed
stanislav-tkach opened this issue Aug 22, 2017 · 5 comments · Fixed by #8271
Closed

Typedefs and ptr_arg lint #1981

stanislav-tkach opened this issue Aug 22, 2017 · 5 comments · Fixed by #8271
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-middle Type: Probably requires verifiying types

Comments

@stanislav-tkach
Copy link
Contributor

I have the following situation:

type Value = Vec<u8>;

fn foo(_: &Value) {}

Typedef is used for clarity, but Clippy produces a warning:

warning: writing &Vec<_> instead of &[_] involves one more reference and cannot be used with non-Vec-based slices. Consider changing the type to &[...]

Probably this lint can be disabled for typedes?

@oli-obk
Copy link
Contributor

oli-obk commented Aug 22, 2017

Probably this lint can be disabled for typedefs?

hmm... I think it would be ok to disable the lint on typedefs if the function is not public. But if it's public, you're gonna limit your callers needlessly.

@stanislav-tkach
Copy link
Contributor Author

stanislav-tkach commented Aug 22, 2017

In my case both function and typedef isn't public. 😄

@oli-obk oli-obk added good-first-issue These issues are a good way to get started with Clippy C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages T-middle Type: Probably requires verifiying types labels Aug 22, 2017
@algesten
Copy link

My types are public but it's an internal library where I clarify what is what using type defs. However I won't ever need &str instead of &String. I'm not sure about this lint :/

@oli-obk oli-obk added E-medium Call for participation: Medium difficulty level problem and requires some initial experience. and removed good-first-issue These issues are a good way to get started with Clippy labels Aug 19, 2018
@oli-obk
Copy link
Contributor

oli-obk commented Aug 19, 2018

Maybe we should rewrite this lint as a PreExpansionPass and simply check for literal &String and &Vec<T> even if this causes false positives when someone creates their own types named String or Vec

@algesten
Copy link

That sounds like a great idea!

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-middle Type: Probably requires verifiying types
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants