-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Previously working code doesn't work on nightly (zero-sized types) #77563
Comments
This comment has been minimized.
This comment has been minimized.
Found out why, I attached the wrong playground link, where I removed the This one is the correct one. It compiles both in stable and beta, but not on nightly. |
Cc @rust-lang/wg-const-eval This code used to work accidentally, and stopped working when #75586 got fixed. Indeed the intended way to write this is what @SNCPlay42 suggested. We're sorry that this broke existing code, but there just is no good way to support that kind of code longer-term as |
Alright, it's fine. This code was written way back in Sept 2019. I'd like to point out that there exists a different workaround: struct ZST;
impl ZST {
pub const fn new() -> Self { Self }
pub const fn static_ref() -> &'static Self {
&Self
}
} as you can see there's no more function call. The only thing is that moving forward this will break code that is on stable if I'm not mistaken, right? |
yes |
Removing regression labels since this is an intended regression. |
(I edited the issue to show the correct code and the full error.) |
Closing as working-as-intended. Sorry about the accidental stabilization. We're working on more convenient ways to do the same thing. |
I tried this code (playground):
I expected to see this happen: no errors
Instead, this happened: compiler errored with:
Meta
rustc --version --verbose
:This doesn't error in stable or beta, just nightly.
I worked this around by just returning the ZST (
&Self
) instead of calling the constructor (&Self::new()
).The text was updated successfully, but these errors were encountered: