Rename lint to invisible_characters
This commit is contained in:
parent
45f25f82fe
commit
998bd3b6b4
@ -1647,6 +1647,7 @@ Released 2018-09-13
|
|||||||
[`invalid_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_ref
|
[`invalid_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_ref
|
||||||
[`invalid_regex`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_regex
|
[`invalid_regex`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_regex
|
||||||
[`invalid_upcast_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_upcast_comparisons
|
[`invalid_upcast_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_upcast_comparisons
|
||||||
|
[`invisible_characters`]: https://rust-lang.github.io/rust-clippy/master/index.html#invisible_characters
|
||||||
[`items_after_statements`]: https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements
|
[`items_after_statements`]: https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements
|
||||||
[`iter_cloned_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_cloned_collect
|
[`iter_cloned_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_cloned_collect
|
||||||
[`iter_next_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_next_loop
|
[`iter_next_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_next_loop
|
||||||
@ -1922,6 +1923,5 @@ Released 2018-09-13
|
|||||||
[`zero_divided_by_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#zero_divided_by_zero
|
[`zero_divided_by_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#zero_divided_by_zero
|
||||||
[`zero_prefixed_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#zero_prefixed_literal
|
[`zero_prefixed_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#zero_prefixed_literal
|
||||||
[`zero_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#zero_ptr
|
[`zero_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#zero_ptr
|
||||||
[`zero_width_space`]: https://rust-lang.github.io/rust-clippy/master/index.html#zero_width_space
|
|
||||||
[`zst_offset`]: https://rust-lang.github.io/rust-clippy/master/index.html#zst_offset
|
[`zst_offset`]: https://rust-lang.github.io/rust-clippy/master/index.html#zst_offset
|
||||||
<!-- end autogenerated links to lint list -->
|
<!-- end autogenerated links to lint list -->
|
||||||
|
@ -854,9 +854,9 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
|
|||||||
&types::UNIT_CMP,
|
&types::UNIT_CMP,
|
||||||
&types::UNNECESSARY_CAST,
|
&types::UNNECESSARY_CAST,
|
||||||
&types::VEC_BOX,
|
&types::VEC_BOX,
|
||||||
|
&unicode::INVISIBLE_CHARACTERS,
|
||||||
&unicode::NON_ASCII_LITERAL,
|
&unicode::NON_ASCII_LITERAL,
|
||||||
&unicode::UNICODE_NOT_NFC,
|
&unicode::UNICODE_NOT_NFC,
|
||||||
&unicode::ZERO_WIDTH_SPACE,
|
|
||||||
&unit_return_expecting_ord::UNIT_RETURN_EXPECTING_ORD,
|
&unit_return_expecting_ord::UNIT_RETURN_EXPECTING_ORD,
|
||||||
&unnamed_address::FN_ADDRESS_COMPARISONS,
|
&unnamed_address::FN_ADDRESS_COMPARISONS,
|
||||||
&unnamed_address::VTABLE_ADDRESS_COMPARISONS,
|
&unnamed_address::VTABLE_ADDRESS_COMPARISONS,
|
||||||
@ -1511,7 +1511,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
|
|||||||
LintId::of(&types::UNIT_CMP),
|
LintId::of(&types::UNIT_CMP),
|
||||||
LintId::of(&types::UNNECESSARY_CAST),
|
LintId::of(&types::UNNECESSARY_CAST),
|
||||||
LintId::of(&types::VEC_BOX),
|
LintId::of(&types::VEC_BOX),
|
||||||
LintId::of(&unicode::ZERO_WIDTH_SPACE),
|
LintId::of(&unicode::INVISIBLE_CHARACTERS),
|
||||||
LintId::of(&unit_return_expecting_ord::UNIT_RETURN_EXPECTING_ORD),
|
LintId::of(&unit_return_expecting_ord::UNIT_RETURN_EXPECTING_ORD),
|
||||||
LintId::of(&unnamed_address::FN_ADDRESS_COMPARISONS),
|
LintId::of(&unnamed_address::FN_ADDRESS_COMPARISONS),
|
||||||
LintId::of(&unnamed_address::VTABLE_ADDRESS_COMPARISONS),
|
LintId::of(&unnamed_address::VTABLE_ADDRESS_COMPARISONS),
|
||||||
@ -1779,7 +1779,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
|
|||||||
LintId::of(&types::ABSURD_EXTREME_COMPARISONS),
|
LintId::of(&types::ABSURD_EXTREME_COMPARISONS),
|
||||||
LintId::of(&types::CAST_REF_TO_MUT),
|
LintId::of(&types::CAST_REF_TO_MUT),
|
||||||
LintId::of(&types::UNIT_CMP),
|
LintId::of(&types::UNIT_CMP),
|
||||||
LintId::of(&unicode::ZERO_WIDTH_SPACE),
|
LintId::of(&unicode::INVISIBLE_CHARACTERS),
|
||||||
LintId::of(&unit_return_expecting_ord::UNIT_RETURN_EXPECTING_ORD),
|
LintId::of(&unit_return_expecting_ord::UNIT_RETURN_EXPECTING_ORD),
|
||||||
LintId::of(&unnamed_address::FN_ADDRESS_COMPARISONS),
|
LintId::of(&unnamed_address::FN_ADDRESS_COMPARISONS),
|
||||||
LintId::of(&unnamed_address::VTABLE_ADDRESS_COMPARISONS),
|
LintId::of(&unnamed_address::VTABLE_ADDRESS_COMPARISONS),
|
||||||
@ -1910,6 +1910,7 @@ pub fn register_renamed(ls: &mut rustc_lint::LintStore) {
|
|||||||
ls.register_renamed("clippy::for_loop_over_option", "clippy::for_loops_over_fallibles");
|
ls.register_renamed("clippy::for_loop_over_option", "clippy::for_loops_over_fallibles");
|
||||||
ls.register_renamed("clippy::for_loop_over_result", "clippy::for_loops_over_fallibles");
|
ls.register_renamed("clippy::for_loop_over_result", "clippy::for_loops_over_fallibles");
|
||||||
ls.register_renamed("clippy::identity_conversion", "clippy::useless_conversion");
|
ls.register_renamed("clippy::identity_conversion", "clippy::useless_conversion");
|
||||||
|
ls.register_renamed("clippy::zero_width_space", "clippy::invisible_characters");
|
||||||
}
|
}
|
||||||
|
|
||||||
// only exists to let the dogfood integration test works.
|
// only exists to let the dogfood integration test works.
|
||||||
|
@ -17,7 +17,7 @@ declare_clippy_lint! {
|
|||||||
///
|
///
|
||||||
/// **Example:** You don't see it, but there may be a zero-width space or soft hyphen
|
/// **Example:** You don't see it, but there may be a zero-width space or soft hyphen
|
||||||
/// somewhere in this text.
|
/// somewhere in this text.
|
||||||
pub ZERO_WIDTH_SPACE,
|
pub INVISIBLE_CHARACTERS,
|
||||||
correctness,
|
correctness,
|
||||||
"using an invisible character in a string literal, which is confusing"
|
"using an invisible character in a string literal, which is confusing"
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ declare_clippy_lint! {
|
|||||||
"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 => [INVISIBLE_CHARACTERS, NON_ASCII_LITERAL, UNICODE_NOT_NFC]);
|
||||||
|
|
||||||
impl LateLintPass<'_> for Unicode {
|
impl LateLintPass<'_> for Unicode {
|
||||||
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &'_ Expr<'_>) {
|
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &'_ Expr<'_>) {
|
||||||
@ -91,12 +91,12 @@ fn escape<T: Iterator<Item = char>>(s: T) -> String {
|
|||||||
|
|
||||||
fn check_str(cx: &LateContext<'_>, span: Span, id: HirId) {
|
fn check_str(cx: &LateContext<'_>, span: Span, id: HirId) {
|
||||||
let string = snippet(cx, span, "");
|
let string = snippet(cx, span, "");
|
||||||
if let Some(invisible) = string.chars().find(|c| ['\u{200B}', '\u{ad}'].contains(&c)) {
|
if string.chars().any(|c| ['\u{200B}', '\u{ad}'].contains(&c)) {
|
||||||
span_lint_and_sugg(
|
span_lint_and_sugg(
|
||||||
cx,
|
cx,
|
||||||
ZERO_WIDTH_SPACE,
|
INVISIBLE_CHARACTERS,
|
||||||
span,
|
span,
|
||||||
&format!("invisible character detected: {:?}", invisible),
|
"invisible character detected",
|
||||||
"consider replacing the string with",
|
"consider replacing the string with",
|
||||||
string.replace("\u{200B}", "\\u{200B}").replace("\u{ad}", "\\u{AD}"),
|
string.replace("\u{200B}", "\\u{200B}").replace("\u{ad}", "\\u{AD}"),
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
|
@ -969,6 +969,13 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
|
|||||||
deprecation: None,
|
deprecation: None,
|
||||||
module: "types",
|
module: "types",
|
||||||
},
|
},
|
||||||
|
Lint {
|
||||||
|
name: "invisible_characters",
|
||||||
|
group: "correctness",
|
||||||
|
desc: "using an invisible character in a string literal, which is confusing",
|
||||||
|
deprecation: None,
|
||||||
|
module: "unicode",
|
||||||
|
},
|
||||||
Lint {
|
Lint {
|
||||||
name: "items_after_statements",
|
name: "items_after_statements",
|
||||||
group: "pedantic",
|
group: "pedantic",
|
||||||
@ -2810,13 +2817,6 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
|
|||||||
deprecation: None,
|
deprecation: None,
|
||||||
module: "misc",
|
module: "misc",
|
||||||
},
|
},
|
||||||
Lint {
|
|
||||||
name: "zero_width_space",
|
|
||||||
group: "correctness",
|
|
||||||
desc: "using an invisible character in a string literal, which is confusing",
|
|
||||||
deprecation: None,
|
|
||||||
module: "unicode",
|
|
||||||
},
|
|
||||||
Lint {
|
Lint {
|
||||||
name: "zst_offset",
|
name: "zst_offset",
|
||||||
group: "correctness",
|
group: "correctness",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#[warn(clippy::zero_width_space)]
|
#[warn(clippy::invisible_characters)]
|
||||||
fn zero() {
|
fn zero() {
|
||||||
print!("Here >< is a ZWS, and another");
|
print!("Here >< is a ZWS, and another");
|
||||||
print!("This\u{200B}is\u{200B}fine");
|
print!("This\u{200B}is\u{200B}fine");
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
error: invisible character detected: '/u{200b}'
|
error: invisible character 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"`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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::invisible-characters` implied by `-D warnings`
|
||||||
|
|
||||||
error: invisible character detected: '/u{ad}'
|
error: invisible character detected
|
||||||
--> $DIR/unicode.rs:5:12
|
--> $DIR/unicode.rs:5:12
|
||||||
|
|
|
|
||||||
LL | print!("Here >< is a SHY, and another");
|
LL | print!("Here >< is a SHY, and another");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user