Auto merge of #9327 - Serial-ATA:non_ascii_literal_macro, r=Alexendoo
Fix [`non_ascii_literal`] in tests changelog: Don't lint [`non_ascii_literal`] when using non-ascii comments in tests changelog: Don't lint [`non_ascii_literal`] when `allow`ed on tests closes: #7739 closes: #8263
This commit is contained in:
commit
f4f5bb4328
4 changed files with 110 additions and 39 deletions
|
|
@ -1,5 +1,6 @@
|
|||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||
use clippy_utils::is_lint_allowed;
|
||||
use clippy_utils::macros::span_is_local;
|
||||
use clippy_utils::source::snippet;
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_errors::Applicability;
|
||||
|
|
@ -98,6 +99,10 @@ fn escape<T: Iterator<Item = char>>(s: T) -> String {
|
|||
}
|
||||
|
||||
fn check_str(cx: &LateContext<'_>, span: Span, id: HirId) {
|
||||
if !span_is_local(span) {
|
||||
return;
|
||||
}
|
||||
|
||||
let string = snippet(cx, span, "");
|
||||
if string.chars().any(|c| ['\u{200B}', '\u{ad}', '\u{2060}'].contains(&c)) {
|
||||
span_lint_and_sugg(
|
||||
|
|
@ -113,6 +118,7 @@ fn check_str(cx: &LateContext<'_>, span: Span, id: HirId) {
|
|||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
|
||||
if string.chars().any(|c| c as u32 > 0x7F) {
|
||||
span_lint_and_sugg(
|
||||
cx,
|
||||
|
|
@ -128,6 +134,7 @@ fn check_str(cx: &LateContext<'_>, span: Span, id: HirId) {
|
|||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
|
||||
if is_lint_allowed(cx, NON_ASCII_LITERAL, id) && string.chars().zip(string.nfc()).any(|(a, b)| a != b) {
|
||||
span_lint_and_sugg(
|
||||
cx,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue