diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2022-03-13 11:12:50 +0100 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2022-03-31 18:33:46 +0200 |
| commit | 15b2d1a97c9cefe41bcb61d5faef5682c112172a (patch) | |
| tree | 01f54641d17651da7078f54e0f531d24068570cb /compiler/rustc_metadata/src | |
| parent | e62f4838424208f0f980f6bf95d17610694c80d4 (diff) | |
| download | rust-15b2d1a97c9cefe41bcb61d5faef5682c112172a.tar.gz rust-15b2d1a97c9cefe41bcb61d5faef5682c112172a.zip | |
Merge impl_constness and is_const_fn_raw.
Diffstat (limited to 'compiler/rustc_metadata/src')
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/decoder.rs | 14 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/encoder.rs | 4 |
3 files changed, 4 insertions, 15 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index 388d36e2766..046322a42d8 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -14,7 +14,6 @@ use rustc_data_structures::sync::{Lock, LockGuard, Lrc, OnceCell}; use rustc_data_structures::unhash::UnhashMap; use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind}; use rustc_expand::proc_macro::{AttrProcMacro, BangProcMacro, ProcMacroDerive}; -use rustc_hir as hir; use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res}; use rustc_hir::def_id::{CrateNum, DefId, DefIndex, CRATE_DEF_INDEX, LOCAL_CRATE}; use rustc_hir::definitions::{DefKey, DefPath, DefPathData, DefPathHash}; @@ -1419,19 +1418,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { } } - // This replicates some of the logic of the crate-local `is_const_fn_raw` query, because we - // don't serialize constness for tuple variant and tuple struct constructors. - fn is_const_fn_raw(self, id: DefIndex) -> bool { - let constness = match self.kind(id) { - EntryKind::AssocFn(_) | EntryKind::Fn | EntryKind::ForeignFn => { - self.root.tables.impl_constness.get(self, id).unwrap().decode(self) - } - EntryKind::Variant(..) | EntryKind::Struct(..) => hir::Constness::Const, - _ => hir::Constness::NotConst, - }; - constness == hir::Constness::Const - } - fn is_foreign_item(self, id: DefIndex) -> bool { match self.kind(id) { EntryKind::ForeignStatic | EntryKind::ForeignFn => true, diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index 87ea041b432..cd3a1d72d41 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -163,7 +163,6 @@ provide! { <'tcx> tcx, def_id, other, cdata, associated_item_def_ids => { cdata.get_associated_item_def_ids(tcx, def_id.index) } associated_item => { cdata.get_associated_item(def_id.index) } inherent_impls => { cdata.get_inherent_implementations_for_type(tcx, def_id.index) } - is_const_fn_raw => { cdata.is_const_fn_raw(def_id.index) } is_foreign_item => { cdata.is_foreign_item(def_id.index) } item_attrs => { tcx.arena.alloc_from_iter(cdata.get_item_attrs(def_id.index, tcx.sess)) } trait_of_item => { cdata.get_trait_of_item(def_id.index) } diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 648a7972cbb..6c758b8e5b6 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1048,6 +1048,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { }; record!(self.tables.kind[def_id] <- EntryKind::Variant(self.lazy(data))); + record!(self.tables.impl_constness[def_id] <- hir::Constness::Const); record!(self.tables.children[def_id] <- variant.fields.iter().map(|f| { assert!(f.did.is_local()); f.did.index @@ -1077,6 +1078,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { }; record!(self.tables.kind[def_id] <- EntryKind::Variant(self.lazy(data))); + record!(self.tables.impl_constness[def_id] <- hir::Constness::Const); self.encode_item_type(def_id); if variant.ctor_kind == CtorKind::Fn { record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id)); @@ -1155,6 +1157,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { }; record!(self.tables.repr_options[def_id] <- adt_def.repr()); + record!(self.tables.impl_constness[def_id] <- hir::Constness::Const); record!(self.tables.kind[def_id] <- EntryKind::Struct(self.lazy(data))); self.encode_item_type(def_id); if variant.ctor_kind == CtorKind::Fn { @@ -1417,6 +1420,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { hir::ItemKind::Struct(ref struct_def, _) => { let adt_def = self.tcx.adt_def(def_id); record!(self.tables.repr_options[def_id] <- adt_def.repr()); + record!(self.tables.impl_constness[def_id] <- hir::Constness::Const); // Encode def_ids for each field and method // for methods, write all the stuff get_trait_method |
