-
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
Unify conditional-const error reporting with non-const error reporting #134732
Unify conditional-const error reporting with non-const error reporting #134732
Conversation
Some changes occurred to the CTFE machinery cc @rust-lang/wg-const-eval |
This comment has been minimized.
This comment has been minimized.
719498a
to
541be58
Compare
Please give me a chance to review before landing 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.
This looks great :) Just one minor nit.
541be58
to
db51aea
Compare
Ok this is ready now. |
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.
r=me with comment nit; the other point about whether the error is "this call is wrong" vs "this call is unstable" is pre-existing.
| | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants |
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.
Looking at this, the output seems to be slightly different than for regular calls? Specifically, we don't seem to print this note for things that can be unstably called, we only print it for things that cannot be called at all.
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.
So we don't distinguish cases where:
- The feature gate is just not enabled
- The feature gate is not enabled, and even if it were the
~const
bounds are not satisfied
I think it would be nice to distinguish those, and only have this note be present in (2.), and not (1.). In the (1.) case, it would be even better to leave a note saying something along the lines of "this functionality is not stable in consts yet".
| | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information | ||
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable |
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.
Is this the error that shows up when the function is conditionally-const and we don't have enough trait bounds to know whether it is actually const, or when it is conditionally-const and we do have the trait bounds but we need to enable a nightly feature to use it?
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 latter, but we don't distinguish the two per my comment above. I'll probably try to make this less misleading, but I'd prefer to do it as a follow-up. I think we can keep iterating on these errors as need (and as users complain).
db51aea
to
924000d
Compare
Edited the comment. @bors r=RalfJung |
…nst-error-reporting, r=RalfJung Unify conditional-const error reporting with non-const error reporting This PR unifies the error reporting between `ConditionallyConstCall` and `FnCallNonConst` so that the former will refer to syntactical sugar like operators by their sugared name, rather than calling all operators "methods". We achieve this by making the "non-const" part of the error message generic over the "non" part so we can plug in "conditionally" instead. This should ensure that as we constify traits in the standard library, we don't regress error messages for things like `==`. r? fmease or reassign
💔 Test failed - checks-actions |
@bors retry
|
@bors treeclosed=1000 happened here as well #135297 (comment) |
The job Click to see the possible cause of the failure (guessed by this bot)
|
@bors retry oh, that failure is from before the previous retry so this did nothing |
Rollup of 7 pull requests Successful merges: - rust-lang#132607 (Used pthread name functions returning result for FreeBSD and DragonFly) - rust-lang#134693 (proc_macro: Use `ToTokens` trait in `quote` macro) - rust-lang#134732 (Unify conditional-const error reporting with non-const error reporting) - rust-lang#135083 (Do not ICE when encountering predicates from other items in method error reporting) - rust-lang#135251 (Only treat plain literal patterns as short) - rust-lang#135320 (Fix typo in `#[coroutine]` gating error) - rust-lang#135321 (remove more redundant into() conversions) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#134732 - compiler-errors:unify-conditional-const-error-reporting, r=RalfJung Unify conditional-const error reporting with non-const error reporting This PR unifies the error reporting between `ConditionallyConstCall` and `FnCallNonConst` so that the former will refer to syntactical sugar like operators by their sugared name, rather than calling all operators "methods". We achieve this by making the "non-const" part of the error message generic over the "non" part so we can plug in "conditionally" instead. This should ensure that as we constify traits in the standard library, we don't regress error messages for things like `==`. r? fmease or reassign
This PR unifies the error reporting between
ConditionallyConstCall
andFnCallNonConst
so that the former will refer to syntactical sugar like operators by their sugared name, rather than calling all operators "methods". We achieve this by making the "non-const" part of the error message generic over the "non" part so we can plug in "conditionally" instead.This should ensure that as we constify traits in the standard library, we don't regress error messages for things like
==
.r? fmease or reassign