mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-27 13:33:26 +00:00
Update Unicode lint tests
This commit is contained in:
parent
72da1015d6
commit
92bd160aac
2 changed files with 9 additions and 9 deletions
|
@ -56,17 +56,17 @@ declare_clippy_lint! {
|
||||||
///
|
///
|
||||||
/// **Known problems** None.
|
/// **Known problems** None.
|
||||||
///
|
///
|
||||||
/// **Example:** You may not see it, but “à” and “à” aren't the same string. The
|
/// **Example:** You may not see it, but "à"" and "à"" aren't the same string. The
|
||||||
/// former when escaped is actually `"a\u{300}"` while the latter is `"\u{e0}"`.
|
/// former when escaped is actually `"a\u{300}"` while the latter is `"\u{e0}"`.
|
||||||
pub UNICODE_NOT_NFC,
|
pub UNICODE_NOT_NFC,
|
||||||
pedantic,
|
pedantic,
|
||||||
"using a unicode literal not in NFC normal form (see [unicode tr15](http://www.unicode.org/reports/tr15/) for further information)"
|
"using a Unicode literal not in NFC normal form (see [Unicode tr15](http://www.unicode.org/reports/tr15/) for further information)"
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_lint_pass!(Unicode => [ZERO_WIDTH_SPACE, NON_ASCII_LITERAL, UNICODE_NOT_NFC]);
|
declare_lint_pass!(Unicode => [ZERO_WIDTH_SPACE, NON_ASCII_LITERAL, UNICODE_NOT_NFC]);
|
||||||
|
|
||||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Unicode {
|
impl LateLintPass<'_, '_> for Unicode {
|
||||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
fn check_expr(&mut self, cx: &LateContext<'_, '_>, expr: &'_ Expr) {
|
||||||
if let ExprKind::Lit(ref lit) = expr.node {
|
if let ExprKind::Lit(ref lit) = expr.node {
|
||||||
if let LitKind::Str(_, _) = lit.node {
|
if let LitKind::Str(_, _) = lit.node {
|
||||||
check_str(cx, lit.span, expr.hir_id)
|
check_str(cx, lit.span, expr.hir_id)
|
||||||
|
@ -122,7 +122,7 @@ fn check_str(cx: &LateContext<'_, '_>, span: Span, id: HirId) {
|
||||||
cx,
|
cx,
|
||||||
UNICODE_NOT_NFC,
|
UNICODE_NOT_NFC,
|
||||||
span,
|
span,
|
||||||
"non-nfc unicode sequence detected",
|
"non-NFC Unicode sequence detected",
|
||||||
"consider replacing the string with",
|
"consider replacing the string with",
|
||||||
string.nfc().collect::<String>(),
|
string.nfc().collect::<String>(),
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
|
|
|
@ -2,15 +2,15 @@ error: zero-width space detected
|
||||||
--> $DIR/unicode.rs:3:12
|
--> $DIR/unicode.rs:3:12
|
||||||
|
|
|
|
||||||
LL | print!("Here >< is a ZWS, and another");
|
LL | print!("Here >< is a ZWS, and another");
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing the string with: `"Here >/u{200B}< is a ZWS, and /u{200B}another"`
|
||||||
|
|
|
|
||||||
= note: `-D clippy::zero-width-space` implied by `-D warnings`
|
= note: `-D clippy::zero-width-space` implied by `-D warnings`
|
||||||
|
|
||||||
error: non-nfc unicode sequence detected
|
error: non-NFC Unicode sequence detected
|
||||||
--> $DIR/unicode.rs:9:12
|
--> $DIR/unicode.rs:9:12
|
||||||
|
|
|
|
||||||
LL | print!("̀àh?");
|
LL | print!("̀àh?");
|
||||||
| ^^^^^
|
| ^^^^^ help: consider replacing the string with: `"̀àh?"`
|
||||||
|
|
|
|
||||||
= note: `-D clippy::unicode-not-nfc` implied by `-D warnings`
|
= note: `-D clippy::unicode-not-nfc` implied by `-D warnings`
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ error: literal non-ASCII character detected
|
||||||
--> $DIR/unicode.rs:15:12
|
--> $DIR/unicode.rs:15:12
|
||||||
|
|
|
|
||||||
LL | print!("Üben!");
|
LL | print!("Üben!");
|
||||||
| ^^^^^^^
|
| ^^^^^^^ help: consider replacing the string with: `"/u{dc}ben!"`
|
||||||
|
|
|
|
||||||
= note: `-D clippy::non-ascii-literal` implied by `-D warnings`
|
= note: `-D clippy::non-ascii-literal` implied by `-D warnings`
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue