about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2019-11-30 18:17:38 +0100
committerOliver Scherer <github35764891676564198441@oli-obk.de>2019-12-03 10:20:15 +0100
commite2bbf0647aa1e78802607dc74d906b94ea127999 (patch)
treefcd73aaf1c7315d4e0ed454c88e99681b0d84b35
parentd9cca74ffc0e5bdd2949d73a08945137171abb58 (diff)
downloadrust-e2bbf0647aa1e78802607dc74d906b94ea127999.tar.gz
rust-e2bbf0647aa1e78802607dc74d906b94ea127999.zip
Explain why "loading" constness from extern crates does not necessarily load anything
-rw-r--r--src/librustc_metadata/rmeta/decoder.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/librustc_metadata/rmeta/decoder.rs b/src/librustc_metadata/rmeta/decoder.rs
index b494c9bdd38..6edd17fe9ab 100644
--- a/src/librustc_metadata/rmeta/decoder.rs
+++ b/src/librustc_metadata/rmeta/decoder.rs
@@ -1360,11 +1360,15 @@ impl<'a, 'tcx> CrateMetadata {
         }
     }
 
+    // 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::Method(data) => data.decode(self).fn_data.constness,
             EntryKind::Fn(data) => data.decode(self).constness,
-            // Some intrinsics can be const fn
+            // Some intrinsics can be const fn. While we could recompute this (at least until we
+            // stop having hardcoded whitelists and move to stability attributes), it seems cleaner
+            // to treat all const fns equally.
             EntryKind::ForeignFn(data) => data.decode(self).constness,
             EntryKind::Variant(..) | EntryKind::Struct(..) => hir::Constness::Const,
             _ => hir::Constness::NotConst,