-
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-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 appliedL-nurseryLint: Currently in the nursery groupLint: Currently in the nursery group
Description
Summary
The code produced by clippy is in theory correct in my eyes, but in reality the type checker doesn't understand it.
Reproducer
I tried this code:
if let Some(id) = &v.as_class().unwrap().id {
Box::new(std::iter::once(Vertex::Span(id.span)))
} else {
Box::new(std::iter::empty())
}
I expected to see this happen: to get working code after a quick fix.
Instead, this happened: The quick fix produces the following non-working code:
v.as_class().unwrap().id.as_ref().map_or_else(
|| Box::new(std::iter::empty()),
|id| Box::new(std::iter::once(Vertex::Span(id.span))),
)
Which is invalid because:
error[E0308]: mismatched types
--> crates\oxc_linter\src\lint_adapter2.rs:217:35
|
217 | |id| Box::new(std::iter::once(Vertex::Span(id.span))),
| -------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Empty<_>`, found `Once<Vertex<'_>>`
| |
| arguments to this function are incorrect
|
= note: expected struct `std::iter::Empty<_>`
found struct `std::iter::Once<lint_adapter2::Vertex<'_>>`
note: associated function defined here
--> C:\Users\jason\.rustup\toolchains\nightly-2023-06-02-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\alloc\src\boxed.rs:215:12
|
215 | pub fn new(x: T) -> Self {
| ^^^
Version
rustc 1.72.0-nightly (d59363ad0 2023-06-01)
binary: rustc
commit-hash: d59363ad0b6391b7fc5bbb02c9ccf9300eef3753
commit-date: 2023-06-01
host: x86_64-pc-windows-msvc
release: 1.72.0-nightly
LLVM version: 16.0.4
Additional Labels
@rustbot label +I-suggestion-causes-error
mfluehr
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-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 appliedL-nurseryLint: Currently in the nursery groupLint: Currently in the nursery group