diff options
| author | Michael Goulet <michael@errs.io> | 2022-09-26 23:44:43 +0000 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2022-10-06 10:07:34 -0700 |
| commit | 99a8cc16d83c209a2886dcff049fe8382c5be0bd (patch) | |
| tree | 619131e4c496ad098ce8dacec3d63ea0a88fe8d4 /compiler | |
| parent | 14ff4cc94aacdcf7c2082f3c8b625adef0fe4989 (diff) | |
| download | rust-99a8cc16d83c209a2886dcff049fe8382c5be0bd.tar.gz rust-99a8cc16d83c209a2886dcff049fe8382c5be0bd.zip | |
Make type_of work correctly for const arg bindings
(cherry picked from commit 05267b5a50bfa3952fe2a4433f4e12a93e15dd22)
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_typeck/src/collect/type_of.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/compiler/rustc_typeck/src/collect/type_of.rs b/compiler/rustc_typeck/src/collect/type_of.rs index 7239ea028ab..16e995b02fe 100644 --- a/compiler/rustc_typeck/src/collect/type_of.rs +++ b/compiler/rustc_typeck/src/collect/type_of.rs @@ -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"); |
