-
-
Notifications
You must be signed in to change notification settings - Fork 16.1k
yeet alias new_from_def_id #162760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
yeet alias new_from_def_id #162760
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,33 +73,37 @@ pub(crate) fn as_constant_inner<'tcx>( | |
| } | ||
| ExprKind::NamedConst { def_id, args, ref user_ty } => { | ||
| let user_ty = user_ty.as_ref().and_then(push_cuta); | ||
|
|
||
| // Under generic_const_args, `def_id` might be a regular const declared in a trait, but | ||
| // is `impl`d as a directly represented const. We do not know whether it is here, so we | ||
| // must use type system normalization for all consts under generic_const_args. | ||
| // FIXME(generic_const_args): there's a lot to consider here! `Const::Ty` uses valtrees | ||
| // and `Const::Unevaluated` does not, we should revisit this before stabilization. | ||
| let def_kind = tcx.def_kind(def_id); | ||
| if tcx.features().generic_const_args() | ||
| || matches!(tcx.def_kind(def_id), DefKind::Const | DefKind::AssocConst) | ||
| || matches!(def_kind, DefKind::Const | DefKind::AssocConst) | ||
| && tcx.is_direct_const(def_id) | ||
| { | ||
| let uneval = ty::AliasConst::new( | ||
| tcx, | ||
| ty::AliasConstKind::new_from_def_id( | ||
| tcx, | ||
| def_id, | ||
| ty::AliasConstInherentArgsKind::Impl, | ||
| ), | ||
| args, | ||
| ); | ||
| let ct = ty::Const::new_alias(tcx, ty::IsRigid::No, uneval); | ||
|
|
||
| let kind = match def_kind { | ||
| DefKind::AssocConst => { | ||
| if let DefKind::Impl { of_trait: false } = tcx.def_kind(tcx.parent(def_id)) | ||
| { | ||
| ty::AliasConstKind::InherentImpl { def_id } | ||
| } else { | ||
| ty::AliasConstKind::Projection { def_id } | ||
| } | ||
| } | ||
| DefKind::Const => ty::AliasConstKind::Free { def_id }, | ||
| _ => unreachable!(), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reachable via #162923 Its always better here to print the actual Defkind or whatever we are not expecting to be reachable as this makes categorizing the ICE a bit easier imho :)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. aaaah sorry!! #162937 |
||
| }; | ||
| let alias = ty::AliasConst::new(tcx, kind, args); | ||
| let ct = ty::Const::new_alias(tcx, ty::IsRigid::No, alias); | ||
| let const_ = Const::Ty(ty, ct); | ||
| return ConstOperand { span, user_ty, const_ }; | ||
| } | ||
|
|
||
| let uneval = mir::UnevaluatedConst::new(def_id, args); | ||
| let const_ = Const::Unevaluated(uneval, ty); | ||
|
|
||
| ConstOperand { user_ty, span, const_ } | ||
| } | ||
| ExprKind::ConstParam { param, def_id: _ } => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we reword this?