Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative bounds (with feature gate) #129

Open
yoshuawuyts opened this issue Jul 4, 2023 · 0 comments
Open

Negative bounds (with feature gate) #129

yoshuawuyts opened this issue Jul 4, 2023 · 0 comments

Comments

@yoshuawuyts
Copy link
Member

yoshuawuyts commented Jul 4, 2023

A counterpart to #73 enabling negative bounds checking. Currently the impl in the compiler is being reworked to make use of the new trait solver (rust-lang/rust#112875). Despite the feature being unstable it would be great if MIR formality could model these rules.

Example

Negative bounds should only match on types which have negative trait impls. This example implements FooTrait for CoreStruct because CoreStruct implements !CoreTrait:

crate core {
    trait CoreTrait<> where [] {}
    struct CoreStruct<> where [] {}
    impl<> !CoreTrait<> for CoreStruct<> where [] {}
}
crate foo {
    trait FooTrait<> where [] {}
    impl<ty T> FooTrait<> for T where [T: !CoreTrait<>] {}
}

note: When converting this into a test some assertion should be written to ensure that CoreStruct actually implements FooTrait.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant