diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index c6c80e613e3..145b31842ef 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -246,7 +246,7 @@ pub trait Visitor<'ast>: Sized { macro_rules! walk_list { ($visitor: expr, $method: ident, $list: expr $(, $($extra_args: expr),* )?) => { { - #[cfg_attr(not(bootstrap), allow(for_loop_over_fallibles))] + #[cfg_attr(not(bootstrap), allow(for_loops_over_fallibles))] for elem in $list { $visitor.$method(elem $(, $($extra_args,)* )?) } diff --git a/compiler/rustc_lint/src/for_loop_over_fallibles.rs b/compiler/rustc_lint/src/for_loops_over_fallibles.rs similarity index 95% rename from compiler/rustc_lint/src/for_loop_over_fallibles.rs rename to compiler/rustc_lint/src/for_loops_over_fallibles.rs index 2253546b5d3..54f1f307ddd 100644 --- a/compiler/rustc_lint/src/for_loop_over_fallibles.rs +++ b/compiler/rustc_lint/src/for_loops_over_fallibles.rs @@ -10,7 +10,7 @@ use rustc_span::{sym, Span}; use rustc_trait_selection::traits::TraitEngineExt; declare_lint! { - /// The `for_loop_over_fallibles` lint checks for `for` loops over `Option` or `Result` values. + /// The `for_loops_over_fallibles` lint checks for `for` loops over `Option` or `Result` values. /// /// ### Example /// @@ -34,14 +34,14 @@ declare_lint! { /// The "intended" use of `IntoIterator` implementations for `Option` and `Result` is passing them to /// generic code that expects something implementing `IntoIterator`. For example using `.chain(option)` /// to optionally add a value to an iterator. - pub FOR_LOOP_OVER_FALLIBLES, + pub FOR_LOOPS_OVER_FALLIBLES, Warn, "for-looping over an `Option` or a `Result`, which is more clearly expressed as an `if let`" } -declare_lint_pass!(ForLoopOverFallibles => [FOR_LOOP_OVER_FALLIBLES]); +declare_lint_pass!(ForLoopsOverFallibles => [FOR_LOOPS_OVER_FALLIBLES]); -impl<'tcx> LateLintPass<'tcx> for ForLoopOverFallibles { +impl<'tcx> LateLintPass<'tcx> for ForLoopsOverFallibles { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { let Some((pat, arg)) = extract_for_loop(expr) else { return }; @@ -59,7 +59,7 @@ impl<'tcx> LateLintPass<'tcx> for ForLoopOverFallibles { "for loop over {article} `{ty}`. This is more readably written as an `if let` statement", ); - cx.struct_span_lint(FOR_LOOP_OVER_FALLIBLES, arg.span, |diag| { + cx.struct_span_lint(FOR_LOOPS_OVER_FALLIBLES, arg.span, |diag| { let mut warn = diag.build(msg); if let Some(recv) = extract_iterator_next_call(cx, arg) diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index ecc64511d7f..fee6e080c4f 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -52,7 +52,7 @@ mod early; mod enum_intrinsics_non_enums; mod errors; mod expect; -mod for_loop_over_fallibles; +mod for_loops_over_fallibles; pub mod hidden_unicode_codepoints; mod internal; mod late; @@ -87,7 +87,7 @@ use rustc_span::Span; use array_into_iter::ArrayIntoIter; use builtin::*; use enum_intrinsics_non_enums::EnumIntrinsicsNonEnums; -use for_loop_over_fallibles::*; +use for_loops_over_fallibles::*; use hidden_unicode_codepoints::*; use internal::*; use let_underscore::*; @@ -190,7 +190,7 @@ macro_rules! late_lint_mod_passes { $macro!( $args, [ - ForLoopOverFallibles: ForLoopOverFallibles, + ForLoopsOverFallibles: ForLoopsOverFallibles, HardwiredLints: HardwiredLints, ImproperCTypesDeclarations: ImproperCTypesDeclarations, ImproperCTypesDefinitions: ImproperCTypesDefinitions, diff --git a/library/core/tests/option.rs b/library/core/tests/option.rs index 84eb4fc0aa3..f36f7c26806 100644 --- a/library/core/tests/option.rs +++ b/library/core/tests/option.rs @@ -57,7 +57,7 @@ fn test_get_resource() { } #[test] -#[cfg_attr(not(bootstrap), allow(for_loop_over_fallibles))] +#[cfg_attr(not(bootstrap), allow(for_loops_over_fallibles))] fn test_option_dance() { let x = Some(()); let mut y = Some(5); diff --git a/src/test/ui/issues/issue-30371.rs b/src/test/ui/issues/issue-30371.rs index 880558eb5b6..eea548c482f 100644 --- a/src/test/ui/issues/issue-30371.rs +++ b/src/test/ui/issues/issue-30371.rs @@ -1,6 +1,6 @@ // run-pass #![allow(unreachable_code)] -#![allow(for_loop_over_fallibles)] +#![allow(for_loops_over_fallibles)] #![deny(unused_variables)] fn main() { diff --git a/src/test/ui/lint/for_loop_over_fallibles.stderr b/src/test/ui/lint/for_loop_over_fallibles.stderr index 56e3126dc09..96efdf85c49 100644 --- a/src/test/ui/lint/for_loop_over_fallibles.stderr +++ b/src/test/ui/lint/for_loop_over_fallibles.stderr @@ -4,7 +4,7 @@ warning: for loop over an `Option`. This is more readably written as an `if let` LL | for _ in Some(1) {} | ^^^^^^^ | - = note: `#[warn(for_loop_over_fallibles)]` on by default + = note: `#[warn(for_loops_over_fallibles)]` on by default help: to check pattern in a loop use `while let` | LL | while let Some(_) = Some(1) {} diff --git a/src/tools/clippy/tests/ui/for_loop_unfixable.rs b/src/tools/clippy/tests/ui/for_loop_unfixable.rs index 203656fa4d6..55fb3788a8b 100644 --- a/src/tools/clippy/tests/ui/for_loop_unfixable.rs +++ b/src/tools/clippy/tests/ui/for_loop_unfixable.rs @@ -8,7 +8,7 @@ clippy::for_kv_map )] #[allow(clippy::linkedlist, clippy::unnecessary_mut_passed, clippy::similar_names)] -#[allow(for_loop_over_fallibles)] +#[allow(for_loops_over_fallibles)] fn main() { let vec = vec![1, 2, 3, 4]; diff --git a/src/tools/clippy/tests/ui/for_loops_over_fallibles.rs b/src/tools/clippy/tests/ui/for_loops_over_fallibles.rs index 54661ff94f2..75cdcc02353 100644 --- a/src/tools/clippy/tests/ui/for_loops_over_fallibles.rs +++ b/src/tools/clippy/tests/ui/for_loops_over_fallibles.rs @@ -1,6 +1,6 @@ #![warn(clippy::for_loops_over_fallibles)] #![allow(clippy::uninlined_format_args)] -#![allow(for_loop_over_fallibles)] +#![allow(for_loops_over_fallibles)] fn for_loops_over_fallibles() { let option = Some(1);