You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We can't compile the actual implementation of Try for Result<T, E> in Rust 1.49
Reproducer
I tried this code:
#[lang = "sized"]traitSized{}enumResult<T,E>{#[lang = "Ok"]Ok(T),#[lang = "Err"]Err(E)}#[lang = "try"]pubtraitTry{/// The type of this value when viewed as successful.// #[unstable(feature = "try_trait", issue = "42327")]typeOk;/// The type of this value when viewed as failed.// #[unstable(feature = "try_trait", issue = "42327")]typeError;/// Applies the "?" operator. A return of `Ok(t)` means that the/// execution should continue normally, and the result of `?` is the/// value `t`. A return of `Err(e)` means that execution should branch/// to the innermost enclosing `catch`, or return from the function.////// If an `Err(e)` result is returned, the value `e` will be "wrapped"/// in the return type of the enclosing scope (which must itself implement/// `Try`). Specifically, the value `X::from_error(From::from(e))`/// is returned, where `X` is the return type of the enclosing function.#[lang = "into_result"]#[unstable(feature = "try_trait", issue = "42327")]fninto_result(self) -> Result<Self::Ok,Self::Error>;/// Wrap an error value to construct the composite result. For example,/// `Result::Err(x)` and `Result::from_error(x)` are equivalent.#[lang = "from_error"]#[unstable(feature = "try_trait", issue = "42327")]fnfrom_error(v:Self::Ok) -> Self;/// Wrap an OK value to construct the composite result. For example,/// `Result::Ok(x)` and `Result::from_ok(x)` are equivalent.#[lang = "from_ok"]#[unstable(feature = "try_trait", issue = "42327")]fnfrom_ok(v:Self::Error) -> Self;}impl<T,E>TryforResult<T,E>{typeOk = T;typeError = E;fninto_result(self) -> Result<T,E>{self}fnfrom_ok(v:T) -> Self{Result::Ok(v)}fnfrom_error(v:E) -> Self{Result::Err(v)}}
Does the code make use of any (1.49) nightly feature ?
When we pass generic types as the Self on traits they need to be handled
via a special case on fntypes, ADT's and placeholders as the type params
won't necessarily match up because of the implicit Self.
Fixes#3382
gcc/rust/ChangeLog:
* typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit): special case
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: nr2 cant handle this
* rust/compile/issue-3382.rs: New test.
Signed-off-by: Philip Herron <[email protected]>
Summary
We can't compile the actual implementation of
Try
forResult<T, E>
in Rust 1.49Reproducer
I tried this code:
Does the code make use of any (1.49) nightly feature ?
Godbolt link
Actual behavior
We get the following error:
Expected behavior
No error
GCC Version
latest master
The text was updated successfully, but these errors were encountered: