Skip to content

Commit 8f280ff

Browse files
authored
Add missing tests annotations for ui-internal (#14388)
Follow-up of #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

+4
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

+10-9
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

+2
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

+1-1
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

+5
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

+9-4
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

+1
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

+1
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

+2
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

+1-1
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
| ^^^^^^^^^^^^^^

tests/ui-internal/interning_defined_symbol.fixed

+4
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@ macro_rules! sym {
1515
fn main() {
1616
// Direct use of Symbol::intern
1717
let _ = rustc_span::sym::f32;
18+
//~^ interning_defined_symbol
1819

1920
// Using a sym macro
2021
let _ = rustc_span::sym::f32;
22+
//~^ interning_defined_symbol
2123

2224
// Correct suggestion when symbol isn't stringified constant name
2325
let _ = rustc_span::sym::proc_dash_macro;
26+
//~^ interning_defined_symbol
2427

2528
// interning a keyword
2629
let _ = rustc_span::kw::SelfLower;
30+
//~^ interning_defined_symbol
2731

2832
// Interning a symbol that is not defined
2933
let _ = Symbol::intern("xyz123");

tests/ui-internal/interning_defined_symbol.rs

+4
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@ macro_rules! sym {
1515
fn main() {
1616
// Direct use of Symbol::intern
1717
let _ = Symbol::intern("f32");
18+
//~^ interning_defined_symbol
1819

1920
// Using a sym macro
2021
let _ = sym!(f32);
22+
//~^ interning_defined_symbol
2123

2224
// Correct suggestion when symbol isn't stringified constant name
2325
let _ = Symbol::intern("proc-macro");
26+
//~^ interning_defined_symbol
2427

2528
// interning a keyword
2629
let _ = Symbol::intern("self");
30+
//~^ interning_defined_symbol
2731

2832
// Interning a symbol that is not defined
2933
let _ = Symbol::intern("xyz123");

tests/ui-internal/interning_defined_symbol.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ LL | #![deny(clippy::internal)]
1212
= note: `#[deny(clippy::interning_defined_symbol)]` implied by `#[deny(clippy::internal)]`
1313

1414
error: interning a defined symbol
15-
--> tests/ui-internal/interning_defined_symbol.rs:20:13
15+
--> tests/ui-internal/interning_defined_symbol.rs:21:13
1616
|
1717
LL | let _ = sym!(f32);
1818
| ^^^^^^^^^ help: try: `rustc_span::sym::f32`
1919

2020
error: interning a defined symbol
21-
--> tests/ui-internal/interning_defined_symbol.rs:23:13
21+
--> tests/ui-internal/interning_defined_symbol.rs:25:13
2222
|
2323
LL | let _ = Symbol::intern("proc-macro");
2424
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::sym::proc_dash_macro`
2525

2626
error: interning a defined symbol
27-
--> tests/ui-internal/interning_defined_symbol.rs:26:13
27+
--> tests/ui-internal/interning_defined_symbol.rs:29:13
2828
|
2929
LL | let _ = Symbol::intern("self");
3030
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::kw::SelfLower`

tests/ui-internal/invalid_msrv_attr_impl.fixed

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ impl_lint_pass!(Pass => [TEST_LINT]);
2727

2828
impl EarlyLintPass for Pass {
2929
extract_msrv_attr!();
30+
//~^ missing_msrv_attr_impl
3031
fn check_expr(&mut self, _: &EarlyContext<'_>, _: &rustc_ast::Expr) {}
3132
}
3233

tests/ui-internal/invalid_msrv_attr_impl.rs

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ struct Pass {
2626
impl_lint_pass!(Pass => [TEST_LINT]);
2727

2828
impl EarlyLintPass for Pass {
29+
//~^ missing_msrv_attr_impl
2930
fn check_expr(&mut self, _: &EarlyContext<'_>, _: &rustc_ast::Expr) {}
3031
}
3132

tests/ui-internal/invalid_paths.rs

+3
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ mod paths {
1313

1414
// Path with empty segment
1515
pub const TRANSMUTE: [&str; 4] = ["core", "intrinsics", "", "transmute"];
16+
//~^ invalid_paths
1617

1718
// Path with bad crate
1819
pub const BAD_CRATE_PATH: [&str; 2] = ["bad", "path"];
20+
//~^ invalid_paths
1921

2022
// Path with bad module
2123
pub const BAD_MOD_PATH: [&str; 2] = ["std", "xxx"];
24+
//~^ invalid_paths
2225

2326
// Path to method on an enum inherent impl
2427
pub const OPTION_IS_SOME: [&str; 4] = ["core", "option", "Option", "is_some"];

tests/ui-internal/invalid_paths.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ LL | pub const TRANSMUTE: [&str; 4] = ["core", "intrinsics", "", "transmute"
88
= help: to override `-D warnings` add `#[allow(clippy::invalid_paths)]`
99

1010
error: invalid path
11-
--> tests/ui-internal/invalid_paths.rs:18:5
11+
--> tests/ui-internal/invalid_paths.rs:19:5
1212
|
1313
LL | pub const BAD_CRATE_PATH: [&str; 2] = ["bad", "path"];
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1515

1616
error: invalid path
17-
--> tests/ui-internal/invalid_paths.rs:21:5
17+
--> tests/ui-internal/invalid_paths.rs:23:5
1818
|
1919
LL | pub const BAD_MOD_PATH: [&str; 2] = ["std", "xxx"];
2020
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/ui-internal/lint_without_lint_pass.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ extern crate rustc_lint;
1010
use rustc_lint::{LintPass, LintVec};
1111

1212
declare_tool_lint! {
13+
//~^ lint_without_lint_pass
1314
pub clippy::TEST_LINT,
1415
Warn,
1516
"",

tests/ui-internal/lint_without_lint_pass.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ error: the lint `TEST_LINT` is not added to any `LintPass`
22
--> tests/ui-internal/lint_without_lint_pass.rs:12:1
33
|
44
LL | / declare_tool_lint! {
5+
LL | |
56
LL | | pub clippy::TEST_LINT,
67
LL | | Warn,
78
LL | | "",

tests/ui-internal/outer_expn_data.fixed

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ declare_lint_pass!(Pass => [TEST_LINT]);
2121
impl<'tcx> LateLintPass<'tcx> for Pass {
2222
fn check_expr(&mut self, _cx: &LateContext<'tcx>, expr: &'tcx Expr) {
2323
let _ = expr.span.ctxt().outer_expn_data();
24+
//~^ outer_expn_expn_data
2425
}
2526
}
2627

tests/ui-internal/outer_expn_data.rs

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ declare_lint_pass!(Pass => [TEST_LINT]);
2121
impl<'tcx> LateLintPass<'tcx> for Pass {
2222
fn check_expr(&mut self, _cx: &LateContext<'tcx>, expr: &'tcx Expr) {
2323
let _ = expr.span.ctxt().outer_expn().expn_data();
24+
//~^ outer_expn_expn_data
2425
}
2526
}
2627

0 commit comments

Comments
 (0)