-
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
Proper support for cross-crate recursive const stability checks #132541
Conversation
// `#[rustc_const_stable_indirect]` also requires a const fn | ||
#[rustc_const_stable_indirect] | ||
#[unstable(feature = "unstable", issue = "none")] | ||
pub fn not_a_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.
This regresses complaining about rustc_const_stable_indirect on non-const-fn... but keeping that error would make the code even more messy, and we also don't error for rustc_promotable on non-const-fn, so 🤷
There's an ongoing effort to redo the way we do attributes, that should hopefully make this easier in the future.
This comment has been minimized.
This comment has been minimized.
51004b7
to
8a6fd66
Compare
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
This comment has been minimized.
This comment has been minimized.
That's a tricky one... when one force-unstable-if-unmarked crate calls things from another one, how does that work? The callee crate has everything under the |
8a6fd66
to
96f9ada
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
8bf4b22
to
dbf3fba
Compare
☔ The latest upstream changes (presumably #132479) made this pull request unmergeable. Please resolve the merge conflicts. |
dbf3fba
to
a307b47
Compare
☔ The latest upstream changes (presumably #132586) made this pull request unmergeable. Please resolve the merge conflicts. |
a307b47
to
28e920a
Compare
☔ The latest upstream changes (presumably #132603) made this pull request unmergeable. Please resolve the merge conflicts. |
28e920a
to
c98d23d
Compare
The base PR landed, so this is ready to go now. :) |
c98d23d
to
6632ba1
Compare
Some changes occurred to the CTFE machinery cc @rust-lang/wg-const-eval |
…e-unstable-if-unmarked
☔ The latest upstream changes (presumably #132831) made this pull request unmergeable. Please resolve the merge conflicts. |
6632ba1
to
430a398
Compare
@@ -53,10 +53,11 @@ impl<'mir, 'tcx> ConstCx<'mir, 'tcx> { | |||
} | |||
|
|||
pub fn enforce_recursive_const_stability(&self) -> bool { | |||
// We can skip this if `staged_api` is not enabled, since in such crates | |||
// `lookup_const_stability` will always be `None`. | |||
// We can skip this if neither `staged_api` nor `-Zforrce-unstable-if-unmarked` are enabled, |
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 on the arg
r=me after really tiny nit |
430a398
to
3780496
Compare
@bors r=compiler-errors |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#131831 (extend the "if-unchanged" logic for compiler builds) - rust-lang#132541 (Proper support for cross-crate recursive const stability checks) - rust-lang#132657 (AIX: add run-make support) - rust-lang#132901 (Warn about invalid `mir-enable-passes` pass names) - rust-lang#132923 (Triagebot: Consolidate the T-compiler ad hoc assignment groups) - rust-lang#132938 (Make precise capturing suggestion machine-applicable only if it has no APITs) - rust-lang#132947 (clarify `must_produce_diag` ICE for debugging) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#132541 - RalfJung:const-stable-extern-crate, r=compiler-errors Proper support for cross-crate recursive const stability checks ~~Stacked on top of rust-lang#132492; only the last three commits are new.~~ In a crate without `staged_api` but with `-Zforce-unstable-if-unmarked`, we now subject all functions marked with `#[rustc_const_stable_indirect]` to recursive const stability checks. We require an opt-in so that by default, a crate can be built with `-Zforce-unstable-if-unmarked` and use nightly features as usual. This property is recorded in the crate metadata so when a `staged_api` crate calls such a function, it sees the `#[rustc_const_stable_indirect]` and allows it to be exposed on stable. This, finally, will let us expose `const fn` from hashbrown on stable. The second commit makes const stability more like regular stability: via `check_missing_const_stability`, we ensure that all publicly reachable functions have a const stability attribute -- both in `staged_api` crates and `-Zforce-unstable-if-unmarked` crates. To achieve this, we move around the stability computation so that const stability is computed after regular stability is done. This lets us access the final result of the regular stability computation, which we use so that `const fn` can inherit the regular stability (but only if that is "unstable"). Fortunately, this lets us get rid of an `Option` in `ConstStability`. This is the last PR that I have planned in this series. r? `@compiler-errors`
…, r=compiler-errors Proper support for cross-crate recursive const stability checks ~~Stacked on top of rust-lang#132492; only the last three commits are new.~~ In a crate without `staged_api` but with `-Zforce-unstable-if-unmarked`, we now subject all functions marked with `#[rustc_const_stable_indirect]` to recursive const stability checks. We require an opt-in so that by default, a crate can be built with `-Zforce-unstable-if-unmarked` and use nightly features as usual. This property is recorded in the crate metadata so when a `staged_api` crate calls such a function, it sees the `#[rustc_const_stable_indirect]` and allows it to be exposed on stable. This, finally, will let us expose `const fn` from hashbrown on stable. The second commit makes const stability more like regular stability: via `check_missing_const_stability`, we ensure that all publicly reachable functions have a const stability attribute -- both in `staged_api` crates and `-Zforce-unstable-if-unmarked` crates. To achieve this, we move around the stability computation so that const stability is computed after regular stability is done. This lets us access the final result of the regular stability computation, which we use so that `const fn` can inherit the regular stability (but only if that is "unstable"). Fortunately, this lets us get rid of an `Option` in `ConstStability`. This is the last PR that I have planned in this series. r? `@compiler-errors`
Stacked on top of #132492; only the last three commits are new.In a crate without
staged_api
but with-Zforce-unstable-if-unmarked
, we now subject all functions marked with#[rustc_const_stable_indirect]
to recursive const stability checks. We require an opt-in so that by default, a crate can be built with-Zforce-unstable-if-unmarked
and use nightly features as usual. This property is recorded in the crate metadata so when astaged_api
crate calls such a function, it sees the#[rustc_const_stable_indirect]
and allows it to be exposed on stable. This, finally, will let us exposeconst fn
from hashbrown on stable.The second commit makes const stability more like regular stability: via
check_missing_const_stability
, we ensure that all publicly reachable functions have a const stability attribute -- both instaged_api
crates and-Zforce-unstable-if-unmarked
crates. To achieve this, we move around the stability computation so that const stability is computed after regular stability is done. This lets us access the final result of the regular stability computation, which we use so thatconst fn
can inherit the regular stability (but only if that is "unstable"). Fortunately, this lets us get rid of anOption
inConstStability
.This is the last PR that I have planned in this series.
r? @compiler-errors