Skip to content

Commit 097c9c7

Browse files
committed
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.
1 parent 4784074 commit 097c9c7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clippy_utils/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2363,14 +2363,14 @@ pub fn is_no_std_crate(cx: &LateContext<'_>) -> bool {
23632363
cx.tcx
23642364
.hir_attrs(hir::CRATE_HIR_ID)
23652365
.iter()
2366-
.any(|attr| attr.name_or_empty() == sym::no_std)
2366+
.any(|attr| attr.has_name(sym::no_std))
23672367
}
23682368

23692369
pub fn is_no_core_crate(cx: &LateContext<'_>) -> bool {
23702370
cx.tcx
23712371
.hir_attrs(hir::CRATE_HIR_ID)
23722372
.iter()
2373-
.any(|attr| attr.name_or_empty() == sym::no_core)
2373+
.any(|attr| attr.has_name(sym::no_core))
23742374
}
23752375

23762376
/// Check if parent of a hir node is a trait implementation block.

0 commit comments

Comments
 (0)