]> git.lizzy.rs Git - rust.git/commitdiff
Explain why "loading" constness from extern crates does not necessarily load anything
authorOliver Scherer <github35764891676564198441@oli-obk.de>
Sat, 30 Nov 2019 17:17:38 +0000 (18:17 +0100)
committerOliver Scherer <github35764891676564198441@oli-obk.de>
Tue, 3 Dec 2019 09:20:15 +0000 (10:20 +0100)
src/librustc_metadata/rmeta/decoder.rs

index b494c9bdd380b824f93ccd86728adadf4f2f544f..6edd17fe9abef21599890246898ef0911678a61e 100644 (file)
@@ -1360,11 +1360,15 @@ fn get_macro(&self, id: DefIndex) -> MacroDef {
         }
     }
 
+    // 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,