feat: allow a linter to return multiple `Lint`s with different `span`s
Issues
Resolves #3329
Description
Before this an ExprLinter could return multiple Suggestions, but all on a single Lint, which is what you need most of the time.
Buy sometimes there's two ways to fix a mistake the modify different parts of the sentence not next to each.
So far the way to do this was to replace the whole section encompassing both, which could get a bit confusing and also leader to bigger code that took some effort to read. Now you can return a Lint for each place in the sentence that fixes just that localized spot, and another in the other place. Which should make the linter code easier to follow.
For now it only adds match_to_lints_with_context() but I might also add match_to_lints().
As before, an ExprLinter should choose exactly one of the three match_to_lint functions to implement. Implementing none of them or multiple of them will probably blow the stack.
If any Rust experts can think of a way to detect/avoid this at compile time or runtime, a fix would be welcome!
⚠️ NOTE: One difference that might be surprising in some way even though totally logic in another, is that assert_lint_count will probably now be able to return >1 for a single operation. This does not affect any current modules or test but might if an old linter is refactored to use the new method.
The semantic change would be that the number of lints would not be the number of mistakes identified but the number of places mistakes can be fixed. In #[test]s this probably doesn't matter. in UIs and stats it might.
How Has This Been Tested?
A test linter is included that fixes a pronoun and verb that don't agree by a pair of lints, each fixing one of the two words.
Checklist
- [x] I have performed a self-review of my own code
- [x] I have added tests to cover my changes
- [ ] I have considered splitting this into smaller pull requests.
@elijah-potter I don't think this one is ready to go in as-is but I'd like to hear your thoughts about the idea.