Skip to content

Commit 05267b5

Browse files
Make type_of work correctly for const arg bindings
1 parent cca4828 commit 05267b5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

compiler/rustc_hir_analysis/src/collect/type_of.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,15 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
430430
tcx.adt_def(tcx.hir().get_parent_item(hir_id)).repr().discr_type().to_ty(tcx)
431431
}
432432

433-
Node::TypeBinding(binding @ &TypeBinding { hir_id: binding_id, .. })
434-
if let Node::TraitRef(trait_ref) =
435-
tcx.hir().get(tcx.hir().get_parent_node(binding_id)) =>
433+
Node::TypeBinding(
434+
binding @ &TypeBinding {
435+
hir_id: binding_id,
436+
kind: TypeBindingKind::Equality { term: Term::Const(ref e) },
437+
..
438+
},
439+
) if let Node::TraitRef(trait_ref) =
440+
tcx.hir().get(tcx.hir().get_parent_node(binding_id))
441+
&& e.hir_id == hir_id =>
436442
{
437443
let Some(trait_def_id) = trait_ref.trait_def_id() else {
438444
return tcx.ty_error_with_message(DUMMY_SP, "Could not find trait");

0 commit comments

Comments
 (0)