-
Notifications
You must be signed in to change notification settings - Fork 13k
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
const fn: Improve wording #59646
const fn: Improve wording #59646
Conversation
r? @davidtwco (rust_highfive has picked a reviewer for you, use r? to override) |
@@ -326,7 +326,7 @@ fn check_terminator( | |||
abi::Abi::Rust if tcx.is_min_const_fn(def_id) => {}, | |||
abi::Abi::Rust => return Err(( | |||
span, | |||
"can only call other `min_const_fn` within a `min_const_fn`".into(), | |||
"can only call other `const` within a `const`".into(), |
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.
Something like can only call another `const fn` within a `const` block
sounds more natural.
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.
Neither this PR nor the suggestion is accurate. This is not a const block (and with rust-lang/rfcs#2632 it will not always behave in a similar fashion).
Moreover, I think we lose out on the difference between stable const fn
s and unstable ones. This is the main point of min_const_fn
s... I think we should check whether the current compiler can use unstable features and tweak the message based on that. E.g. a stable compiler can just talk about const fn
s but the nightly compiler should emphasize the difference between stable and unstable ones.
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.
Maybe change it to
can only call other stable `const fn` within a stable `const fn`
?
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.
Ah, in that case we should make the error more explicit and add a note to the unstable const fn pointing out that it is undertake.
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.
That is, it's not clear whether it's the containing function or the called function that is the problem (or both).
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.
The problem is to be used same wording without distinction, I think. Should we try to work on this?
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.
kinda both. I'm not sure how easy it is to point to the unstable const fn
, since it might be in another crate. We can just use a more verbose wording like
can only call other
const fn
within aconst fn
, butinsert_fn_name_here
is not stable asconst fn
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.
@oli-obk I changed wording.
r? @oli-obk |
ping from triage @oli-obk any updates? |
@bors r+ rollup |
📌 Commit 4075415 has been approved by |
⌛ Testing commit 4075415 with merge 7f83a069569be0fbed78b108abecc2894bfa63d1... |
💔 Test failed - checks-travis |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors retry |
const fn: Improve wording fixes rust-lang#59611 This might need discussion. Feel free to close this PR if we don't need to fix.
Rollup of 5 pull requests Successful merges: - #59128 (Emit ansi color codes in the `rendered` field of json diagnostics) - #59646 (const fn: Improve wording) - #59986 (Miri: refactor new allocation tagging) - #60003 (LLD is not supported on Darwin) - #60018 (Miri now supports entropy, but is still slow) Failed merges: r? @ghost
fixes #59611
This might need discussion. Feel free to close this PR if we don't need to fix.