Skip to content

Commit 8f280ff

Browse files
authored
Add missing tests annotations for ui-internal (#14388)
Follow-up of rust-lang/rust-clippy#11421. I can't yet make the annotations mandatory because there is an issue with `tests/ui-internal/custom_ice_message.rs`: the error message is not emitted as JSON, meaning that we can't match it with `ui_test`. I need to check if it's a bug in rustc or if `ui_test` needs to handle this case somehow. changelog: Add missing tests annotations for `ui-internal` r? @flip1995
2 parents a5bc316 + cb9682b commit 8f280ff

29 files changed

+121
-40
lines changed

tests/ui-internal/check_clippy_version_attribute.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ declare_tool_lint! {
3838
// Invalid attributes
3939
///////////////////////
4040
declare_tool_lint! {
41+
//~^ invalid_clippy_version_attribute
4142
#[clippy::version = "1.2.3.4.5.6"]
4243
pub clippy::INVALID_ONE,
4344
Warn,
@@ -46,6 +47,7 @@ declare_tool_lint! {
4647
}
4748

4849
declare_tool_lint! {
50+
//~^ invalid_clippy_version_attribute
4951
#[clippy::version = "I'm a string"]
5052
pub clippy::INVALID_TWO,
5153
Warn,
@@ -57,6 +59,7 @@ declare_tool_lint! {
5759
// Missing attribute test
5860
///////////////////////
5961
declare_tool_lint! {
62+
//~^ missing_clippy_version_attribute
6063
#[clippy::version]
6164
pub clippy::MISSING_ATTRIBUTE_ONE,
6265
Warn,
@@ -65,6 +68,7 @@ declare_tool_lint! {
6568
}
6669

6770
declare_tool_lint! {
71+
//~^ missing_clippy_version_attribute
6872
pub clippy::MISSING_ATTRIBUTE_TWO,
6973
Warn,
7074
"Two",

tests/ui-internal/check_clippy_version_attribute.stderr

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ error: this item has an invalid `clippy::version` attribute
22
--> tests/ui-internal/check_clippy_version_attribute.rs:40:1
33
|
44
LL | / declare_tool_lint! {
5+
LL | |
56
LL | | #[clippy::version = "1.2.3.4.5.6"]
67
LL | | pub clippy::INVALID_ONE,
7-
LL | | Warn,
8-
LL | | "One",
8+
... |
99
LL | | report_in_external_macro: true
1010
LL | | }
1111
| |_^
@@ -20,13 +20,13 @@ LL | #![deny(clippy::internal)]
2020
= note: this error originates in the macro `$crate::declare_tool_lint` which comes from the expansion of the macro `declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info)
2121

2222
error: this item has an invalid `clippy::version` attribute
23-
--> tests/ui-internal/check_clippy_version_attribute.rs:48:1
23+
--> tests/ui-internal/check_clippy_version_attribute.rs:49:1
2424
|
2525
LL | / declare_tool_lint! {
26+
LL | |
2627
LL | | #[clippy::version = "I'm a string"]
2728
LL | | pub clippy::INVALID_TWO,
28-
LL | | Warn,
29-
LL | | "Two",
29+
... |
3030
LL | | report_in_external_macro: true
3131
LL | | }
3232
| |_^
@@ -35,13 +35,13 @@ LL | | }
3535
= note: this error originates in the macro `$crate::declare_tool_lint` which comes from the expansion of the macro `declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info)
3636

3737
error: this lint is missing the `clippy::version` attribute or version value
38-
--> tests/ui-internal/check_clippy_version_attribute.rs:59:1
38+
--> tests/ui-internal/check_clippy_version_attribute.rs:61:1
3939
|
4040
LL | / declare_tool_lint! {
41+
LL | |
4142
LL | | #[clippy::version]
4243
LL | | pub clippy::MISSING_ATTRIBUTE_ONE,
43-
LL | | Warn,
44-
LL | | "Two",
44+
... |
4545
LL | | report_in_external_macro: true
4646
LL | | }
4747
| |_^
@@ -51,9 +51,10 @@ LL | | }
5151
= note: this error originates in the macro `$crate::declare_tool_lint` which comes from the expansion of the macro `declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info)
5252

5353
error: this lint is missing the `clippy::version` attribute or version value
54-
--> tests/ui-internal/check_clippy_version_attribute.rs:67:1
54+
--> tests/ui-internal/check_clippy_version_attribute.rs:70:1
5555
|
5656
LL | / declare_tool_lint! {
57+
LL | |
5758
LL | | pub clippy::MISSING_ATTRIBUTE_TWO,
5859
LL | | Warn,
5960
LL | | "Two",

tests/ui-internal/check_formulation.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ declare_tool_lint! {
2121
declare_tool_lint! {
2222
/// # What it does
2323
/// Check for lint formulations that are correct
24+
//~^ almost_standard_lint_formulation
2425
#[clippy::version = "pre 1.29.0"]
2526
pub clippy::INVALID1,
2627
Warn,
@@ -31,6 +32,7 @@ declare_tool_lint! {
3132
declare_tool_lint! {
3233
/// # What it does
3334
/// Detects uses of incorrect formulations
35+
//~^ almost_standard_lint_formulation
3436
#[clippy::version = "pre 1.29.0"]
3537
pub clippy::INVALID2,
3638
Warn,

tests/ui-internal/check_formulation.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | /// Check for lint formulations that are correct
99
= help: to override `-D warnings` add `#[allow(clippy::almost_standard_lint_formulation)]`
1010

1111
error: non-standard lint formulation
12-
--> tests/ui-internal/check_formulation.rs:33:5
12+
--> tests/ui-internal/check_formulation.rs:34:5
1313
|
1414
LL | /// Detects uses of incorrect formulations
1515
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/ui-internal/collapsible_span_lint_calls.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,23 @@ impl EarlyLintPass for Pass {
3333
let predicate = true;
3434

3535
span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
36+
//~^ collapsible_span_lint_calls
3637
db.span_suggestion(expr.span, help_msg, sugg.to_string(), Applicability::MachineApplicable);
3738
});
3839
span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
40+
//~^ collapsible_span_lint_calls
3941
db.span_help(expr.span, help_msg);
4042
});
4143
span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
44+
//~^ collapsible_span_lint_calls
4245
db.help(help_msg);
4346
});
4447
span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
48+
//~^ collapsible_span_lint_calls
4549
db.span_note(expr.span, note_msg);
4650
});
4751
span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
52+
//~^ collapsible_span_lint_calls
4853
db.note(note_msg);
4954
});
5055

tests/ui-internal/collapsible_span_lint_calls.stderr

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ error: this call is collapsible
22
--> tests/ui-internal/collapsible_span_lint_calls.rs:35:9
33
|
44
LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
5+
LL | |
56
LL | | db.span_suggestion(expr.span, help_msg, sugg.to_string(), Applicability::MachineApplicable);
67
LL | | });
78
| |__________^ help: collapse into: `span_lint_and_sugg(cx, TEST_LINT, expr.span, lint_msg, help_msg, sugg.to_string(), Applicability::MachineApplicable)`
@@ -14,33 +15,37 @@ LL | #![deny(clippy::internal)]
1415
= note: `#[deny(clippy::collapsible_span_lint_calls)]` implied by `#[deny(clippy::internal)]`
1516

1617
error: this call is collapsible
17-
--> tests/ui-internal/collapsible_span_lint_calls.rs:38:9
18+
--> tests/ui-internal/collapsible_span_lint_calls.rs:39:9
1819
|
1920
LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
21+
LL | |
2022
LL | | db.span_help(expr.span, help_msg);
2123
LL | | });
2224
| |__________^ help: collapse into: `span_lint_and_help(cx, TEST_LINT, expr.span, lint_msg, Some(expr.span), help_msg)`
2325

2426
error: this call is collapsible
25-
--> tests/ui-internal/collapsible_span_lint_calls.rs:41:9
27+
--> tests/ui-internal/collapsible_span_lint_calls.rs:43:9
2628
|
2729
LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
30+
LL | |
2831
LL | | db.help(help_msg);
2932
LL | | });
3033
| |__________^ help: collapse into: `span_lint_and_help(cx, TEST_LINT, expr.span, lint_msg, None, help_msg)`
3134

3235
error: this call is collapsible
33-
--> tests/ui-internal/collapsible_span_lint_calls.rs:44:9
36+
--> tests/ui-internal/collapsible_span_lint_calls.rs:47:9
3437
|
3538
LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
39+
LL | |
3640
LL | | db.span_note(expr.span, note_msg);
3741
LL | | });
3842
| |__________^ help: collapse into: `span_lint_and_note(cx, TEST_LINT, expr.span, lint_msg, Some(expr.span), note_msg)`
3943

4044
error: this call is collapsible
41-
--> tests/ui-internal/collapsible_span_lint_calls.rs:47:9
45+
--> tests/ui-internal/collapsible_span_lint_calls.rs:51:9
4246
|
4347
LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
48+
LL | |
4449
LL | | db.note(note_msg);
4550
LL | | });
4651
| |__________^ help: collapse into: `span_lint_and_note(cx, TEST_LINT, expr.span, lint_msg, None, note_msg)`

tests/ui-internal/default_lint.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ declare_tool_lint! {
1616
}
1717

1818
declare_tool_lint! {
19+
//~^ default_lint
1920
pub clippy::TEST_LINT_DEFAULT,
2021
Warn,
2122
"default lint description",

tests/ui-internal/default_lint.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ error: the lint `TEST_LINT_DEFAULT` has the default lint description
22
--> tests/ui-internal/default_lint.rs:18:1
33
|
44
LL | / declare_tool_lint! {
5+
LL | |
56
LL | | pub clippy::TEST_LINT_DEFAULT,
67
LL | | Warn,
78
LL | | "default lint description",

tests/ui-internal/disallow_span_lint.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ use rustc_middle::ty::TyCtxt;
1212

1313
pub fn a(cx: impl LintContext, lint: &'static Lint, span: impl Into<MultiSpan>, msg: impl Into<DiagMessage>) {
1414
cx.span_lint(lint, span, |lint| {
15+
//~^ disallowed_methods
1516
lint.primary_message(msg);
1617
});
1718
}
1819

1920
pub fn b(tcx: TyCtxt<'_>, lint: &'static Lint, hir_id: HirId, span: impl Into<MultiSpan>, msg: impl Into<DiagMessage>) {
2021
tcx.node_span_lint(lint, hir_id, span, |lint| {
22+
//~^ disallowed_methods
2123
lint.primary_message(msg);
2224
});
2325
}

tests/ui-internal/disallow_span_lint.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | cx.span_lint(lint, span, |lint| {
99
= help: to override `-D warnings` add `#[allow(clippy::disallowed_methods)]`
1010

1111
error: use of a disallowed method `rustc_middle::ty::context::TyCtxt::node_span_lint`
12-
--> tests/ui-internal/disallow_span_lint.rs:20:9
12+
--> tests/ui-internal/disallow_span_lint.rs:21:9
1313
|
1414
LL | tcx.node_span_lint(lint, hir_id, span, |lint| {
1515
| ^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)