-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
opaque type needlessly inferred to be recursive #115017
Copy link
Copy link
Open
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.Category: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]``#[feature(type_alias_impl_trait)]`T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.Category: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]``#[feature(type_alias_impl_trait)]`T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Projects
Status
Todo
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_varshere:rust/compiler/rustc_trait_selection/src/traits/project.rs
Lines 319 to 328 in 82c5732