fix vec.rs test, comment

This commit is contained in:
Mario Carneiro 2023-09-04 06:35:51 +02:00
parent 1317378b9e
commit 4e0a3465d1
4 changed files with 10 additions and 9 deletions

View file

@ -275,10 +275,9 @@ fn never_loop_expr<'tcx>(
let Some(macro_call) = root_macro_call_first_node(cx, expr) && 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) let Some(sym::todo_macro) = cx.tcx.get_diagnostic_name(macro_call.def_id)
{ {
// We return MayContinueMainLoop here because we treat `todo!()` and // We return MayContinueMainLoop here because we treat `todo!()`
// `unimplemented!()` macros as potentially containing any code, // as potentially containing any code, including a continue of the main loop.
// including a continue of the main loop. This effectively silences the lint // This effectively silences the lint whenever a loop contains this macro anywhere.
// whenever a loop contains one of these macros anywhere.
NeverLoopResult::MayContinueMainLoop NeverLoopResult::MayContinueMainLoop
} else { } else {
result result

View file

@ -120,6 +120,7 @@ fn issue11075() {
stringify!($e) stringify!($e)
}; };
} }
#[allow(clippy::never_loop)]
for _string in [repro!(true), repro!(null)] { for _string in [repro!(true), repro!(null)] {
unimplemented!(); unimplemented!();
} }

View file

@ -120,6 +120,7 @@ fn issue11075() {
stringify!($e) stringify!($e)
}; };
} }
#[allow(clippy::never_loop)]
for _string in vec![repro!(true), repro!(null)] { for _string in vec![repro!(true), repro!(null)] {
unimplemented!(); unimplemented!();
} }

View file

@ -85,31 +85,31 @@ LL | for _ in vec![1, 2, 3] {}
| ^^^^^^^^^^^^^ help: you can use an array directly: `[1, 2, 3]` | ^^^^^^^^^^^^^ help: you can use an array directly: `[1, 2, 3]`
error: useless use of `vec!` error: useless use of `vec!`
--> $DIR/vec.rs:123:20 --> $DIR/vec.rs:124:20
| |
LL | for _string in vec![repro!(true), repro!(null)] { LL | for _string in vec![repro!(true), repro!(null)] {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can use an array directly: `[repro!(true), repro!(null)]` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can use an array directly: `[repro!(true), repro!(null)]`
error: useless use of `vec!` 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]); LL | in_macro!(1, vec![1, 2], vec![1; 2]);
| ^^^^^^^^^^ help: you can use an array directly: `[1, 2]` | ^^^^^^^^^^ help: you can use an array directly: `[1, 2]`
error: useless use of `vec!` 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]); LL | in_macro!(1, vec![1, 2], vec![1; 2]);
| ^^^^^^^^^^ help: you can use an array directly: `[1; 2]` | ^^^^^^^^^^ help: you can use an array directly: `[1; 2]`
error: useless use of `vec!` error: useless use of `vec!`
--> $DIR/vec.rs:159:14 --> $DIR/vec.rs:160:14
| |
LL | for a in vec![1, 2, 3] { LL | for a in vec![1, 2, 3] {
| ^^^^^^^^^^^^^ help: you can use an array directly: `[1, 2, 3]` | ^^^^^^^^^^^^^ help: you can use an array directly: `[1, 2, 3]`
error: useless use of `vec!` error: useless use of `vec!`
--> $DIR/vec.rs:163:14 --> $DIR/vec.rs:164:14
| |
LL | for a in vec![String::new(), String::new()] { LL | for a in vec![String::new(), String::new()] {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can use an array directly: `[String::new(), String::new()]` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can use an array directly: `[String::new(), String::new()]`