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
Only bar compiles. foo produces the following compiler error:
error[E0308]: mismatched types
--> src/main.rs:9:5
|
4 | fn foo<T1, T2, E>(a: T1) -> Result<T2, E>
| -- ------------- expected `Result<T2, E>` because of return type
| |
| expected this type parameter
...
9 | a.try_into()
| ^^^^^^^^^^^^ expected `Result<T2, E>`, found `Result<usize, ...>`
|
= note: expected enum `Result<T2, E>`
found enum `Result<usize, <T1 as TryInto<usize>>::Error>`
For more information about this error, try `rustc --explain E0308`.
I also tried compiling with the new trait solver (rustc -Znext-solver src/main.rs) and get the same error message. I am not 100% sure if that means that I am compiling it the wrong way or if the output is just identical.
fmease
added
A-traits
Area: Trait system
T-types
Relevant to the types team, which will review and decide on the PR/issue.
and removed
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
labels
Nov 20, 2024
I tried this code:
I expected to see this happen:
Both functions should compile.
Instead, this happened:
Only
bar
compiles.foo
produces the following compiler error:I also tried compiling with the new trait solver (
rustc -Znext-solver src/main.rs
) and get the same error message. I am not 100% sure if that means that I am compiling it the wrong way or if the output is just identical.Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: