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

lint get vs index dissonance #1314

Open
oli-obk opened this issue Nov 1, 2016 · 4 comments
Open

lint get vs index dissonance #1314

oli-obk opened this issue Nov 1, 2016 · 4 comments
Labels
A-lint Area: New lints E-hard Call for participation: This a hard problem and requires more experience or effort to work on L-correctness Lint: Belongs in the correctness lint group L-style Lint: Belongs in the style lint group T-middle Type: Probably requires verifiying types

Comments

@oli-obk
Copy link
Contributor

oli-obk commented Nov 1, 2016

for custom types we aren't sure that .get().unwrap() and [] are actually equivalent. They probably should be, so let's lint them.

Idea by @devonhollowood in https://github.com/Manishearth/rust-clippy/pull/1312#issuecomment-257664178

@oli-obk oli-obk added E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-middle Type: Probably requires verifiying types A-lint Area: New lints L-style Lint: Belongs in the style lint group L-correctness Lint: Belongs in the correctness lint group labels Nov 1, 2016
@mcarton
Copy link
Member

mcarton commented Nov 2, 2016

Oo how do you check that?
We're far from being able to prove code equivalence.

@mcarton mcarton added E-hard Call for participation: This a hard problem and requires more experience or effort to work on and removed E-medium Call for participation: Medium difficulty level problem and requires some initial experience. labels Nov 2, 2016
@oli-obk
Copy link
Contributor Author

oli-obk commented Nov 2, 2016

well... one of them should probably forward to the other? xD

we can also compare fully inlined MIR or something

@mcarton
Copy link
Member

mcarton commented Nov 2, 2016

It's not the case for example for Vec. Also for Vec, Index is also implemented on ranges, but get only works on indexes.

@oli-obk
Copy link
Contributor Author

oli-obk commented Nov 2, 2016

Well... dissonance requires that both exist. So we'd only check those cases where the Index<T, Output=U> and the get(T) -> Option<U> exist as a pair.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints E-hard Call for participation: This a hard problem and requires more experience or effort to work on L-correctness Lint: Belongs in the correctness lint group L-style Lint: Belongs in the style lint group T-middle Type: Probably requires verifiying types
Projects
None yet
Development

No branches or pull requests

2 participants