Skip to content

Allow bounds on type variables in enums & structs#13302

Closed
nrc wants to merge 1 commit into
rust-lang:masterfrom
nrc:struct-bounds
Closed

Allow bounds on type variables in enums & structs#13302
nrc wants to merge 1 commit into
rust-lang:masterfrom
nrc:struct-bounds

Conversation

@nrc

@nrc nrc commented Apr 4, 2014

Copy link
Copy Markdown
Member

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

@huonw

huonw commented Apr 4, 2014

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Member

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

@nrc

nrc commented Apr 5, 2014

Copy link
Copy Markdown
Member Author

Now with more tests.

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

nrc commented Apr 24, 2014

Copy link
Copy Markdown
Member Author

The RFC for this has been accepted.

r?

@alexcrichton

Copy link
Copy Markdown
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

flaper87 commented May 3, 2014

Copy link
Copy Markdown
Contributor

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

nrc commented May 3, 2014

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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