Skip to content

Commit

Permalink
Rollup merge of rust-lang#132541 - RalfJung:const-stable-extern-crate…
Browse files Browse the repository at this point in the history
…, 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`
  • Loading branch information
matthiaskrgr authored Nov 12, 2024
2 parents 33fa870 + 170e993 commit 27fe6c7
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit 27fe6c7

Please sign in to comment.