Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 99a8cc1

Browse files
compiler-errorscuviper
authored andcommitted
Make type_of work correctly for const arg bindings
(cherry picked from commit 05267b5)
1 parent 14ff4cc commit 99a8cc1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

compiler/rustc_typeck/src/collect/type_of.rs

Lines changed: 9 additions & 3 deletions
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)