Since I was the original reviewer of the PR, I also want to comment on this. I read through the whole thread and hope that I don't forget anything. I want to address these things:
- Clippy is not the tool to reverse rustc features
- The
pattern_type_mismatch
lint and why I agreed to allow it in Clippy
- The
restriction
group (briefly)
Clippy is not the tool to reverse rustc features
I completely agree with @Manishearth here. Clippy is not a tool you should (ab)use to implement a lint, reversing a feature, just because you don't like it. I myself also closed some Issues exactly for this reason already. Rust has the RFC process and once a feature made it through the RFC process, the majority agreed that it is a good feature people should have.
I personally think this is definitely a good feature, because it makes the language easier to write for beginners and therefore lowers the level of entry. Pretty much the first reason @skade brought up.
The pattern_type_mismatch
lint
If I agree that Clippy isn't a tool for doing such things, why did I allow this lint to get into Clippy then?
I didn't see this lint as "it should disable this feature" but rather as a lint that can help teaching what actually happens when writing a match
expression. And the lint in its current state does this really well IMO.
From the start it was clear that this lint should go into the restriction
group and is not meant for broader use. You can enable it, if you want to teach someone about the intricacies of pattern matching in Rust. Or, if for some reason, your codebase has a correctness reason, why you cannot use default binding modes. I doubt that this happens often though.
@phaylon put much work into the suggestions and the documentation to explain on a beginner level, how bindings work and what should be added to always adhere to the underlying type. This is also something I put a really high bar on, since I would definitely have disagreed with adding a lint that just says "this uses default binding mode!".
That being said, if you want to enable this lint in your codebase, I can't stop you from doing so. But I also won't help you explain newcomers, why they aren't allowed to use a convenience feature in your codebase.
The restriction
group
I don't want to go into details here and open a big discussion about Clippy lint groups. We want to write a Clippy book this year, where we can discuss the definitions of groups in more detail (internally and with the community)
I just want to rehash what @Manishearth already said about the restriction
group with my own understanding and my own words. This is not a group where you can just open a PR with any lint that you care about and it will get automatically merged, because "it's just restriction
".
The restriction
group is for lints, that only apply in really specialized codebases with a specific goal in mind. And as the group name says, they will "restrict" the language in a way, that does not make sense for almost all codebases. Otherwise it would be pedantic
or even in one of the warn-by-default
groups.
As for this lint: if you do a workshop on Rust and want to make an example crate about the intricacies of pattern matching, using this lint might help you. In any other case, don't use this lint.
(Clippy has a lint, that warns-by-default if you write #[warn(clippy::restriction)]
)