about summary refs log tree commit diff
path: root/compiler/rustc_metadata/src
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-05-11 16:02:20 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-05-30 08:52:25 +0000
commit4d390de4a3de9e73a51f1edfcecaf8519d94b3ee (patch)
treea8346c48e62d287cbf50406924bbc923d509473b /compiler/rustc_metadata/src
parent257f06587c7cb271517ca9a02c4ed3fd4581f71e (diff)
downloadrust-4d390de4a3de9e73a51f1edfcecaf8519d94b3ee.tar.gz
rust-4d390de4a3de9e73a51f1edfcecaf8519d94b3ee.zip
Add a helper function for checking whether a default function in a trait can be treated as `const`
Diffstat (limited to 'compiler/rustc_metadata/src')
-rw-r--r--compiler/rustc_metadata/src/rmeta/encoder.rs6
1 files changed, 2 insertions, 4 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs
index 3e647f4a50e..dad5247b2c4 100644
--- a/compiler/rustc_metadata/src/rmeta/encoder.rs
+++ b/compiler/rustc_metadata/src/rmeta/encoder.rs
@@ -892,10 +892,8 @@ fn should_encode_mir(tcx: TyCtxt<'_>, def_id: LocalDefId) -> (bool, bool) {
                 || tcx.codegen_fn_attrs(def_id).requests_inline())
                 && tcx.sess.opts.output_types.should_codegen();
             // The function has a `const` modifier or is in a `#[const_trait]`.
-            let mut is_const_fn = tcx.is_const_fn_raw(def_id.to_def_id());
-            if let Some(trait_) = tcx.trait_of_item(def_id.to_def_id()) {
-                is_const_fn = is_const_fn || tcx.has_attr(trait_, sym::const_trait);
-            }
+            let is_const_fn = tcx.is_const_fn_raw(def_id.to_def_id())
+                || tcx.is_const_default_method(def_id.to_def_id());
             let always_encode_mir = tcx.sess.opts.debugging_opts.always_encode_mir;
             (is_const_fn, needs_inline || always_encode_mir)
         }