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

Allow bounds on type variables in enums & structs #13302

Closed
wants to merge 1 commit into from

Conversation

nrc
Copy link
Member

@nrc nrc commented Apr 4, 2014

Does not do any checking of bounds, just allows them to exist. Checking will come later

@huonw
Copy link
Member

huonw commented Apr 4, 2014

It might be good to have a negative test like:

struct Foo<X: TraitDoesntExist>;
enum Bar<X: TraitDoesntExist> {}

trait Trait<T> {}

struct Baz<X: Trait<Invalid>>;
enum Qux<X: Trait<Invalid>> {}

trait Trait2<'a> {}

struct Baz2<X: Trait<'a>>;
enum Quz2<X: Trait<'a>>;

fn main() {}

just making sure that the bounds are being resolved correctly (i.e. the non-existent traits/params/lifetimes are being correctly error about).

I guess having a (valid) struct S<'a, X: Trait<'a>>; might be good too?

@alexcrichton
Copy link
Member

Note that the corresponding RFC has not yet been merged. This should likely wait until it is merged.

@nrc
Copy link
Member Author

nrc commented Apr 5, 2014

Now with more tests.

Does not do any checking of bounds, just allows them to exist.
@nrc
Copy link
Member Author

nrc commented Apr 24, 2014

The RFC for this has been accepted.

r?

@alexcrichton
Copy link
Member

Like the RFC, I'm not sure how useful or expected this is unless the type bounds themselves are checked. I don't think that we're gaining much by merging this before the type bounds are checked, and it seems small enough (surprisingly!). Perhaps merging this should wait until the type checking has been implemented?

@flaper87
Copy link
Contributor

flaper87 commented May 3, 2014

I agree with @alexcrichton It may be confusing to be able to specify type bounds and then realize they're not checked. Lets wait for the type checking to be implemented.

@nrc
Copy link
Member Author

nrc commented May 3, 2014

Yeah, it is not useful until we do the checking. But we do need it for that. Happy to wait for the checking before we land this.

@alexcrichton
Copy link
Member

OK, in that case I'm going to close this for now until the checking is implemented as well.

compiler-errors pushed a commit to compiler-errors/rust that referenced this pull request Oct 26, 2022
Don't auto-publish lib crates

I believe this should *just* work? With this cargo-workspaces should not consider them
Jarcho pushed a commit to Jarcho/rust that referenced this pull request Aug 24, 2024
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

Successfully merging this pull request may close these issues.

4 participants