diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-04-10 14:33:59 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-04-17 09:50:52 +1000 |
| commit | 2fef0a30ae6b2687dfb286cb544d2a542f7e2335 (patch) | |
| tree | 9c17b4e3cf1885d0181a26d0bc24c3c6fb0e114d /src/tools/clippy | |
| parent | 7e1f2f9c54338cbefddffcce725f89d271d2cbe8 (diff) | |
| download | rust-2fef0a30ae6b2687dfb286cb544d2a542f7e2335.tar.gz rust-2fef0a30ae6b2687dfb286cb544d2a542f7e2335.zip | |
Replace infallible `name_or_empty` methods with fallible `name` methods.
I'm removing empty identifiers everywhere, because in practice they always mean "no identifier" rather than "empty identifier". (An empty identifier is impossible.) It's better to use `Option` to mean "no identifier" because you then can't forget about the "no identifier" possibility. Some specifics: - When testing an attribute for a single name, the commit uses the `has_name` method. - When testing an attribute for multiple names, the commit uses the new `has_any_name` method. - When using `match` on an attribute, the match arms now have `Some` on them. In the tests, we now avoid printing empty identifiers by not printing the identifier in the `error:` line at all, instead letting the carets point out the problem.
Diffstat (limited to 'src/tools/clippy')
| -rw-r--r-- | src/tools/clippy/clippy_utils/src/lib.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/tools/clippy/clippy_utils/src/lib.rs b/src/tools/clippy/clippy_utils/src/lib.rs index 9f450d654d5..f715fc86e4e 100644 --- a/src/tools/clippy/clippy_utils/src/lib.rs +++ b/src/tools/clippy/clippy_utils/src/lib.rs @@ -2363,14 +2363,14 @@ pub fn is_no_std_crate(cx: &LateContext<'_>) -> bool { cx.tcx .hir_attrs(hir::CRATE_HIR_ID) .iter() - .any(|attr| attr.name_or_empty() == sym::no_std) + .any(|attr| attr.has_name(sym::no_std)) } pub fn is_no_core_crate(cx: &LateContext<'_>) -> bool { cx.tcx .hir_attrs(hir::CRATE_HIR_ID) .iter() - .any(|attr| attr.name_or_empty() == sym::no_core) + .any(|attr| attr.has_name(sym::no_core)) } /// Check if parent of a hir node is a trait implementation block. |
