Skip to content

Add missing tests annotations for ui-internal #14388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tests/ui-internal/check_clippy_version_attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ declare_tool_lint! {
// Invalid attributes
///////////////////////
declare_tool_lint! {
//~^ invalid_clippy_version_attribute
#[clippy::version = "1.2.3.4.5.6"]
pub clippy::INVALID_ONE,
Warn,
Expand All @@ -46,6 +47,7 @@ declare_tool_lint! {
}

declare_tool_lint! {
//~^ invalid_clippy_version_attribute
#[clippy::version = "I'm a string"]
pub clippy::INVALID_TWO,
Warn,
Expand All @@ -57,6 +59,7 @@ declare_tool_lint! {
// Missing attribute test
///////////////////////
declare_tool_lint! {
//~^ missing_clippy_version_attribute
#[clippy::version]
pub clippy::MISSING_ATTRIBUTE_ONE,
Warn,
Expand All @@ -65,6 +68,7 @@ declare_tool_lint! {
}

declare_tool_lint! {
//~^ missing_clippy_version_attribute
pub clippy::MISSING_ATTRIBUTE_TWO,
Warn,
"Two",
Expand Down
19 changes: 10 additions & 9 deletions tests/ui-internal/check_clippy_version_attribute.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ error: this item has an invalid `clippy::version` attribute
--> tests/ui-internal/check_clippy_version_attribute.rs:40:1
|
LL | / declare_tool_lint! {
LL | |
LL | | #[clippy::version = "1.2.3.4.5.6"]
LL | | pub clippy::INVALID_ONE,
LL | | Warn,
LL | | "One",
... |
LL | | report_in_external_macro: true
LL | | }
| |_^
Expand All @@ -20,13 +20,13 @@ LL | #![deny(clippy::internal)]
= 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)

error: this item has an invalid `clippy::version` attribute
--> tests/ui-internal/check_clippy_version_attribute.rs:48:1
--> tests/ui-internal/check_clippy_version_attribute.rs:49:1
|
LL | / declare_tool_lint! {
LL | |
LL | | #[clippy::version = "I'm a string"]
LL | | pub clippy::INVALID_TWO,
LL | | Warn,
LL | | "Two",
... |
LL | | report_in_external_macro: true
LL | | }
| |_^
Expand All @@ -35,13 +35,13 @@ LL | | }
= 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)

error: this lint is missing the `clippy::version` attribute or version value
--> tests/ui-internal/check_clippy_version_attribute.rs:59:1
--> tests/ui-internal/check_clippy_version_attribute.rs:61:1
|
LL | / declare_tool_lint! {
LL | |
LL | | #[clippy::version]
LL | | pub clippy::MISSING_ATTRIBUTE_ONE,
LL | | Warn,
LL | | "Two",
... |
LL | | report_in_external_macro: true
LL | | }
| |_^
Expand All @@ -51,9 +51,10 @@ LL | | }
= 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)

error: this lint is missing the `clippy::version` attribute or version value
--> tests/ui-internal/check_clippy_version_attribute.rs:67:1
--> tests/ui-internal/check_clippy_version_attribute.rs:70:1
|
LL | / declare_tool_lint! {
LL | |
LL | | pub clippy::MISSING_ATTRIBUTE_TWO,
LL | | Warn,
LL | | "Two",
Expand Down
2 changes: 2 additions & 0 deletions tests/ui-internal/check_formulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ declare_tool_lint! {
declare_tool_lint! {
/// # What it does
/// Check for lint formulations that are correct
//~^ almost_standard_lint_formulation
#[clippy::version = "pre 1.29.0"]
pub clippy::INVALID1,
Warn,
Expand All @@ -31,6 +32,7 @@ declare_tool_lint! {
declare_tool_lint! {
/// # What it does
/// Detects uses of incorrect formulations
//~^ almost_standard_lint_formulation
#[clippy::version = "pre 1.29.0"]
pub clippy::INVALID2,
Warn,
Expand Down
2 changes: 1 addition & 1 deletion tests/ui-internal/check_formulation.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LL | /// Check for lint formulations that are correct
= help: to override `-D warnings` add `#[allow(clippy::almost_standard_lint_formulation)]`

error: non-standard lint formulation
--> tests/ui-internal/check_formulation.rs:33:5
--> tests/ui-internal/check_formulation.rs:34:5
|
LL | /// Detects uses of incorrect formulations
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
5 changes: 5 additions & 0 deletions tests/ui-internal/collapsible_span_lint_calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,23 @@ impl EarlyLintPass for Pass {
let predicate = true;

span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
//~^ collapsible_span_lint_calls
db.span_suggestion(expr.span, help_msg, sugg.to_string(), Applicability::MachineApplicable);
});
span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
//~^ collapsible_span_lint_calls
db.span_help(expr.span, help_msg);
});
span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
//~^ collapsible_span_lint_calls
db.help(help_msg);
});
span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
//~^ collapsible_span_lint_calls
db.span_note(expr.span, note_msg);
});
span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
//~^ collapsible_span_lint_calls
db.note(note_msg);
});

Expand Down
13 changes: 9 additions & 4 deletions tests/ui-internal/collapsible_span_lint_calls.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ error: this call is collapsible
--> tests/ui-internal/collapsible_span_lint_calls.rs:35:9
|
LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
LL | |
LL | | db.span_suggestion(expr.span, help_msg, sugg.to_string(), Applicability::MachineApplicable);
LL | | });
| |__________^ help: collapse into: `span_lint_and_sugg(cx, TEST_LINT, expr.span, lint_msg, help_msg, sugg.to_string(), Applicability::MachineApplicable)`
Expand All @@ -14,33 +15,37 @@ LL | #![deny(clippy::internal)]
= note: `#[deny(clippy::collapsible_span_lint_calls)]` implied by `#[deny(clippy::internal)]`

error: this call is collapsible
--> tests/ui-internal/collapsible_span_lint_calls.rs:38:9
--> tests/ui-internal/collapsible_span_lint_calls.rs:39:9
|
LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
LL | |
LL | | db.span_help(expr.span, help_msg);
LL | | });
| |__________^ help: collapse into: `span_lint_and_help(cx, TEST_LINT, expr.span, lint_msg, Some(expr.span), help_msg)`

error: this call is collapsible
--> tests/ui-internal/collapsible_span_lint_calls.rs:41:9
--> tests/ui-internal/collapsible_span_lint_calls.rs:43:9
|
LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
LL | |
LL | | db.help(help_msg);
LL | | });
| |__________^ help: collapse into: `span_lint_and_help(cx, TEST_LINT, expr.span, lint_msg, None, help_msg)`

error: this call is collapsible
--> tests/ui-internal/collapsible_span_lint_calls.rs:44:9
--> tests/ui-internal/collapsible_span_lint_calls.rs:47:9
|
LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
LL | |
LL | | db.span_note(expr.span, note_msg);
LL | | });
| |__________^ help: collapse into: `span_lint_and_note(cx, TEST_LINT, expr.span, lint_msg, Some(expr.span), note_msg)`

error: this call is collapsible
--> tests/ui-internal/collapsible_span_lint_calls.rs:47:9
--> tests/ui-internal/collapsible_span_lint_calls.rs:51:9
|
LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
LL | |
LL | | db.note(note_msg);
LL | | });
| |__________^ help: collapse into: `span_lint_and_note(cx, TEST_LINT, expr.span, lint_msg, None, note_msg)`
Expand Down
1 change: 1 addition & 0 deletions tests/ui-internal/default_lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ declare_tool_lint! {
}

declare_tool_lint! {
//~^ default_lint
pub clippy::TEST_LINT_DEFAULT,
Warn,
"default lint description",
Expand Down
1 change: 1 addition & 0 deletions tests/ui-internal/default_lint.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ error: the lint `TEST_LINT_DEFAULT` has the default lint description
--> tests/ui-internal/default_lint.rs:18:1
|
LL | / declare_tool_lint! {
LL | |
LL | | pub clippy::TEST_LINT_DEFAULT,
LL | | Warn,
LL | | "default lint description",
Expand Down
2 changes: 2 additions & 0 deletions tests/ui-internal/disallow_span_lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ use rustc_middle::ty::TyCtxt;

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

pub fn b(tcx: TyCtxt<'_>, lint: &'static Lint, hir_id: HirId, span: impl Into<MultiSpan>, msg: impl Into<DiagMessage>) {
tcx.node_span_lint(lint, hir_id, span, |lint| {
//~^ disallowed_methods
lint.primary_message(msg);
});
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ui-internal/disallow_span_lint.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LL | cx.span_lint(lint, span, |lint| {
= help: to override `-D warnings` add `#[allow(clippy::disallowed_methods)]`

error: use of a disallowed method `rustc_middle::ty::context::TyCtxt::node_span_lint`
--> tests/ui-internal/disallow_span_lint.rs:20:9
--> tests/ui-internal/disallow_span_lint.rs:21:9
|
LL | tcx.node_span_lint(lint, hir_id, span, |lint| {
| ^^^^^^^^^^^^^^
Expand Down
4 changes: 4 additions & 0 deletions tests/ui-internal/interning_defined_symbol.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@ macro_rules! sym {
fn main() {
// Direct use of Symbol::intern
let _ = rustc_span::sym::f32;
//~^ interning_defined_symbol

// Using a sym macro
let _ = rustc_span::sym::f32;
//~^ interning_defined_symbol

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

// interning a keyword
let _ = rustc_span::kw::SelfLower;
//~^ interning_defined_symbol

// Interning a symbol that is not defined
let _ = Symbol::intern("xyz123");
Expand Down
4 changes: 4 additions & 0 deletions tests/ui-internal/interning_defined_symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@ macro_rules! sym {
fn main() {
// Direct use of Symbol::intern
let _ = Symbol::intern("f32");
//~^ interning_defined_symbol

// Using a sym macro
let _ = sym!(f32);
//~^ interning_defined_symbol

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

// interning a keyword
let _ = Symbol::intern("self");
//~^ interning_defined_symbol

// Interning a symbol that is not defined
let _ = Symbol::intern("xyz123");
Expand Down
6 changes: 3 additions & 3 deletions tests/ui-internal/interning_defined_symbol.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ LL | #![deny(clippy::internal)]
= note: `#[deny(clippy::interning_defined_symbol)]` implied by `#[deny(clippy::internal)]`

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

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

error: interning a defined symbol
--> tests/ui-internal/interning_defined_symbol.rs:26:13
--> tests/ui-internal/interning_defined_symbol.rs:29:13
|
LL | let _ = Symbol::intern("self");
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::kw::SelfLower`
Expand Down
1 change: 1 addition & 0 deletions tests/ui-internal/invalid_msrv_attr_impl.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ impl_lint_pass!(Pass => [TEST_LINT]);

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

Expand Down
1 change: 1 addition & 0 deletions tests/ui-internal/invalid_msrv_attr_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ struct Pass {
impl_lint_pass!(Pass => [TEST_LINT]);

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

Expand Down
3 changes: 3 additions & 0 deletions tests/ui-internal/invalid_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ mod paths {

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

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

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

// Path to method on an enum inherent impl
pub const OPTION_IS_SOME: [&str; 4] = ["core", "option", "Option", "is_some"];
Expand Down
4 changes: 2 additions & 2 deletions tests/ui-internal/invalid_paths.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ LL | pub const TRANSMUTE: [&str; 4] = ["core", "intrinsics", "", "transmute"
= help: to override `-D warnings` add `#[allow(clippy::invalid_paths)]`

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

error: invalid path
--> tests/ui-internal/invalid_paths.rs:21:5
--> tests/ui-internal/invalid_paths.rs:23:5
|
LL | pub const BAD_MOD_PATH: [&str; 2] = ["std", "xxx"];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions tests/ui-internal/lint_without_lint_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ extern crate rustc_lint;
use rustc_lint::{LintPass, LintVec};

declare_tool_lint! {
//~^ lint_without_lint_pass
pub clippy::TEST_LINT,
Warn,
"",
Expand Down
1 change: 1 addition & 0 deletions tests/ui-internal/lint_without_lint_pass.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ error: the lint `TEST_LINT` is not added to any `LintPass`
--> tests/ui-internal/lint_without_lint_pass.rs:12:1
|
LL | / declare_tool_lint! {
LL | |
LL | | pub clippy::TEST_LINT,
LL | | Warn,
LL | | "",
Expand Down
1 change: 1 addition & 0 deletions tests/ui-internal/outer_expn_data.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ declare_lint_pass!(Pass => [TEST_LINT]);
impl<'tcx> LateLintPass<'tcx> for Pass {
fn check_expr(&mut self, _cx: &LateContext<'tcx>, expr: &'tcx Expr) {
let _ = expr.span.ctxt().outer_expn_data();
//~^ outer_expn_expn_data
}
}

Expand Down
1 change: 1 addition & 0 deletions tests/ui-internal/outer_expn_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ declare_lint_pass!(Pass => [TEST_LINT]);
impl<'tcx> LateLintPass<'tcx> for Pass {
fn check_expr(&mut self, _cx: &LateContext<'tcx>, expr: &'tcx Expr) {
let _ = expr.span.ctxt().outer_expn().expn_data();
//~^ outer_expn_expn_data
}
}

Expand Down
Loading