-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Remove qualify_min_const_fn
#76850
Remove qualify_min_const_fn
#76850
Conversation
e957778
to
de11a42
Compare
if self.const_checking_stopped { | ||
return; | ||
} |
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.
We could get a bit closer to the existing behavior by disabling the "stop after a single error" stuff when #![feature(const_fn)]
is enabled. However, this is temporary anyway.
13880fc
to
3e04245
Compare
r? @oli-obk Okay, I think I've done all I can to minimize the diff. After 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.
I love it, all the problems now have explicit sites "causing" them (though as you correctly noted, some should just happen in stability checking. I think some of the stability checking here was to prevent any worries about accidental stabilization.
/// Emits an error if `op` is not allowed in the given const context. | ||
pub fn non_const<O: NonConstOp>(ccx: &ConstCx<'_, '_>, op: O, span: Span) { | ||
/// Emits an error and returns `true` if `op` is not allowed in the given const context. | ||
pub fn non_const<O: NonConstOp>(ccx: &ConstCx<'_, '_>, op: O, span: Span) -> bool { |
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.
a bit too much negation going on for my taste, but inverting that can be delayed to a follow up
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.
Yeah, it's possible that this helper function should folded back into the const-checker, since the return value and (unfortunately) the unstable_in_stable
bit are unused in the post-elaboration live drop checker.
This comment has been minimized.
This comment has been minimized.
a47e76e
to
b6fe533
Compare
This may not be strictly minimal, but all unstable functions also need a `rustc_const_unstable` attribute.
This is a hack for parity with `qualify_min_const_fn`, which only emitted a single error.
b6fe533
to
08e3822
Compare
Tests are passing, and Oli has approved it, so I'm gonna add it to the queue. @bors r=oli-obk |
📌 Commit 186d148 has been approved by |
…tor, r=oli-obk Remove `qualify_min_const_fn` ~~Blocked on rust-lang#76807 (the first six commits).~~ With this PR, all checks in `qualify_min_const_fn` are replicated in `check_consts`, and the former is no longer invoked. My goal was to have as few changes to test output as possible, since making sweeping changes to the code *while* doing big batches of diagnostics updates turned out to be a headache. To this end, there's a few `HACK`s in `check_consts` to achieve parity with `qualify_min_const_fn`. The new system that replaces `is_min_const_fn` is referred to as "const-stability" My end goal for the const-stability rules is this: * Const-stability is only applicable to functions defined in `staged_api` crates. * All functions not marked `rustc_const_unstable` are considered "const-stable". - NB. This is currently not implemented. `#[unstable]` functions are also const-unstable. This causes problems when searching for feature gates. - All "const-unstable" functions have an associated feature gate * const-stable functions can only call other const-stable functions - `allow_internal_unstable` can be used to circumvent this. * All const-stable functions are subject to some additional checks (the ones that were unique to `qualify_min_const_fn`) The plan is to remove each `HACK` individually in subsequent PRs. That way, changes to error message output can be reviewed in isolation.
☀️ Test successful - checks-actions, checks-azure |
This is great. :) @ecstatic-morse do you think this would be worth documenting in https://github.com/rust-lang/const-eval/?
|
I believe it's as simple as "const-stable functions can only call other const-stable functions and cannot depend on any unstable features to pass const-checking". My parenthetical isn't very helpful, since these were only two of the dozen or so checks that were unique to |
Ah I see. Also, shouldn't a PR with this title actually delete the |
Oh, that is still open in #77128. I guess I do not understand what this PR is "removing" then, the description sounds more like it is porting all the min_const_fn checks over to the main checker (but keeps the old checks active). |
|
Blocked on #76807 (the first six commits).With this PR, all checks in
qualify_min_const_fn
are replicated incheck_consts
, and the former is no longer invoked. My goal was to have as few changes to test output as possible, since making sweeping changes to the code while doing big batches of diagnostics updates turned out to be a headache. To this end, there's a fewHACK
s incheck_consts
to achieve parity withqualify_min_const_fn
.The new system that replaces
is_min_const_fn
is referred to as "const-stability" My end goal for the const-stability rules is this:staged_api
crates.rustc_const_unstable
are considered "const-stable".#[unstable]
functions are also const-unstable. This causes problems when searching for feature gates.allow_internal_unstable
can be used to circumvent this.qualify_min_const_fn
)The plan is to remove each
HACK
individually in subsequent PRs. That way, changes to error message output can be reviewed in isolation.