-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-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-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.F-never_type`#![feature(never_type)]``#![feature(never_type)]`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
An example is the following code:
#![feature(never_type)]
use std::error::Error;
pub trait Deserialize: Sized {
fn deserialize() -> Result<Self, Box<Error>>;
}
impl Deserialize for ! {
fn deserialize() -> Result<!, Box<Error>> {
Err("oh geez")?;
panic!()
}
}
fn foo() -> Result<usize, Box<Error>> {
Deserialize::deserialize()?;
Ok(22)
}
Here, the type of Deserialize::deserialize()?
defaults to !
, making the Ok(22)
unreachable. It might be unclear to users why the Ok(22)
is unreachable since the !
-fallback happens implicitly, so it would be good to point at it with an auxiliary note on the warning. eg. something like note: unconstrained type variable fell back to !
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-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-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.F-never_type`#![feature(never_type)]``#![feature(never_type)]`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.