debug!("find_bound_for_assoc_item: predicates={:#?}", predicates);
- let param_hir_id = tcx.hir().local_def_id_to_hir_id(ty_param_def_id);
- let param_name = tcx.hir().ty_param_name(param_hir_id);
+ let param_name = tcx.hir().ty_param_name(ty_param_def_id);
self.one_bound_for_assoc_type(
|| {
traits::transitive_bounds_that_define_assoc_type(
assert_eq!(opt_self_ty, None);
self.prohibit_generics(path.segments);
- let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local());
- let item_id = tcx.hir().get_parent_node(hir_id);
- let item_def_id = tcx.hir().local_def_id(item_id);
+ let def_id = def_id.expect_local();
+ let item_def_id = tcx.hir().ty_param_owner(def_id);
let generics = tcx.generics_of(item_def_id);
- let index = generics.param_def_id_to_index[&def_id];
- tcx.mk_ty_param(index, tcx.hir().name(hir_id))
+ let index = generics.param_def_id_to_index[&def_id.to_def_id()];
+ tcx.mk_ty_param(index, tcx.hir().ty_param_name(def_id))
}
Res::SelfTy { trait_: Some(_), alias_to: None } => {
// `Self` in trait or type alias.
self.normalize_ty(ast_ty.span, array_ty)
}
hir::TyKind::Typeof(ref e) => {
- tcx.sess.emit_err(TypeofReservedKeywordUsed { span: ast_ty.span });
- tcx.type_of(tcx.hir().local_def_id(e.hir_id))
+ let ty = tcx.type_of(tcx.hir().local_def_id(e.hir_id));
+ let span = ast_ty.span;
+ tcx.sess.emit_err(TypeofReservedKeywordUsed {
+ span,
+ ty,
+ opt_sugg: Some((span, Applicability::MachineApplicable))
+ .filter(|_| ty.is_suggestable()),
+ });
+
+ ty
}
hir::TyKind::Infer => {
// Infer also appears as the type of arguments or return