Skip to content

Conversation

nweston
Copy link
Contributor

@nweston nweston commented Nov 3, 2015

Fixes #11.

I have one question about this: I'm matching an expression like x.iter().zip(0..x.len()) and I need to check that .iter() and .len() are called on the same thing. Right now I compare the snippet() of the two expressions but that seems kludgey. Is there a better way to check that two expressions are equivalent?

@Manishearth
Copy link
Member

"x" will be an ExprPath with a single element.

@nweston
Copy link
Contributor Author

nweston commented Nov 3, 2015

In this example, sure. But in practice it could be something more complicated (a method call that returns a vector, for example). Unless we want the lint to ignore anything that isn't an ExprPath.

@Manishearth
Copy link
Member

The method call could return a different vector each time. So yeah, simple variable access only 😄

@llogiq
Copy link
Contributor

llogiq commented Nov 3, 2015

Yeah, perhaps we could allow simple blocks, like {x}, but I wouldn't do anything more complex.

@nweston
Copy link
Contributor Author

nweston commented Nov 3, 2015

OK, I changed it to expect ExprPath in both places and compare those.

llogiq added a commit that referenced this pull request Nov 3, 2015
New lint for zip with array length instead of enumerate()
@llogiq llogiq merged commit 4b14096 into rust-lang:master Nov 3, 2015
@llogiq
Copy link
Contributor

llogiq commented Nov 3, 2015

Thanks for the PR! I just added a wiki entry, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants