Skip to content

Commit 410ee6d

Browse files
authored
Unrolled build for rust-lang#129818
Rollup merge of rust-lang#129818 - RalfJung:const-stability, r=compiler-errors make the const-unstable-in-stable error more clear The default should be to add `rustc_const_unstable`, not `rustc_allow_const_fn_unstable`. Also I discovered our check for missing const stability attributes on stable functions -- but strangely that check only kicks in for "reachable" functions. `check_missing_stability` checks for reachability since all reachable functions must have a stability attribute, but I would say if a function has `#[stable]` it should also have const-stability attributes regardless of reachability.
2 parents d571ae8 + 3cec2d6 commit 410ee6d

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

compiler/rustc_const_eval/messages.ftl

+2-2
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,8 @@ const_eval_unstable_const_fn = `{$def_path}` is not yet stable as a const fn
415415
416416
const_eval_unstable_in_stable =
417417
const-stable function cannot use `#[feature({$gate})]`
418-
.unstable_sugg = if it is not part of the public API, make this function unstably const
419-
.bypass_sugg = otherwise `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (but requires team approval)
418+
.unstable_sugg = if the function is not (yet) meant to be stable, make this function unstably const
419+
.bypass_sugg = otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (but requires team approval)
420420
421421
const_eval_unterminated_c_string =
422422
reading a null-terminated string starting at {$pointer} with no null found before end of allocation

compiler/rustc_passes/src/stability.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -544,9 +544,8 @@ impl<'tcx> MissingStabilityAnnotations<'tcx> {
544544
let is_stable =
545545
self.tcx.lookup_stability(def_id).is_some_and(|stability| stability.level.is_stable());
546546
let missing_const_stability_attribute = self.tcx.lookup_const_stability(def_id).is_none();
547-
let is_reachable = self.effective_visibilities.is_reachable(def_id);
548547

549-
if is_const && is_stable && missing_const_stability_attribute && is_reachable {
548+
if is_const && is_stable && missing_const_stability_attribute {
550549
let descr = self.tcx.def_descr(def_id.to_def_id());
551550
self.tcx.dcx().emit_err(errors::MissingConstStabAttr { span, descr });
552551
}

tests/ui/consts/min_const_fn/min_const_fn_libstd_stability.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ error: const-stable function cannot use `#[feature(const_refs_to_cell)]`
2020
LL | x.get();
2121
| ^
2222
|
23-
help: if it is not part of the public API, make this function unstably const
23+
help: if the function is not (yet) meant to be stable, make this function unstably const
2424
|
2525
LL + #[rustc_const_unstable(feature = "...", issue = "...")]
2626
LL | const fn bar3() -> u32 {
2727
|
28-
help: otherwise `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (but requires team approval)
28+
help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (but requires team approval)
2929
|
3030
LL + #[rustc_allow_const_fn_unstable(const_refs_to_cell)]
3131
LL | const fn bar3() -> u32 {

0 commit comments

Comments
 (0)