Skip to content

Add annotations for test files #12327

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

Closed
wants to merge 4 commits into from
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ fn check_empty_line_after_outer_attr(cx: &EarlyContext<'_>, item: &rustc_ast::It
let lines = snippet.split('\n').collect::<Vec<_>>();
let lines = without_block_comments(lines);

if lines.iter().filter(|l| l.trim().is_empty()).count() > 2 {
if lines.iter().skip(1).filter(|l| l.trim().is_empty()).count() > 1 {
let (lint_msg, lint_type) = match attr.kind {
AttrKind::DocComment(..) => (
"found an empty line after a doc comment. \
Expand Down
22 changes: 11 additions & 11 deletions tests/ui-toml/absolute_paths/absolute_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ pub mod a {

fn main() {
f32::max(1.0, 2.0);
std::f32::MAX;
core::f32::MAX;
::core::f32::MAX;
crate::a::b::c::C;
crate::a::b::c::d::e::f::F;
crate::a::A;
crate::a::b::B;
crate::a::b::c::C::ZERO;
helper::b::c::d::e::f();
::helper::b::c::d::e::f();
std::f32::MAX; //~ absolute_paths
core::f32::MAX; //~ absolute_paths
::core::f32::MAX; //~ absolute_paths
crate::a::b::c::C; //~[disallow_crates] absolute_paths
crate::a::b::c::d::e::f::F; //~[disallow_crates] absolute_paths
crate::a::A; //~[disallow_crates] absolute_paths
crate::a::b::B; //~[disallow_crates] absolute_paths
crate::a::b::c::C::ZERO; //~[disallow_crates] absolute_paths
helper::b::c::d::e::f(); //~[disallow_crates] absolute_paths
::helper::b::c::d::e::f(); //~[disallow_crates] absolute_paths
fn b() -> a::b::B {
todo!()
}
Expand All @@ -55,7 +55,7 @@ fn main() {
std::ptr::addr_of!(x);
// Test we handle max segments with `PathRoot` properly; this has 4 segments but we should say it
// has 3
::std::f32::MAX;
::std::f32::MAX; //~ absolute_paths
// Do not lint due to the above
::helper::a();
// Do not lint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ fn main() {
let local_f64 = 2.0;
let local_opt: Option<i32> = Some(3);

println!("val='{local_i32}'");
println!("val='{local_i32}'"); //~ uninlined_format_args
println!("Hello x is {local_f64:.local_i32$}");
//~^ uninlined_format_args
//~| print_literal
println!("Hello {local_i32} is {local_f64:.*}", 5);
//~^ uninlined_format_args
println!("Hello {local_i32} is {local_f64:.*}", 5);
//~^ uninlined_format_args
println!("{local_i32}, {}", local_opt.unwrap());
//~^ uninlined_format_args
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ fn main() {
let local_f64 = 2.0;
let local_opt: Option<i32> = Some(3);

println!("val='{}'", local_i32);
println!("val='{}'", local_i32); //~ uninlined_format_args
println!("Hello {} is {:.*}", "x", local_i32, local_f64);
//~^ uninlined_format_args
//~| print_literal
println!("Hello {} is {:.*}", local_i32, 5, local_f64);
//~^ uninlined_format_args
println!("Hello {} is {2:.*}", local_i32, 5, local_f64);
//~^ uninlined_format_args
println!("{}, {}", local_i32, local_opt.unwrap());
//~^ uninlined_format_args
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ LL + println!("Hello x is {:.*}", local_i32, local_f64);
|

error: variables can be used directly in the `format!` string
--> $DIR/allow_mixed_uninlined_format_args/uninlined_format_args.rs:11:5
--> $DIR/allow_mixed_uninlined_format_args/uninlined_format_args.rs:13:5
|
LL | println!("Hello {} is {:.*}", local_i32, 5, local_f64);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -51,7 +51,7 @@ LL + println!("Hello {local_i32} is {local_f64:.*}", 5);
|

error: variables can be used directly in the `format!` string
--> $DIR/allow_mixed_uninlined_format_args/uninlined_format_args.rs:12:5
--> $DIR/allow_mixed_uninlined_format_args/uninlined_format_args.rs:15:5
|
LL | println!("Hello {} is {2:.*}", local_i32, 5, local_f64);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -63,7 +63,7 @@ LL + println!("Hello {local_i32} is {local_f64:.*}", 5);
|

error: variables can be used directly in the `format!` string
--> $DIR/allow_mixed_uninlined_format_args/uninlined_format_args.rs:13:5
--> $DIR/allow_mixed_uninlined_format_args/uninlined_format_args.rs:17:5
|
LL | println!("{}, {}", local_i32, local_opt.unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn lhs_and_rhs_are_equal() {
// is implicitly on the list
let _ = Bar + Bar;
// not on the list
let _ = Baz + Baz;
let _ = Baz + Baz; //~ arithmetic_side_effects
}

fn lhs_is_different() {
Expand All @@ -77,14 +77,14 @@ fn lhs_is_different() {
// is implicitly on the list
let _ = 1i32 + Bar;
// not on the list
let _ = 1i32 + Baz;
let _ = 1i32 + Baz; //~ arithmetic_side_effects

// not on the list
let _ = 1i64 + Foo;
let _ = 1i64 + Foo; //~ arithmetic_side_effects
// is implicitly on the list
let _ = 1i64 + Bar;
// not on the list
let _ = 1i64 + Baz;
let _ = 1i64 + Baz; //~ arithmetic_side_effects
}

fn rhs_is_different() {
Expand All @@ -95,14 +95,14 @@ fn rhs_is_different() {
// is implicitly on the list
let _ = Bar + 1i32;
// not on the list
let _ = Baz + 1i32;
let _ = Baz + 1i32; //~ arithmetic_side_effects

// not on the list
let _ = Foo + 1i64;
let _ = Foo + 1i64; //~ arithmetic_side_effects
// is implicitly on the list
let _ = Bar + 1i64;
// not on the list
let _ = Baz + 1i64;
let _ = Baz + 1i64; //~ arithmetic_side_effects
}

fn unary() {
Expand All @@ -111,9 +111,9 @@ fn unary() {
// is explicitly on the list
let _ = -Foo;
// not on the list
let _ = -Bar;
let _ = -Bar; //~ arithmetic_side_effects
// not on the list
let _ = -Baz;
let _ = -Baz; //~ arithmetic_side_effects
}

fn main() {}
4 changes: 3 additions & 1 deletion tests/ui-toml/array_size_threshold/array_size_threshold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
#![warn(clippy::large_const_arrays, clippy::large_stack_arrays)]
//@no-rustfix
const ABOVE: [u8; 11] = [0; 11];
//~^ large_const_arrays
//~| large_stack_arrays
const BELOW: [u8; 10] = [0; 10];

fn main() {
let above = [0u8; 11];
let above = [0u8; 11]; //~ large_stack_arrays
let below = [0u8; 10];
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ LL | const ABOVE: [u8; 11] = [0; 11];
= help: to override `-D warnings` add `#[allow(clippy::large_stack_arrays)]`

error: allocating a local array larger than 10 bytes
--> $DIR/array_size_threshold/array_size_threshold.rs:8:17
--> $DIR/array_size_threshold/array_size_threshold.rs:10:17
|
LL | let above = [0u8; 11];
| ^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
use std::net::Ipv4Addr;

async fn bad() -> u32 {
let _x = String::from("hello");
let _x = String::from("hello"); //~ await_holding_invalid_type
baz().await
}

async fn bad_reason() -> u32 {
let x = Ipv4Addr::new(127, 0, 0, 1);
//~^ await_holding_invalid_type
let y = baz().await;
let _x = x;
y
Expand All @@ -30,7 +31,7 @@ async fn baz() -> u32 {
#[allow(clippy::manual_async_fn)]
fn block_bad() -> impl std::future::Future<Output = u32> {
async move {
let _x = String::from("hi!");
let _x = String::from("hi!"); //~ await_holding_invalid_type
baz().await
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ LL | let x = Ipv4Addr::new(127, 0, 0, 1);
| ^

error: `std::string::String` may not be held across an `await` point per `clippy.toml`
--> $DIR/await_holding_invalid_type/await_holding_invalid_type.rs:33:13
--> $DIR/await_holding_invalid_type/await_holding_invalid_type.rs:34:13
|
LL | let _x = String::from("hi!");
| ^^
Expand Down
1 change: 1 addition & 0 deletions tests/ui-toml/conf_deprecated_key/conf_deprecated_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
fn main() {}

#[warn(clippy::cognitive_complexity)]
//~v cognitive_complexity
fn cognitive_complexity() {
let x = vec![1, 2, 3];
for i in x {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LL | blacklisted-names = [ "..", "wibble" ]
| ^^^^^^^^^^^^^^^^^

error: the function has a cognitive complexity of (3/2)
--> $DIR/conf_deprecated_key/conf_deprecated_key.rs:6:4
--> $DIR/conf_deprecated_key/conf_deprecated_key.rs:7:4
|
LL | fn cognitive_complexity() {
| ^^^^^^^^^^^^^^^^^^^^
Expand Down
16 changes: 9 additions & 7 deletions tests/ui-toml/dbg_macro/dbg_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@
//@no-rustfix
fn foo(n: u32) -> u32 {
if let Some(n) = dbg!(n.checked_sub(4)) { n } else { n }
//~^ dbg_macro
}

fn factorial(n: u32) -> u32 {
//~v dbg_macro
if dbg!(n <= 1) {
dbg!(1)
dbg!(1) //~ dbg_macro
} else {
dbg!(n * factorial(n - 1))
dbg!(n * factorial(n - 1)) //~ dbg_macro
}
}

fn main() {
dbg!(42);
dbg!(dbg!(dbg!(42)));
foo(3) + dbg!(factorial(4));
dbg!(1, 2, dbg!(3, 4));
dbg!(1, 2, 3, 4, 5);
dbg!(42); //~ dbg_macro
dbg!(dbg!(dbg!(42))); //~ dbg_macro
foo(3) + dbg!(factorial(4)); //~ dbg_macro
dbg!(1, 2, dbg!(3, 4)); //~ dbg_macro
dbg!(1, 2, 3, 4, 5); //~ dbg_macro
}

#[test]
Expand Down
20 changes: 10 additions & 10 deletions tests/ui-toml/dbg_macro/dbg_macro.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | if let Some(n) = n.checked_sub(4) { n } else { n }
| ~~~~~~~~~~~~~~~~

error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro/dbg_macro.rs:9:8
--> $DIR/dbg_macro/dbg_macro.rs:11:8
|
LL | if dbg!(n <= 1) {
| ^^^^^^^^^^^^
Expand All @@ -23,29 +23,29 @@ LL | if n <= 1 {
| ~~~~~~

error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro/dbg_macro.rs:10:9
--> $DIR/dbg_macro/dbg_macro.rs:12:9
|
LL | dbg!(1)
| ^^^^^^^
|
help: remove the invocation before committing it to a version control system
|
LL | 1
|
| ~

error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro/dbg_macro.rs:12:9
--> $DIR/dbg_macro/dbg_macro.rs:14:9
|
LL | dbg!(n * factorial(n - 1))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: remove the invocation before committing it to a version control system
|
LL | n * factorial(n - 1)
|
| ~~~~~~~~~~~~~~~~~~~~

error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro/dbg_macro.rs:17:5
--> $DIR/dbg_macro/dbg_macro.rs:19:5
|
LL | dbg!(42);
| ^^^^^^^^
Expand All @@ -56,7 +56,7 @@ LL | 42;
| ~~

error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro/dbg_macro.rs:18:5
--> $DIR/dbg_macro/dbg_macro.rs:20:5
|
LL | dbg!(dbg!(dbg!(42)));
| ^^^^^^^^^^^^^^^^^^^^
Expand All @@ -67,7 +67,7 @@ LL | dbg!(dbg!(42));
| ~~~~~~~~~~~~~~

error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro/dbg_macro.rs:19:14
--> $DIR/dbg_macro/dbg_macro.rs:21:14
|
LL | foo(3) + dbg!(factorial(4));
| ^^^^^^^^^^^^^^^^^^
Expand All @@ -78,7 +78,7 @@ LL | foo(3) + factorial(4);
| ~~~~~~~~~~~~

error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro/dbg_macro.rs:20:5
--> $DIR/dbg_macro/dbg_macro.rs:22:5
|
LL | dbg!(1, 2, dbg!(3, 4));
| ^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -89,7 +89,7 @@ LL | (1, 2, dbg!(3, 4));
| ~~~~~~~~~~~~~~~~~~

error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro/dbg_macro.rs:21:5
--> $DIR/dbg_macro/dbg_macro.rs:23:5
|
LL | dbg!(1, 2, 3, 4, 5);
| ^^^^^^^^^^^^^^^^^^^
Expand Down
Loading