about summary refs log tree commit diff
path: root/compiler/rustc_pattern_analysis/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-02-25 22:02:55 +0000
committerbors <bors@rust-lang.org>2024-02-25 22:02:55 +0000
commit7353bd0341443769986b1b8c9167ace68ecdec8a (patch)
treea69230044ba505d8f3e565ed5f317c08f58e5ca7 /compiler/rustc_pattern_analysis/src
parent10c99031cee17b342fd92a51ab1cc6f96f27bb7b (diff)
parent9a56153c5ee0624c09cce2aaf6757407e17a1264 (diff)
downloadrust-7353bd0341443769986b1b8c9167ace68ecdec8a.tar.gz
rust-7353bd0341443769986b1b8c9167ace68ecdec8a.zip
Auto merge of #12256 - y21:single_call_fn_rm_visitor, r=llogiq
Merge `single_call_fn` post-crate visitor into lint pass

The `single_call_fn` lint worked by first collecting a list of function definitions in the lint pass, then populating the list of uses for each function in a second visitor after the crate is checked.
Doing another pass through the crate shouldn't be needed, and we should be able to do it in the same lint pass, by looking for path references to functions only and then processing them post-crate.

Other changes:
- `FxHashMap` -> `FxIndexMap` so that we emit warnings in a consistent order, as we see them (making the diff a bit confusing to look at, because warnings were moved around)
- no longer storing a `Vec<Span>` per function: an enum representing "seen once" or "seen more than once" should be enough (only the first element is used later)
- "used here" help is now a note

I also noticed that it lints on trait methods with a default implementation, but not on regular trait methods without a body (because that's what `check_fn` does). I'm not sure if that's useful though, maybe we shouldn't lint trait methods at all? It's not like you can avoid it sometimes (but then again it's a restriction lint). Either way, I left the behavior where it was before so that there are no functional changes made in this PR and it's purely a refactor. I can change it though

changelog: none
Diffstat (limited to 'compiler/rustc_pattern_analysis/src')
0 files changed, 0 insertions, 0 deletions