diff options
| author | Jason Newcomb <jsnewcomb@pm.me> | 2025-05-05 21:46:40 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-05 21:46:40 +0000 |
| commit | c1586e141fcba29135cbb96929250dea933812d0 (patch) | |
| tree | d5db182c128a4945677cbc6d7643c537d00ddf2e /compiler/rustc_codegen_gcc | |
| parent | f62f26965817f2573c2649288faa489a03ed1665 (diff) | |
| parent | f23772ce8cbfe78010fdb27da9dedcdf35180e9f (diff) | |
| download | rust-c1586e141fcba29135cbb96929250dea933812d0.tar.gz rust-c1586e141fcba29135cbb96929250dea933812d0.zip | |
Replace str path utils with new `PathLookup` type (#14705)
The `&[&str]` path based `clippy_utils` have been removed and replace
with a new type `PathLookup`:
-
[`match_trait_method`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.match_trait_method.html)
-
[`match_qpath`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.match_qpath.html)
-
[`match_path`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.match_path.html)
-
[`match_any_def_paths`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.match_any_def_paths.html)
-
[`match_def_path`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.match_def_path.html)
-
[`match_type`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/ty/fn.match_type.html)
-
[`get_trait_def_id`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.get_trait_def_id.html)
Internally `PathLookup` is a lazy call to `lookup_path` (the new name
for
[`def_path_res`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.def_path_res.html)
to distinguish it from
[`path_res`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.path_res.html))
The `invalid_paths` internal lint is removed, it could be reimplemented
but it feels redundant since every path should be covered by a test
anyway
### User facing changes
- `manual_saturating_arithmetic` now checks for `u32::MAX/MIN` instead
of only detecting the legacy numeric consts (`std::u32::MAX/MIN`),
`clippy::legacy_numeric_constants` will redirect usages of the legacy
versions to the new one
- `allow-invalid = true` now suppresses all invalid path warnings,
currently you can run into a warning that can't be ignored in some
situations, e.g. with `serde` without the `derive` feature
```
warning: expected a macro, found a trait
--> /home/gh-Alexendoo/temp/clippy.toml:2:5
|
2 | { path = "serde::Serialize", allow-invalid = true },
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
- Re-exports of primitives types like `std::primitive::*` no longer work
in `disallowed-types`, this seems acceptable since it would be unusual
to deny a primitive this way rather than writing e.g. `usize`. Type
aliases such as `c_char` are unaffected
- A similar slight performance improvement to
https://github.com/rust-lang/rust-clippy/pull/14650
```bash
$ hyperfine -w 2 -p 'touch src/cargo/lib.rs' 'cargo +master clippy'
'cargo +lazy-paths clippy'
```
```
Benchmark 1: cargo +master clippy
Time (mean ± σ): 6.829 s ± 0.064 s [User: 6.079 s, System: 0.673 s]
Range (min … max): 6.705 s … 6.907 s 10 runs
Benchmark 2: cargo +lazy-paths clippy
Time (mean ± σ): 6.765 s ± 0.064 s [User: 5.984 s, System: 0.698 s]
Range (min … max): 6.636 s … 6.834 s 10 runs
Summary
cargo +lazy-paths clippy ran
1.01 ± 0.01 times faster than cargo +master clippy
```
changelog: none
Diffstat (limited to 'compiler/rustc_codegen_gcc')
0 files changed, 0 insertions, 0 deletions
