-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
On conflicting assoc item bindings in trait object types, two similar errors are emitted #150936
Copy link
Copy link
Open
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-dyn-traitArea: trait objects, vtable layoutArea: trait objects, vtable layoutD-verboseDiagnostics: Too much output caused by a single piece of incorrect code.Diagnostics: Too much output caused by a single piece of incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.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-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-dyn-traitArea: trait objects, vtable layoutArea: trait objects, vtable layoutD-verboseDiagnostics: Too much output caused by a single piece of incorrect code.Diagnostics: Too much output caused by a single piece of incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.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.
Reproducer:
Compiler output:
This only happens if the provided types are "syntactically" unequal (i.e., using
middle::Ty's==, not unification). If they're equal only the 1st one is emitted.What happens here is that the 1st diagnostic stems from our (formerly general) check we use when HIR-ty-lowering assoc item bindings and the 2nd one comes from the lowerer for trait object types, more specifically from a check that's meant to trigger in the presence of trait aliases only I'm pretty sure. I'm claiming that because the 2nd diagnostic used to say the following prior to PR #146593 / 1.92:
This was factually incorrect in this case obviously.
So why did PR #146593 generalize the wording (w/o addressing the "double" emission)? Well, that change originates from its closed predecessor #143146 where the (formerly general) check in
lower_assoc_item_constraintwas dropped entirely in favor of the one inlower_trait_object_ty, so it made sense to generalize it.