Skip to content

Allow unused_must_use on result with never type #65861

Open
@TheZoq2

Description

@TheZoq2
#![feature(never_type)]

fn will_not_fail() -> Result<i32, !> {
    Ok(5)
}

pub fn main() {
    will_not_fail();
}

This code yields a warning:

warning: unused `std::result::Result` that must be used
 --> main.rs:8:5
  |
8 |     will_not_fail();
  |     ^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_must_use)]` on by default
  = note: this `Result` may be an `Err` variant, which should be handled

However since a Result<T, !> can never have the Err branch, having to handle the resulting error seems kind of pointless. Would it be possible to disable the unused_must_use lint for this particular case?

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.F-never_type`#![feature(never_type)]`T-langRelevant to the language 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