Skip to content

dead_code lint misses some expressions #46164

Closed
@canndrew

Description

@canndrew
#![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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: 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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions