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

const fn: Improve wording #59646

Merged
merged 3 commits into from
Apr 17, 2019
Merged

const fn: Improve wording #59646

merged 3 commits into from
Apr 17, 2019

Conversation

JohnTitor
Copy link
Member

@JohnTitor JohnTitor commented Apr 2, 2019

fixes #59611

This might need discussion. Feel free to close this PR if we don't need to fix.

@rust-highfive
Copy link
Collaborator

r? @davidtwco

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 2, 2019
@@ -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(),
Copy link
Member

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.

Copy link
Contributor

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 fns and unstable ones. This is the main point of min_const_fns... 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 fns but the nightly compiler should emphasize the difference between stable and unstable ones.

Copy link
Contributor

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`

?

Copy link
Member

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.

Copy link
Member

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).

Copy link
Member Author

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?

Copy link
Contributor

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 a const fn, but insert_fn_name_here is not stable as const fn

Copy link
Member Author

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.

@Centril
Copy link
Contributor

Centril commented Apr 2, 2019

r? @oli-obk

@rust-highfive rust-highfive assigned oli-obk and unassigned davidtwco Apr 2, 2019
@Dylan-DPC-zz
Copy link

ping from triage @oli-obk any updates?

@oli-obk
Copy link
Contributor

oli-obk commented Apr 16, 2019

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Apr 16, 2019

📌 Commit 4075415 has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 16, 2019
@bors
Copy link
Contributor

bors commented Apr 17, 2019

⌛ Testing commit 4075415 with merge 7f83a069569be0fbed78b108abecc2894bfa63d1...

@bors
Copy link
Contributor

bors commented Apr 17, 2019

💔 Test failed - checks-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 17, 2019
@rust-highfive
Copy link
Collaborator

The job dist-i586-gnu-i586-i686-musl of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[01:34:17] test iter::test_double_ended_range ... ok
[01:34:17] test iter::test_filter_try_folds ... ok
[01:34:17] test iter::test_find_map ... ok
[01:34:17] test iter::test_filter_map_fold ... ok
No output has been received in the last 30m0s, this potentially indicates a stalled build or something wrong with the build itself.
Check the details on how to adjust your build configuration on: https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received
The build has been terminated

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 @TimNN. (Feature Requests)

@Centril
Copy link
Contributor

Centril commented Apr 17, 2019

@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 17, 2019
Centril added a commit to Centril/rust that referenced this pull request Apr 17, 2019
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.
bors added a commit that referenced this pull request Apr 17, 2019
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
@bors bors merged commit 4075415 into rust-lang:master Apr 17, 2019
@JohnTitor JohnTitor deleted the improve-wording branch April 17, 2019 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Weird error message for non-const const fns
8 participants