about summary refs log tree commit diff
path: root/compiler/rustc_metadata
diff options
context:
space:
mode:
authorDeadbeef <ent3rm4n@gmail.com>2021-12-16 21:38:54 +0800
committerDeadbeef <ent3rm4n@gmail.com>2021-12-16 21:38:54 +0800
commit4bb65e1c79a79fadce297a41d15003c82cabf61b (patch)
tree90520b0349e83f06d95cc093ce34b140539b3a1a /compiler/rustc_metadata
parentdf89fd2063aaa060c72c81254db0b930ff379e9a (diff)
downloadrust-4bb65e1c79a79fadce297a41d15003c82cabf61b.tar.gz
rust-4bb65e1c79a79fadce297a41d15003c82cabf61b.zip
Fix default_method_body_is_const when used across crates
Diffstat (limited to 'compiler/rustc_metadata')
-rw-r--r--compiler/rustc_metadata/src/rmeta/encoder.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs
index 94e7376ddb2..75676389df7 100644
--- a/compiler/rustc_metadata/src/rmeta/encoder.rs
+++ b/compiler/rustc_metadata/src/rmeta/encoder.rs
@@ -869,8 +869,9 @@ fn should_encode_mir(tcx: TyCtxt<'_>, def_id: LocalDefId) -> (bool, bool) {
             let needs_inline = (generics.requires_monomorphization(tcx)
                 || tcx.codegen_fn_attrs(def_id).requests_inline())
                 && tcx.sess.opts.output_types.should_codegen();
-            // Only check the presence of the `const` modifier.
-            let is_const_fn = tcx.is_const_fn_raw(def_id.to_def_id());
+            // The function has a `const` modifier or is annotated with `default_method_body_is_const`.
+            let is_const_fn = tcx.is_const_fn_raw(def_id.to_def_id())
+                || tcx.has_attr(def_id.to_def_id(), sym::default_method_body_is_const);
             let always_encode_mir = tcx.sess.opts.debugging_opts.always_encode_mir;
             (is_const_fn, needs_inline || always_encode_mir)
         }