about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src
diff options
context:
space:
mode:
authorDeadbeef <ent3rm4n@gmail.com>2025-02-07 21:58:08 +0800
committerDeadbeef <ent3rm4n@gmail.com>2025-02-27 04:56:27 +0000
commitef66cbb27bc2a911edf4541e1c56102dc03e42d9 (patch)
tree5fb460c1ecc5ad46a2cf26261facbc965ea55edb /compiler/rustc_const_eval/src
parent00f245915b0c7839d42c26f9628220c4f1b93bf6 (diff)
downloadrust-ef66cbb27bc2a911edf4541e1c56102dc03e42d9.tar.gz
rust-ef66cbb27bc2a911edf4541e1c56102dc03e42d9.zip
require trait impls to have matching const stabilities as the traits
Diffstat (limited to 'compiler/rustc_const_eval/src')
-rw-r--r--compiler/rustc_const_eval/src/check_consts/mod.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_const_eval/src/check_consts/mod.rs b/compiler/rustc_const_eval/src/check_consts/mod.rs
index 659d4a30456..607cb2e497d 100644
--- a/compiler/rustc_const_eval/src/check_consts/mod.rs
+++ b/compiler/rustc_const_eval/src/check_consts/mod.rs
@@ -94,6 +94,11 @@ pub fn rustc_allow_const_fn_unstable(
 /// world into two functions: those that are safe to expose on stable (and hence may not use
 /// unstable features, not even recursively), and those that are not.
 pub fn is_fn_or_trait_safe_to_expose_on_stable(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
+    // A default body in a `#[const_trait]` is const-stable when the trait is const-stable.
+    if tcx.is_const_default_method(def_id) {
+        return is_fn_or_trait_safe_to_expose_on_stable(tcx, tcx.parent(def_id));
+    }
+
     match tcx.lookup_const_stability(def_id) {
         None => {
             // In a `staged_api` crate, we do enforce recursive const stability for all unmarked