-
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
Add long diagnostics for E0018 #24525
Conversation
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
@@ -112,6 +112,11 @@ reference when using guards or refactor the entire expression, perhaps by | |||
putting the condition inside the body of the arm. | |||
"##, | |||
|
|||
E0018: r##" | |||
The value of static and const variables must be known at the compile-time which is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/the compile-time which/compile time, which/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm don't get your point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
He means "... value of static and const variables must be known at compile time, which is ...".
And I think he's right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right ! Thanks !
55eabfc
to
3434062
Compare
Don't you need to delete the other entry too? |
@pnkfelix: Totally, thanks for noticing me ! |
3434062
to
123b7dd
Compare
And it's done ! |
☔ The latest upstream changes (presumably #24562) made this pull request unmergeable. Please resolve the merge conflicts. |
123b7dd
to
5f20141
Compare
@apasel422: Did you find another way ? For my french mind, it seems totally fine haha. |
I think the explanation needs a bit more detail to fully convey the subtlety of this error. Pointers are allowed in I think an ideal explanation for this error should cover these points:
// This is fine.
const X: u32 = 50;
const Y: *const u32 = &X;
println!("{:?}", Y);
You could also link to the RFC and the issue. |
@michaelsproul: I don't think giving links to RFC/issue was a good idea. I added your explanations. Do you find something else to correct or add ? |
E0018: r##" | ||
The value of static and const variables must be known at compile time. You | ||
can't cast an integer as a pointer because we can't know what value will be | ||
at the address. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great except for the second sentence here. I think integer as a pointer
should be pointer as an integer
and what value will be at the address
should be what value the address will take
.
91aa6cf
to
8a6980c
Compare
@michaelsproul: It's corrected ! Thanks again ! |
@GuillaumeGomez: Looks good to me 👍 |
``` | ||
|
||
Therefore, casting one of these non-constant pointers to an integer results | ||
in a non-constant integer whichs lead to this error. Example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: "whichs lead to this error" is not correct. Should be "which"
@pnkfelix: It's corrected, thanks ! |
Part of #24407.