opaque type needlessly inferred to be recursive #115017
Labels
A-impl-trait
Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.
C-bug
Category: This is a bug.
F-type_alias_impl_trait
`#[feature(type_alias_impl_trait)]`
T-types
Relevant to the types team, which will review and decide on the PR/issue.
The following code should compile. However we infer two conflicting hidden types,
Opaque<A> := Opaque<A>
andOpaque<B> := u8
, causing an error:Another case to show that it is not enough to naively ignore the recursive definition, as it may have different arguments (
Opaque<'a, 'b> := Opaque<'static, 'static>
).Normally when we encounter an equality
Opaque<A> == Opaque<A>
, we equate substs and never register a hidden type.The only way we infer an opaque type to be recursive in borrowck is through
replace_opaque_types_with_inference_vars
here:rust/compiler/rustc_trait_selection/src/traits/project.rs
Lines 319 to 328 in 82c5732
The text was updated successfully, but these errors were encountered: