Skip to content

Commit

Permalink
fix vec.rs test, comment
Browse files Browse the repository at this point in the history
  • Loading branch information
digama0 committed Sep 4, 2023
1 parent 1317378 commit 4e0a346
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
7 changes: 3 additions & 4 deletions clippy_lints/src/loops/never_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,9 @@ fn never_loop_expr<'tcx>(
let Some(macro_call) = root_macro_call_first_node(cx, expr) &&
let Some(sym::todo_macro) = cx.tcx.get_diagnostic_name(macro_call.def_id)
{
// We return MayContinueMainLoop here because we treat `todo!()` and
// `unimplemented!()` macros as potentially containing any code,
// including a continue of the main loop. This effectively silences the lint
// whenever a loop contains one of these macros anywhere.
// We return MayContinueMainLoop here because we treat `todo!()`
// as potentially containing any code, including a continue of the main loop.
// This effectively silences the lint whenever a loop contains this macro anywhere.
NeverLoopResult::MayContinueMainLoop
} else {
result
Expand Down
1 change: 1 addition & 0 deletions tests/ui/vec.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ fn issue11075() {
stringify!($e)
};
}
#[allow(clippy::never_loop)]
for _string in [repro!(true), repro!(null)] {
unimplemented!();
}
Expand Down
1 change: 1 addition & 0 deletions tests/ui/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ fn issue11075() {
stringify!($e)
};
}
#[allow(clippy::never_loop)]
for _string in vec![repro!(true), repro!(null)] {
unimplemented!();
}
Expand Down
10 changes: 5 additions & 5 deletions tests/ui/vec.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -85,31 +85,31 @@ LL | for _ in vec![1, 2, 3] {}
| ^^^^^^^^^^^^^ help: you can use an array directly: `[1, 2, 3]`

error: useless use of `vec!`
--> $DIR/vec.rs:123:20
--> $DIR/vec.rs:124:20
|
LL | for _string in vec![repro!(true), repro!(null)] {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can use an array directly: `[repro!(true), repro!(null)]`

error: useless use of `vec!`
--> $DIR/vec.rs:140:18
--> $DIR/vec.rs:141:18
|
LL | in_macro!(1, vec![1, 2], vec![1; 2]);
| ^^^^^^^^^^ help: you can use an array directly: `[1, 2]`

error: useless use of `vec!`
--> $DIR/vec.rs:140:30
--> $DIR/vec.rs:141:30
|
LL | in_macro!(1, vec![1, 2], vec![1; 2]);
| ^^^^^^^^^^ help: you can use an array directly: `[1; 2]`

error: useless use of `vec!`
--> $DIR/vec.rs:159:14
--> $DIR/vec.rs:160:14
|
LL | for a in vec![1, 2, 3] {
| ^^^^^^^^^^^^^ help: you can use an array directly: `[1, 2, 3]`

error: useless use of `vec!`
--> $DIR/vec.rs:163:14
--> $DIR/vec.rs:164:14
|
LL | for a in vec![String::new(), String::new()] {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can use an array directly: `[String::new(), String::new()]`
Expand Down

0 comments on commit 4e0a346

Please sign in to comment.