Make type_of work correctly for const arg bindings
This commit is contained in:
parent
cca48285b8
commit
05267b5a50
1 changed files with 9 additions and 3 deletions
|
@ -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)
|
tcx.adt_def(tcx.hir().get_parent_item(hir_id)).repr().discr_type().to_ty(tcx)
|
||||||
}
|
}
|
||||||
|
|
||||||
Node::TypeBinding(binding @ &TypeBinding { hir_id: binding_id, .. })
|
Node::TypeBinding(
|
||||||
if let Node::TraitRef(trait_ref) =
|
binding @ &TypeBinding {
|
||||||
tcx.hir().get(tcx.hir().get_parent_node(binding_id)) =>
|
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 {
|
let Some(trait_def_id) = trait_ref.trait_def_id() else {
|
||||||
return tcx.ty_error_with_message(DUMMY_SP, "Could not find trait");
|
return tcx.ty_error_with_message(DUMMY_SP, "Could not find trait");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue