Diagnostic and cause
LinkDuplicate protocol implementation
- Family
- topaz
- Phase
- check
- Code
TPZ5521
Cause and conditions
Each nominal type has at most one conformance to a given protocol. Repeating a derives entry or adding another implementation of the same conformance is rejected with TPZ5521.
Related rule: Duplicate protocol implementationResponse
Keep one implementation of the protocol for that type. Remove the duplicate derives entry or manual implementation.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 818-827 - compiler/crates/topaz_self_frontend/topaz/checker/diagnostics_derives.tpz at
151141d7bb44· 274-274 - compiler/crates/topaz_self_frontend/topaz/checker/protocols_methods.tpz at
151141d7bb44· 618-618 - compiler/crates/topaz_self_frontend/topaz/checker/diagnostics_derives.tpz at
151141d7bb44· 249-278 - compiler/crates/topaz_self_frontend/topaz/checker/protocols_methods.tpz at
151141d7bb44· 600-623
Compiler phase: check.
Compiler explanation: The same type already conforms to the same protocol.
Message templates. The marker ⟨value⟩ stands for text computed for the reported program.
⟨value⟩conformance to⟨value⟩⟨value⟩; a conformance must be unique Source⟨value⟩already conforms to⟨value⟩⟨value⟩; a conformance must be unique Source
Observed for the candidate in Topaz 5.21.3. Execution
- error[TPZ5521]:
Itemconformance toShowis derived more than once; a conformance must be unique
Each nominal type has at most one conformance to a given protocol. Repeating a derives entry or adding another implementation of the same conformance is rejected with TPZ5521.
Duplicate protocol implementation
Each nominal type has at most one conformance to a given protocol. Repeating a derives entry or adding another implementation of the same conformance is rejected with TPZ5521.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/checker/diagnostics_derives.tpz at
151141d7bb44· 249-278 - compiler/crates/topaz_self_frontend/topaz/checker/protocols_methods.tpz at
151141d7bb44· 600-623
Response
LinkKeep one implementation of the protocol for that type. Remove the duplicate derives entry or manual implementation.
Reproduction and verification
LinkRejected program
Linkrecord Item derives Show, Show { value: int }
No stdout.
Expected result
Source evidence
- compiler/crates/topaz_self_frontend/topaz/checker/diagnostics_derives.tpz at
151141d7bb44· 249-278 - compiler/crates/topaz_self_frontend/topaz/checker/protocols_methods.tpz at
151141d7bb44· 600-623
Repaired program
Linkrecord Item derives Show { value: int }
Expected result
Expected result
Checking accepts the program. Exit code 0.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/checker/diagnostics_derives.tpz at
151141d7bb44· 249-278 - compiler/crates/topaz_self_frontend/topaz/checker/protocols_methods.tpz at
151141d7bb44· 600-623