about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-04-07 17:11:26 +0000
committerbors <bors@rust-lang.org>2022-04-07 17:11:26 +0000
commit984330a6ee3c4d15626685d6dc8b7b759ff630bd (patch)
tree009eda145dc08dc192be4f93f53c48a513a84c49
parentabc59bb9144a97ec23d187dcb2cb28dd88271297 (diff)
parent6ab4508350add2549b2f4b7b052057992a804128 (diff)
downloadrust-984330a6ee3c4d15626685d6dc8b7b759ff630bd.tar.gz
rust-984330a6ee3c4d15626685d6dc8b7b759ff630bd.zip
Auto merge of #8657 - flip1995:raw_lint_desc, r=flip1995
Allow raw lint descriptions

update_lints now understands raw strings in declare_clippy_lint descriptions.

Supersedes  #8655

cc `@Alexendoo` thanks for addressing this so quickly. I build a little bit simpler version of your patch. I don't think it really matters what `Literal` we're trying to tokenize, since we assume later, that it is some sort of `str`.

changelog: none
-rw-r--r--CHANGELOG.md1
-rw-r--r--clippy_dev/src/update_lints.rs5
-rw-r--r--clippy_lints/src/lib.register_all.rs1
-rw-r--r--clippy_lints/src/lib.register_lints.rs1
-rw-r--r--clippy_lints/src/lib.register_style.rs1
5 files changed, 8 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 918f0b48e50..b4097ea86a5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3272,6 +3272,7 @@ Released 2018-09-13
 [`eq_op`]: https://rust-lang.github.io/rust-clippy/master/index.html#eq_op
 [`equatable_if_let`]: https://rust-lang.github.io/rust-clippy/master/index.html#equatable_if_let
 [`erasing_op`]: https://rust-lang.github.io/rust-clippy/master/index.html#erasing_op
+[`err_expect`]: https://rust-lang.github.io/rust-clippy/master/index.html#err_expect
 [`eval_order_dependence`]: https://rust-lang.github.io/rust-clippy/master/index.html#eval_order_dependence
 [`excessive_precision`]: https://rust-lang.github.io/rust-clippy/master/index.html#excessive_precision
 [`exhaustive_enums`]: https://rust-lang.github.io/rust-clippy/master/index.html#exhaustive_enums
diff --git a/clippy_dev/src/update_lints.rs b/clippy_dev/src/update_lints.rs
index 4e48b670457..59db51fbfac 100644
--- a/clippy_dev/src/update_lints.rs
+++ b/clippy_dev/src/update_lints.rs
@@ -359,7 +359,7 @@ fn parse_contents(contents: &str, module: &str, lints: &mut Vec<Lint>) {
             // group,
             Ident(group) Comma
             // "description" }
-            Literal{kind: LiteralKind::Str{..}, ..}(desc) CloseBrace
+            Literal{..}(desc) CloseBrace
         );
         lints.push(Lint::new(name, group, desc, module));
     }
@@ -397,6 +397,9 @@ fn parse_deprecated_contents(contents: &str, lints: &mut Vec<DeprecatedLint>) {
 /// Removes the line splices and surrounding quotes from a string literal
 fn remove_line_splices(s: &str) -> String {
     let s = s
+        .strip_prefix('r')
+        .unwrap_or(s)
+        .trim_matches('#')
         .strip_prefix('"')
         .and_then(|s| s.strip_suffix('"'))
         .unwrap_or_else(|| panic!("expected quoted string, found `{}`", s));
diff --git a/clippy_lints/src/lib.register_all.rs b/clippy_lints/src/lib.register_all.rs
index c95b791f43e..14ca93b5f3c 100644
--- a/clippy_lints/src/lib.register_all.rs
+++ b/clippy_lints/src/lib.register_all.rs
@@ -157,6 +157,7 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
     LintId::of(methods::CHARS_NEXT_CMP),
     LintId::of(methods::CLONE_DOUBLE_REF),
     LintId::of(methods::CLONE_ON_COPY),
+    LintId::of(methods::ERR_EXPECT),
     LintId::of(methods::EXPECT_FUN_CALL),
     LintId::of(methods::EXTEND_WITH_DRAIN),
     LintId::of(methods::FILTER_MAP_IDENTITY),
diff --git a/clippy_lints/src/lib.register_lints.rs b/clippy_lints/src/lib.register_lints.rs
index 1c4ccc15e83..532590aaa5a 100644
--- a/clippy_lints/src/lib.register_lints.rs
+++ b/clippy_lints/src/lib.register_lints.rs
@@ -286,6 +286,7 @@ store.register_lints(&[
     methods::CLONE_DOUBLE_REF,
     methods::CLONE_ON_COPY,
     methods::CLONE_ON_REF_PTR,
+    methods::ERR_EXPECT,
     methods::EXPECT_FUN_CALL,
     methods::EXPECT_USED,
     methods::EXTEND_WITH_DRAIN,
diff --git a/clippy_lints/src/lib.register_style.rs b/clippy_lints/src/lib.register_style.rs
index dcf399cf956..3114afac886 100644
--- a/clippy_lints/src/lib.register_style.rs
+++ b/clippy_lints/src/lib.register_style.rs
@@ -59,6 +59,7 @@ store.register_group(true, "clippy::style", Some("clippy_style"), vec![
     LintId::of(methods::BYTES_NTH),
     LintId::of(methods::CHARS_LAST_CMP),
     LintId::of(methods::CHARS_NEXT_CMP),
+    LintId::of(methods::ERR_EXPECT),
     LintId::of(methods::INTO_ITER_ON_REF),
     LintId::of(methods::ITER_CLONED_COLLECT),
     LintId::of(methods::ITER_NEXT_SLICE),