-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied
Description
Summary
.
Lint Name
single_element_loop
Reproducer
I tried this code:
#![feature(never_patterns)]
#![allow(incomplete_features)]
#![warn(clippy::single_element_loop)]
// edition: 2021
#[derive(Copy, Clone)]
enum Void {}
fn main() {
let res_void: Result<bool, Void> = Ok(true);
for (Ok(mut _x) | Err(!)) in [res_void] {
// sugg:
//{ let Ok(mut _x) | Err(!) = res_void;
let ptr: *const Void = std::ptr::null();
}
}
I saw this happen:
suggestion does not build:
error: top-level or-patterns are not allowed in `let` bindings
--> seloop.rs:11:11
|
11 | { let Ok(mut _x) | Err(!) = res_void;
| ^^^^^^^^^^^^^^^^^^^ help: wrap the pattern in parentheses: `(Ok(mut _x) | Err(!))`
Version
rustc 1.80.0-nightly (faefc618c 2024-05-07)
binary: rustc
commit-hash: faefc618cf48bd794cbc808448df1bf3f59f36af
commit-date: 2024-05-07
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.4
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied