Skip to content

Regression in Error conversion from Infallible #66757

@alexcrichton

Description

@alexcrichton

The following code:

use std::convert::{TryFrom, Infallible}; struct E; impl From<Infallible> for E { fn from(_: Infallible) -> E { E } } fn foo() -> Result<(), E> { u32::try_from(1u32)?; Ok(()) }

compiles on stable but fails to compile on nightly with:

error[E0277]: `?` couldn't convert the error to `E` --> src/lib.rs:13:24 | 13 | u32::try_from(1u32)?; | ^ the trait `std::convert::From<()>` is not implemented for `E` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = help: the following implementations were found: <E as std::convert::From<!>> = note: required by `std::convert::From::from` 

This was discovered through bytecodealliance/wasmtime#633

Metadata

Metadata

Assignees

No one assigned

    Labels

    P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions