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

Add a lint for lets/matches which won't do anything #11122

Conversation

glaebhoerl
Copy link
Contributor

in other words irrefutable ones without any bindings. This will be useful once the semantics of _ in patterns changes to "ignore" instead of "drop" (#10488). Closes #11088.

For now it defaults to "allow", so I don't think there's any harm in this going in before #10488 itself, but please DON'T r+ this unless you're in a position to decide (or it has been decided).

If I run the tests with it set to "deny", things break in all of the expected places, with the exception that deriving code for unit structs also appears to trigger it. That should presumably be fixed before it gets changed to something other than "allow" (along with of course the expected failures).

…lly do anything (irrefutable, no bindings).

Will be useful once the semantics of _ in patterns changes to "ignore" instead of "drop" (rust-lang#10488).

Closes rust-lang#11088.
@huonw
Copy link
Member

huonw commented Dec 23, 2013

(Changing the deriving code to not generate a "useless" match will be annoying and not an improvement (no particular need for that special case), so the best way to handle that will be putting an #[allow] attribute on the generated impl or methods. Grepping for cx.attribute or cx.meta in syntax::ext::deriving::generic should find an appropriate spot, iirc.)

@glaebhoerl
Copy link
Contributor Author

(Yeah I figured it would be something like that. Thanks.)

@glaebhoerl glaebhoerl closed this Dec 23, 2013
@glaebhoerl glaebhoerl reopened this Dec 23, 2013
@glaebhoerl
Copy link
Contributor Author

(Gah, apparently "Close" doesn't mean the comment box.)

@alexcrichton
Copy link
Member

Closing due to inactivity. This probably needs to get rebased around #11585, but I'm not sure how they interact with one another.

flip1995 pushed a commit to flip1995/rust that referenced this pull request Jul 14, 2023
…lip1995

Pass correct substs to `implements_trait` in `incorrect_impls`

`Copy<T>` does in fact not exist. The substs on the trait_ref contain the `Self` type of the impl as the first parameter, so passing that to `implements_trait`, which then nicely prepends the `Self` type for us does not end will.

fixes  rust-lang#11121

The assertions requires debug assertions inside rustc, which is probably why it didn't fire here. I tested the change locally in rust-lang/rust and it did not ICE anymore.

cc `@xFrednet` `@Centri3`

changelog: [`incorrect_impls`]: fix confusion about generic parameters
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.

Lint for superfluous let/match
3 participants