-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
forbid conditional, negative impls #79098
Copy link
Copy link
Open
Labels
F-negative_impls#![feature(negative_impls)]#![feature(negative_impls)]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
F-negative_impls#![feature(negative_impls)]#![feature(negative_impls)]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.
We currently permit negative impls (feature-gated, #68318) for both auto- and regular traits. However, the semantics of negative impls are somewhat unresolved. The current trait checker's implementation in particular does not work well with "conditional" negative impls -- in other words, negative impls that do not apply to all instances of a type. Further, the semantics of such impls when combined with auto traits are not fully agreed upon.
Consider:
The question is, does
Bar<Box<T>>implementFoo? There is some disagreement about what would be expected here.As a temporary step, the plan is to forbid impls of this kind using similar logic to what we use for
Dropimpls. There was a PR in this direction #74648.Another similar step would be to forbid negative impls for traits that have multiple generic parameters:
There is no particular reason that we can't support multiple parameters, but I suspect that the drop logic is not designed to handle cases like this.
Related issues:
negative_implsandauto_traitsexperimental features allow trait impls to overlap #74629