]> git.lizzy.rs Git - rust.git/commitdiff
Impl items have generics
authorOliver Scherer <github35764891676564198441@oli-obk.de>
Fri, 19 Oct 2018 10:46:16 +0000 (12:46 +0200)
committerOliver Scherer <github35764891676564198441@oli-obk.de>
Fri, 26 Oct 2018 15:27:22 +0000 (17:27 +0200)
src/librustc/util/ppaux.rs
src/librustc_mir/const_eval.rs

index 709b844526529dbbcf4fe6c6e9f196481d986075..abdd7fd8d40bf0d220ad2022d1fa47d6f12eb243 100644 (file)
@@ -251,25 +251,17 @@ fn fn_sig<F: fmt::Write>(&mut self,
     fn parameterized<F: fmt::Write>(&mut self,
                                     f: &mut F,
                                     substs: &subst::Substs<'_>,
-                                    mut did: DefId,
+                                    did: DefId,
                                     projections: &[ty::ProjectionPredicate<'_>])
                                     -> fmt::Result {
         let key = ty::tls::with(|tcx| tcx.def_key(did));
-        let mut item_name = if let Some(name) = key.disambiguated_data.data.get_opt_name() {
-            Some(name)
-        } else {
-            did.index = key.parent.unwrap_or_else(
-                || bug!("finding type for {:?}, encountered def-id {:?} with no parent",
-                        did, did));
-            self.parameterized(f, substs, did, projections)?;
-            return write!(f, "::{}", key.disambiguated_data.data.as_interned_str());
-        };
 
         let verbose = self.is_verbose;
         let mut num_supplied_defaults = 0;
         let mut has_self = false;
         let mut own_counts: GenericParamCount = Default::default();
         let mut is_value_path = false;
+        let mut item_name = Some(key.disambiguated_data.data.as_interned_str());
         let fn_trait_kind = ty::tls::with(|tcx| {
             // Unfortunately, some kinds of items (e.g., closures) don't have
             // generics. So walk back up the find the closest parent that DOES
@@ -282,6 +274,7 @@ fn parameterized<F: fmt::Write>(&mut self,
                     DefPathData::AssocTypeInImpl(_) |
                     DefPathData::AssocExistentialInImpl(_) |
                     DefPathData::Trait(_) |
+                    DefPathData::Impl |
                     DefPathData::TypeNs(_) => {
                         break;
                     }
@@ -292,7 +285,6 @@ fn parameterized<F: fmt::Write>(&mut self,
                     }
                     DefPathData::CrateRoot |
                     DefPathData::Misc |
-                    DefPathData::Impl |
                     DefPathData::Module(_) |
                     DefPathData::MacroDef(_) |
                     DefPathData::ClosureExpr |
index 362fbc4b1355b65b605711e5f769510d0317356d..d92001704285a84a34240e63dc5846faad6aaa0d 100644 (file)
@@ -612,6 +612,13 @@ pub fn const_eval_raw_provider<'a, 'tcx>(
             other => return other,
         }
     }
+    // the first trace is for replicating an ice
+    // There's no tracking issue, but the next two lines concatenated link to the discussion on
+    // zulip. It's not really possible to test this, because it doesn't show up in diagnostics
+    // or MIR.
+    // https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/
+    // subject/anon_const_instance_printing/near/135980032
+    trace!("const eval: {}", key.value.instance);
     trace!("const eval: {:?}", key);
 
     let cid = key.value;