Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d45f6db
Move some tests to more reasonable directories
c410-f3r Sep 20, 2022
8b9a1f1
Remove tuple candidate, nothing special about it
compiler-errors Oct 7, 2022
293f662
Make tests capture the error printed by a Result return
dtolnay Oct 7, 2022
fa380a8
Start uplifting `clippy::for_loops_over_fallibles`
WaffleLapkin Jul 17, 2022
d030ba5
Use structured suggestions for `for_loop_over_fallibles` lint
WaffleLapkin Jul 18, 2022
21ec99b
`for_loop_over_fallibles`: Suggest removing `.next()`
WaffleLapkin Jul 24, 2022
5dcfdbf
`for_loop_over_fallibles`: suggest `while let` loop
WaffleLapkin Jul 24, 2022
b2975ee
`for_loop_over_fallibles`: suggest using `?` in some cases
WaffleLapkin Jul 24, 2022
dd842ff
`for_loop_over_fallibles`: remove duplication from the message
WaffleLapkin Jul 24, 2022
7308564
Add a test for the `for_loop_over_fallibles` lint
WaffleLapkin Jul 24, 2022
23a7674
`for_loop_over_fallibles`: fix suggestion for "remove `.next()`" case
WaffleLapkin Jul 24, 2022
8ca57b5
`for_loop_over_fallibles`: don't use `MachineApplicable`
WaffleLapkin Jul 24, 2022
0250f02
allow or avoid for loops over option in compiler and tests
WaffleLapkin Jul 26, 2022
75ae20a
allow `for_loop_over_fallibles` in a `core` test
WaffleLapkin Jul 26, 2022
b9b2059
Edit documentation for `for_loop_over_fallibles` lint
WaffleLapkin Aug 14, 2022
6766113
remove an infinite loop
WaffleLapkin Aug 15, 2022
98e0c4d
fix `for_loop_over_fallibles` lint docs
WaffleLapkin Aug 18, 2022
9c64bb1
Fix clippy tests that trigger `for_loop_over_fallibles` lint
WaffleLapkin Aug 25, 2022
7434b9f
fixup lint name
WaffleLapkin Oct 7, 2022
40f36fa
adopt to new rustc lint api
WaffleLapkin Oct 7, 2022
5347c81
deprecate `clippy::for_loops_over_fallibles`
WaffleLapkin Oct 7, 2022
9d4edff
adopt to building infcx
WaffleLapkin Oct 7, 2022
e828ce5
Skip chained OpaqueCast when building captures.
cjgillot Oct 9, 2022
d3bd6be
Rename AssocItemKind::TyAlias to AssocItemKind::Type
compiler-errors Oct 10, 2022
7e16f9f
Rollup merge of #99696 - WaffleLapkin:uplift, r=fee1-dead
Dylan-DPC Oct 10, 2022
0c17324
Rollup merge of #102055 - c410-f3r:moar-errors, r=petrochenkov
Dylan-DPC Oct 10, 2022
58d533d
Rollup merge of #102786 - compiler-errors:no-tuple-candidate, r=lcnr
Dylan-DPC Oct 10, 2022
302bf31
Rollup merge of #102794 - dtolnay:termination, r=thomcc
Dylan-DPC Oct 10, 2022
5a09b72
Rollup merge of #102853 - cjgillot:skip-opaque-cast, r=jackh726
Dylan-DPC Oct 10, 2022
81b9d0b
Rollup merge of #102868 - compiler-errors:rename-assoc-tyalias-to-ty,…
Dylan-DPC Oct 10, 2022
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
Prev Previous commit
Next Next commit
fixup lint name
  • Loading branch information
WaffleLapkin committed Oct 9, 2022
commit 7434b9f0d1e1587dc97829ffbc65a5afdf04fb7e
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,)* )?)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand All @@ -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 };

Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_lint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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::*;
Expand Down Expand Up @@ -190,7 +190,7 @@ macro_rules! late_lint_mod_passes {
$macro!(
$args,
[
ForLoopOverFallibles: ForLoopOverFallibles,
ForLoopsOverFallibles: ForLoopsOverFallibles,
HardwiredLints: HardwiredLints,
ImproperCTypesDeclarations: ImproperCTypesDeclarations,
ImproperCTypesDefinitions: ImproperCTypesDefinitions,
Expand Down
2 changes: 1 addition & 1 deletion library/core/tests/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-30371.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// run-pass
#![allow(unreachable_code)]
#![allow(for_loop_over_fallibles)]
#![allow(for_loops_over_fallibles)]
#![deny(unused_variables)]

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/lint/for_loop_over_fallibles.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/tests/ui/for_loop_unfixable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/tests/ui/for_loops_over_fallibles.rs
Original file line number Diff line number Diff line change
@@ -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);
Expand Down