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

min_const_generics prevents references to concrete Self param #75486

Closed
lcnr opened this issue Aug 13, 2020 · 5 comments · Fixed by #76195
Closed

min_const_generics prevents references to concrete Self param #75486

lcnr opened this issue Aug 13, 2020 · 5 comments · Fixed by #76195
Labels
C-bug Category: This is a bug.

Comments

@lcnr
Copy link
Contributor

lcnr commented Aug 13, 2020

👋 I'm trying to understand the limitations of min_const_generics. Is it expected that https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=59cca2f3891e9fa921afdcbcda9f2588 compiles ok without min_const_generics, but fails with it?

Originally posted by @alex in #74878 (comment)

@lcnr lcnr added C-bug Category: This is a bug. F-min_const_generics labels Aug 13, 2020
@lcnr
Copy link
Contributor Author

lcnr commented Aug 13, 2020

We should not break stable code and change the generic parameters must not be used inside of non trivial constant values check to only run for const parameters.

So this is a bug of the current min_const_generics implementation.

@alex
Copy link
Member

alex commented Aug 13, 2020

Thank @lcnr! Sorry about the noise on the tracking bug!

@alex
Copy link
Member

alex commented Aug 13, 2020

FWIW, I was able to work around this in my own code by replacing mem::size_of::<Self>() with mem::size_of::<what self is>(): https://github.com/alex/rust-asn1/compare/ee5e5b48b5c765b8d460dc1b44b7716c59325706..bc7be1da41d86e99b602c8df66c320f8edc01f63

@varkor
Copy link
Member

varkor commented Aug 21, 2020

Self might be special enough that we can make this work in general, rather than limiting the scope of the generic parameters must not be used… error, because the parameter is effectively fixed. At the very least, we should have a better error message, because Self is not thought of as a generic parameter to users.

@lcnr
Copy link
Contributor Author

lcnr commented Aug 21, 2020

We should be able to fix this, so I am not too worried about this yet

Will try to do so next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants