about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/derive_partial_eq_without_eq.fixed17
-rw-r--r--tests/ui/derive_partial_eq_without_eq.rs17
-rw-r--r--tests/ui/derive_partial_eq_without_eq.stderr26
-rw-r--r--tests/ui/doc/doc-fixable.fixed3
-rw-r--r--tests/ui/doc/doc-fixable.rs3
-rw-r--r--tests/ui/doc/doc-fixable.stderr8
-rw-r--r--tests/ui/doc/issue_12795.fixed9
-rw-r--r--tests/ui/doc/issue_12795.rs9
-rw-r--r--tests/ui/doc/issue_12795.stderr48
-rw-r--r--tests/ui/numbered_fields.fixed5
-rw-r--r--tests/ui/numbered_fields.rs5
-rw-r--r--tests/ui/numbered_fields.stderr8
-rw-r--r--tests/ui/unsafe_derive_deserialize.rs11
-rw-r--r--tests/ui/unsafe_derive_deserialize.stderr8
14 files changed, 158 insertions, 19 deletions
diff --git a/tests/ui/derive_partial_eq_without_eq.fixed b/tests/ui/derive_partial_eq_without_eq.fixed
index 6f42487bbf4..eb93eb8e8ed 100644
--- a/tests/ui/derive_partial_eq_without_eq.fixed
+++ b/tests/ui/derive_partial_eq_without_eq.fixed
@@ -1,3 +1,4 @@
+#![feature(lint_reasons)]
 #![allow(unused)]
 #![warn(clippy::derive_partial_eq_without_eq)]
 
@@ -14,6 +15,22 @@ pub struct MissingEq {
     bar: String,
 }
 
+// Check that we honor the `allow` attribute
+#[allow(clippy::derive_partial_eq_without_eq)]
+#[derive(Debug, PartialEq)]
+pub struct AllowedMissingEq {
+    foo: u32,
+    bar: String,
+}
+
+// Check that we honor the `expect` attribute
+#[expect(clippy::derive_partial_eq_without_eq)]
+#[derive(Debug, PartialEq)]
+pub struct ExpectedMissingEq {
+    foo: u32,
+    bar: String,
+}
+
 // Eq is derived
 #[derive(PartialEq, Eq)]
 pub struct NotMissingEq {
diff --git a/tests/ui/derive_partial_eq_without_eq.rs b/tests/ui/derive_partial_eq_without_eq.rs
index 24f687c6c9d..42dc435bdd5 100644
--- a/tests/ui/derive_partial_eq_without_eq.rs
+++ b/tests/ui/derive_partial_eq_without_eq.rs
@@ -1,3 +1,4 @@
+#![feature(lint_reasons)]
 #![allow(unused)]
 #![warn(clippy::derive_partial_eq_without_eq)]
 
@@ -14,6 +15,22 @@ pub struct MissingEq {
     bar: String,
 }
 
+// Check that we honor the `allow` attribute
+#[allow(clippy::derive_partial_eq_without_eq)]
+#[derive(Debug, PartialEq)]
+pub struct AllowedMissingEq {
+    foo: u32,
+    bar: String,
+}
+
+// Check that we honor the `expect` attribute
+#[expect(clippy::derive_partial_eq_without_eq)]
+#[derive(Debug, PartialEq)]
+pub struct ExpectedMissingEq {
+    foo: u32,
+    bar: String,
+}
+
 // Eq is derived
 #[derive(PartialEq, Eq)]
 pub struct NotMissingEq {
diff --git a/tests/ui/derive_partial_eq_without_eq.stderr b/tests/ui/derive_partial_eq_without_eq.stderr
index 3d92112dc36..29cd7da6b77 100644
--- a/tests/ui/derive_partial_eq_without_eq.stderr
+++ b/tests/ui/derive_partial_eq_without_eq.stderr
@@ -1,5 +1,5 @@
 error: you are deriving `PartialEq` and can implement `Eq`
-  --> tests/ui/derive_partial_eq_without_eq.rs:11:17
+  --> tests/ui/derive_partial_eq_without_eq.rs:12:17
    |
 LL | #[derive(Debug, PartialEq)]
    |                 ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
@@ -8,73 +8,73 @@ LL | #[derive(Debug, PartialEq)]
    = help: to override `-D warnings` add `#[allow(clippy::derive_partial_eq_without_eq)]`
 
 error: you are deriving `PartialEq` and can implement `Eq`
-  --> tests/ui/derive_partial_eq_without_eq.rs:53:10
+  --> tests/ui/derive_partial_eq_without_eq.rs:70:10
    |
 LL | #[derive(PartialEq)]
    |          ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
 
 error: you are deriving `PartialEq` and can implement `Eq`
-  --> tests/ui/derive_partial_eq_without_eq.rs:59:10
+  --> tests/ui/derive_partial_eq_without_eq.rs:76:10
    |
 LL | #[derive(PartialEq)]
    |          ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
 
 error: you are deriving `PartialEq` and can implement `Eq`
-  --> tests/ui/derive_partial_eq_without_eq.rs:65:10
+  --> tests/ui/derive_partial_eq_without_eq.rs:82:10
    |
 LL | #[derive(PartialEq)]
    |          ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
 
 error: you are deriving `PartialEq` and can implement `Eq`
-  --> tests/ui/derive_partial_eq_without_eq.rs:68:10
+  --> tests/ui/derive_partial_eq_without_eq.rs:85:10
    |
 LL | #[derive(PartialEq)]
    |          ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
 
 error: you are deriving `PartialEq` and can implement `Eq`
-  --> tests/ui/derive_partial_eq_without_eq.rs:74:10
+  --> tests/ui/derive_partial_eq_without_eq.rs:91:10
    |
 LL | #[derive(PartialEq)]
    |          ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
 
 error: you are deriving `PartialEq` and can implement `Eq`
-  --> tests/ui/derive_partial_eq_without_eq.rs:80:10
+  --> tests/ui/derive_partial_eq_without_eq.rs:97:10
    |
 LL | #[derive(PartialEq)]
    |          ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
 
 error: you are deriving `PartialEq` and can implement `Eq`
-  --> tests/ui/derive_partial_eq_without_eq.rs:93:17
+  --> tests/ui/derive_partial_eq_without_eq.rs:110:17
    |
 LL | #[derive(Debug, PartialEq, Clone)]
    |                 ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
 
 error: you are deriving `PartialEq` and can implement `Eq`
-  --> tests/ui/derive_partial_eq_without_eq.rs:96:10
+  --> tests/ui/derive_partial_eq_without_eq.rs:113:10
    |
 LL | #[derive(PartialEq)]
    |          ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
 
 error: you are deriving `PartialEq` and can implement `Eq`
-  --> tests/ui/derive_partial_eq_without_eq.rs:103:14
+  --> tests/ui/derive_partial_eq_without_eq.rs:120:14
    |
 LL |     #[derive(PartialEq)]
    |              ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
 
 error: you are deriving `PartialEq` and can implement `Eq`
-  --> tests/ui/derive_partial_eq_without_eq.rs:106:14
+  --> tests/ui/derive_partial_eq_without_eq.rs:123:14
    |
 LL |     #[derive(PartialEq)]
    |              ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
 
 error: you are deriving `PartialEq` and can implement `Eq`
-  --> tests/ui/derive_partial_eq_without_eq.rs:166:14
+  --> tests/ui/derive_partial_eq_without_eq.rs:183:14
    |
 LL |     #[derive(PartialEq)]
    |              ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
 
 error: you are deriving `PartialEq` and can implement `Eq`
-  --> tests/ui/derive_partial_eq_without_eq.rs:174:14
+  --> tests/ui/derive_partial_eq_without_eq.rs:191:14
    |
 LL |     #[derive(PartialEq)]
    |              ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
diff --git a/tests/ui/doc/doc-fixable.fixed b/tests/ui/doc/doc-fixable.fixed
index 7e22c847b1b..84673f1f43f 100644
--- a/tests/ui/doc/doc-fixable.fixed
+++ b/tests/ui/doc/doc-fixable.fixed
@@ -240,3 +240,6 @@ extern {
     /// `foo()`
     fn in_extern();
 }
+
+/// <https://github.com/rust-lang/rust-clippy/pull/12836>
+fn check_autofix_for_base_urls() {}
diff --git a/tests/ui/doc/doc-fixable.rs b/tests/ui/doc/doc-fixable.rs
index 3e2cb0df54b..4d017a99e0f 100644
--- a/tests/ui/doc/doc-fixable.rs
+++ b/tests/ui/doc/doc-fixable.rs
@@ -240,3 +240,6 @@ extern {
     /// foo()
     fn in_extern();
 }
+
+/// https://github.com/rust-lang/rust-clippy/pull/12836
+fn check_autofix_for_base_urls() {}
diff --git a/tests/ui/doc/doc-fixable.stderr b/tests/ui/doc/doc-fixable.stderr
index cd2228c47e3..a9263f62d38 100644
--- a/tests/ui/doc/doc-fixable.stderr
+++ b/tests/ui/doc/doc-fixable.stderr
@@ -363,5 +363,11 @@ help: try
 LL |     /// `foo()`
    |         ~~~~~~~
 
-error: aborting due to 33 previous errors
+error: you should put bare URLs between `<`/`>` or make a proper Markdown link
+  --> tests/ui/doc/doc-fixable.rs:244:5
+   |
+LL | /// https://github.com/rust-lang/rust-clippy/pull/12836
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `<https://github.com/rust-lang/rust-clippy/pull/12836>`
+
+error: aborting due to 34 previous errors
 
diff --git a/tests/ui/doc/issue_12795.fixed b/tests/ui/doc/issue_12795.fixed
new file mode 100644
index 00000000000..ade23bf975c
--- /dev/null
+++ b/tests/ui/doc/issue_12795.fixed
@@ -0,0 +1,9 @@
+#![warn(clippy::doc_markdown)]
+
+//! A comment with `a_b(x)` and `a_c` in it and (`a_b((c))` ) too and (maybe `a_b((c))`)
+//~^ ERROR: item in documentation is missing backticks
+//~| ERROR: item in documentation is missing backticks
+//~| ERROR: item in documentation is missing backticks
+//~| ERROR: item in documentation is missing backticks
+
+pub fn main() {}
diff --git a/tests/ui/doc/issue_12795.rs b/tests/ui/doc/issue_12795.rs
new file mode 100644
index 00000000000..6d94a07e303
--- /dev/null
+++ b/tests/ui/doc/issue_12795.rs
@@ -0,0 +1,9 @@
+#![warn(clippy::doc_markdown)]
+
+//! A comment with a_b(x) and a_c in it and (a_b((c)) ) too and (maybe a_b((c)))
+//~^ ERROR: item in documentation is missing backticks
+//~| ERROR: item in documentation is missing backticks
+//~| ERROR: item in documentation is missing backticks
+//~| ERROR: item in documentation is missing backticks
+
+pub fn main() {}
diff --git a/tests/ui/doc/issue_12795.stderr b/tests/ui/doc/issue_12795.stderr
new file mode 100644
index 00000000000..5700145ec8f
--- /dev/null
+++ b/tests/ui/doc/issue_12795.stderr
@@ -0,0 +1,48 @@
+error: item in documentation is missing backticks
+  --> tests/ui/doc/issue_12795.rs:3:20
+   |
+LL | //! A comment with a_b(x) and a_c in it and (a_b((c)) ) too and (maybe a_b((c)))
+   |                    ^^^^^^
+   |
+   = note: `-D clippy::doc-markdown` implied by `-D warnings`
+   = help: to override `-D warnings` add `#[allow(clippy::doc_markdown)]`
+help: try
+   |
+LL | //! A comment with `a_b(x)` and a_c in it and (a_b((c)) ) too and (maybe a_b((c)))
+   |                    ~~~~~~~~
+
+error: item in documentation is missing backticks
+  --> tests/ui/doc/issue_12795.rs:3:31
+   |
+LL | //! A comment with a_b(x) and a_c in it and (a_b((c)) ) too and (maybe a_b((c)))
+   |                               ^^^
+   |
+help: try
+   |
+LL | //! A comment with a_b(x) and `a_c` in it and (a_b((c)) ) too and (maybe a_b((c)))
+   |                               ~~~~~
+
+error: item in documentation is missing backticks
+  --> tests/ui/doc/issue_12795.rs:3:46
+   |
+LL | //! A comment with a_b(x) and a_c in it and (a_b((c)) ) too and (maybe a_b((c)))
+   |                                              ^^^^^^^^
+   |
+help: try
+   |
+LL | //! A comment with a_b(x) and a_c in it and (`a_b((c))` ) too and (maybe a_b((c)))
+   |                                              ~~~~~~~~~~
+
+error: item in documentation is missing backticks
+  --> tests/ui/doc/issue_12795.rs:3:72
+   |
+LL | //! A comment with a_b(x) and a_c in it and (a_b((c)) ) too and (maybe a_b((c)))
+   |                                                                        ^^^^^^^^
+   |
+help: try
+   |
+LL | //! A comment with a_b(x) and a_c in it and (a_b((c)) ) too and (maybe `a_b((c))`)
+   |                                                                        ~~~~~~~~~~
+
+error: aborting due to 4 previous errors
+
diff --git a/tests/ui/numbered_fields.fixed b/tests/ui/numbered_fields.fixed
index dc88081ba0a..108520eed38 100644
--- a/tests/ui/numbered_fields.fixed
+++ b/tests/ui/numbered_fields.fixed
@@ -34,4 +34,9 @@ fn main() {
 
     // Aliases can't be tuple constructed #8638
     let _ = Alias { 0: 0, 1: 1, 2: 2 };
+
+    // Issue #12367
+    struct TupleStructVec(Vec<usize>);
+
+    let _ = TupleStructVec(vec![0, 1, 2, 3]);
 }
diff --git a/tests/ui/numbered_fields.rs b/tests/ui/numbered_fields.rs
index e8fa652e3c1..c718661a682 100644
--- a/tests/ui/numbered_fields.rs
+++ b/tests/ui/numbered_fields.rs
@@ -42,4 +42,9 @@ fn main() {
 
     // Aliases can't be tuple constructed #8638
     let _ = Alias { 0: 0, 1: 1, 2: 2 };
+
+    // Issue #12367
+    struct TupleStructVec(Vec<usize>);
+
+    let _ = TupleStructVec { 0: vec![0, 1, 2, 3] };
 }
diff --git a/tests/ui/numbered_fields.stderr b/tests/ui/numbered_fields.stderr
index 96426cab1e6..9d3f59cd376 100644
--- a/tests/ui/numbered_fields.stderr
+++ b/tests/ui/numbered_fields.stderr
@@ -23,5 +23,11 @@ LL | |         1: 3u32,
 LL | |     };
    | |_____^ help: try: `TupleStruct(1u32, 3u32, 2u8)`
 
-error: aborting due to 2 previous errors
+error: used a field initializer for a tuple struct
+  --> tests/ui/numbered_fields.rs:49:13
+   |
+LL |     let _ = TupleStructVec { 0: vec![0, 1, 2, 3] };
+   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `TupleStructVec(vec![0, 1, 2, 3])`
+
+error: aborting due to 3 previous errors
 
diff --git a/tests/ui/unsafe_derive_deserialize.rs b/tests/ui/unsafe_derive_deserialize.rs
index 70dcaa3afa4..5187e079042 100644
--- a/tests/ui/unsafe_derive_deserialize.rs
+++ b/tests/ui/unsafe_derive_deserialize.rs
@@ -1,3 +1,4 @@
+#![feature(lint_reasons)]
 #![warn(clippy::unsafe_derive_deserialize)]
 #![allow(unused, clippy::missing_safety_doc)]
 
@@ -71,4 +72,14 @@ impl G {
     }
 }
 
+// Check that we honor the `expect` attribute on the ADT
+#[expect(clippy::unsafe_derive_deserialize)]
+#[derive(Deserialize)]
+pub struct H;
+impl H {
+    pub fn unsafe_block(&self) {
+        unsafe {}
+    }
+}
+
 fn main() {}
diff --git a/tests/ui/unsafe_derive_deserialize.stderr b/tests/ui/unsafe_derive_deserialize.stderr
index f2d4429f707..06719f23d57 100644
--- a/tests/ui/unsafe_derive_deserialize.stderr
+++ b/tests/ui/unsafe_derive_deserialize.stderr
@@ -1,5 +1,5 @@
 error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe`
-  --> tests/ui/unsafe_derive_deserialize.rs:8:10
+  --> tests/ui/unsafe_derive_deserialize.rs:9:10
    |
 LL | #[derive(Deserialize)]
    |          ^^^^^^^^^^^
@@ -10,7 +10,7 @@ LL | #[derive(Deserialize)]
    = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe`
-  --> tests/ui/unsafe_derive_deserialize.rs:17:10
+  --> tests/ui/unsafe_derive_deserialize.rs:18:10
    |
 LL | #[derive(Deserialize)]
    |          ^^^^^^^^^^^
@@ -19,7 +19,7 @@ LL | #[derive(Deserialize)]
    = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe`
-  --> tests/ui/unsafe_derive_deserialize.rs:24:10
+  --> tests/ui/unsafe_derive_deserialize.rs:25:10
    |
 LL | #[derive(Deserialize)]
    |          ^^^^^^^^^^^
@@ -28,7 +28,7 @@ LL | #[derive(Deserialize)]
    = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe`
-  --> tests/ui/unsafe_derive_deserialize.rs:33:10
+  --> tests/ui/unsafe_derive_deserialize.rs:34:10
    |
 LL | #[derive(Deserialize)]
    |          ^^^^^^^^^^^