Impl items have generics

This commit is contained in:
Oliver Scherer 2018-10-19 12:46:16 +02:00
parent 694cf75298
commit b9bd2a6008
2 changed files with 10 additions and 11 deletions

View file

@ -251,25 +251,17 @@ impl PrintContext {
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 @@ impl PrintContext {
DefPathData::AssocTypeInImpl(_) |
DefPathData::AssocExistentialInImpl(_) |
DefPathData::Trait(_) |
DefPathData::Impl |
DefPathData::TypeNs(_) => {
break;
}
@ -292,7 +285,6 @@ impl PrintContext {
}
DefPathData::CrateRoot |
DefPathData::Misc |
DefPathData::Impl |
DefPathData::Module(_) |
DefPathData::MacroDef(_) |
DefPathData::ClosureExpr |

View 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;