a-mir-formality icon indicating copy to clipboard operation
a-mir-formality copied to clipboard

prevent Copy and Drop impls for same type

Open nikomatsakis opened this issue 3 years ago • 2 comments

According to https://doc.rust-lang.org/reference/special-types-and-traits.html#copy one also has to check that Drop is not implemented for a type that implements Copy. As far as I can tell this can't be stated currently as there is no logical negation nor a predicate that asserts that a trait is not implemented.

Originally posted by @ltentrup in https://github.com/nikomatsakis/a-mir-formality/issues/10#issuecomment-1107448775

nikomatsakis avatar May 02 '22 18:05 nikomatsakis

We probably want to add a (not-provable Goal) goal into the solver so that we can express this -- but I wouldn't want that exposed as a where-clause.

nikomatsakis avatar May 02 '22 18:05 nikomatsakis

This seems closely related to coherence checks: coherence means something like Implemented T -> Implemented U -> T = U while copy/drop has the form Implemented T -> Implemented U -> False so I imagine that the same techniques can be used in both cases (two trait implementations in negative position)

digama0 avatar May 04 '22 17:05 digama0