-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
The following should probably result in the lint being emitted:
#![feature(never_type)]
pub fn foo(maybe_never: Option<!>) {
match maybe_never {
Some(_never) => {
println!("foo");
}
None => {}
}
}
as _never
is matched on, and it has a diverging type.
Compare this with:
#![feature(never_type)]
pub fn foo(maybe_never: Option<!>) {
match maybe_never {
Some(never) => {
let _ = never;
println!("foo");
}
None => {}
}
}
Currently, the pattern type checking code does not care about diverges
.
We should probably avoid fixing this in typeck and have this be fixed automatically (?) by moving diverges
logic to MIR or some such.
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.