Skip to content

Commit dbf5ee8

Browse files
committed
Fix review comments
1 parent 5dc27d2 commit dbf5ee8

2 files changed

Lines changed: 5 additions & 11 deletions

File tree

  • compiler/rustc_hir_analysis/src/hir_ty_lowering
  • src/librustdoc/clean

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
12831283
)
12841284
});
12851285

1286+
// FIXME(mgca): code duplication with other places we lower
1287+
// the rhs' of associated const bindings
12861288
let ty = projection_term.map_bound(|alias| {
12871289
tcx.type_of(alias.def_id).instantiate(tcx, alias.args)
12881290
});

src/librustdoc/clean/mod.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -468,19 +468,13 @@ fn clean_middle_term<'tcx>(
468468
fn clean_hir_term<'tcx>(
469469
assoc_item: Option<DefId>,
470470
term: &hir::Term<'tcx>,
471-
span: rustc_span::Span,
472471
cx: &mut DocContext<'tcx>,
473472
) -> Term {
474473
match term {
475474
hir::Term::Ty(ty) => Term::Type(clean_ty(ty, cx)),
476475
hir::Term::Const(c) => {
477-
let ty = if let Some(assoc_item) = assoc_item {
478-
// FIXME(generic_const_items): this should instantiate with the alias item's args
479-
cx.tcx.type_of(assoc_item).instantiate_identity()
480-
} else {
481-
Ty::new_error_with_message(cx.tcx, span, "cannot find the associated constant")
482-
};
483-
476+
// FIXME(generic_const_items): this should instantiate with the alias item's args
477+
let ty = cx.tcx.type_of(assoc_item.unwrap()).instantiate_identity();
484478
let ct = lower_const_arg_for_rustdoc(cx.tcx, c, ty);
485479
Term::Constant(clean_middle_const(ty::Binder::dummy(ct), cx))
486480
}
@@ -3164,9 +3158,7 @@ fn clean_assoc_item_constraint<'tcx>(
31643158
.associated_items(trait_did)
31653159
.find_by_ident_and_kind(cx.tcx, constraint.ident, assoc_tag, trait_did)
31663160
.map(|item| item.def_id);
3167-
AssocItemConstraintKind::Equality {
3168-
term: clean_hir_term(assoc_item, term, constraint.span, cx),
3169-
}
3161+
AssocItemConstraintKind::Equality { term: clean_hir_term(assoc_item, term, cx) }
31703162
}
31713163
hir::AssocItemConstraintKind::Bound { bounds } => AssocItemConstraintKind::Bound {
31723164
bounds: bounds.iter().filter_map(|b| clean_generic_bound(b, cx)).collect(),

0 commit comments

Comments
 (0)