Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dead_code lint misses some expressions #46164

Closed
canndrew opened this issue Nov 21, 2017 · 1 comment
Closed

dead_code lint misses some expressions #46164

canndrew opened this issue Nov 21, 2017 · 1 comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@canndrew
Copy link
Contributor

#![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)
}

In this code, the Ok(22) is unreachable. This should raise a warning but it currently doesn't.

@nikomatsakis nikomatsakis added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 21, 2017
@TimNN TimNN added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Nov 21, 2017
@nikomatsakis
Copy link
Contributor

since we decided to stabilize, this doesn't matter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants