Skip to content

Commit

Permalink
Make type_of work correctly for const arg bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Sep 27, 2022
1 parent cca4828 commit 05267b5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions compiler/rustc_hir_analysis/src/collect/type_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,15 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
tcx.adt_def(tcx.hir().get_parent_item(hir_id)).repr().discr_type().to_ty(tcx)
}

Node::TypeBinding(binding @ &TypeBinding { hir_id: binding_id, .. })
if let Node::TraitRef(trait_ref) =
tcx.hir().get(tcx.hir().get_parent_node(binding_id)) =>
Node::TypeBinding(
binding @ &TypeBinding {
hir_id: binding_id,
kind: TypeBindingKind::Equality { term: Term::Const(ref e) },
..
},
) if let Node::TraitRef(trait_ref) =
tcx.hir().get(tcx.hir().get_parent_node(binding_id))
&& e.hir_id == hir_id =>
{
let Some(trait_def_id) = trait_ref.trait_def_id() else {
return tcx.ty_error_with_message(DUMMY_SP, "Could not find trait");
Expand Down

0 comments on commit 05267b5

Please sign in to comment.