From 7cd1fa7fa59c9f1f9727aa354def9583ccb2fc8f Mon Sep 17 00:00:00 2001 From: David Wood Date: Wed, 5 Mar 2025 04:29:41 +0000 Subject: [PATCH] passes: propagate unstability for traits Unstability is propagated when staged API is not used and `-Zforce-unstable-if-unmarked` is, but this only happened for const functions not const traits, which ends up being an issue for some of the minicore tests of codegen backends when introducing the sizedness traits. --- compiler/rustc_passes/src/stability.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index 0fcf6a80ec4de..c6d26f99ab946 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -155,7 +155,10 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { if let Some(stab) = self.parent_stab { if inherit_deprecation.yes() && stab.is_unstable() { self.index.stab_map.insert(def_id, stab); - if fn_sig.is_some_and(|s| s.header.is_const()) { + let is_const = fn_sig.is_some_and(|s| s.header.is_const()) + || (self.tcx.def_kind(def_id) == DefKind::Trait + && self.tcx.is_const_trait(def_id.to_def_id())); + if is_const { self.index.const_stab_map.insert( def_id, ConstStability::unmarked(const_stability_indirect, stab),