Regression in Error conversion from Infallible · Issue #66757 · rust-lang/rust (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
The following code:
use std::convert::{TryFrom, Infallible};
struct E;
impl From 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