-
-
Notifications
You must be signed in to change notification settings - Fork 15.5k
type system const items via direct rhs #162179
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
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 |
|---|---|---|
|
|
@@ -929,13 +929,9 @@ pub(crate) fn check_associated_item( | |
| let ty = tcx.type_of(def_id).instantiate_identity(); | ||
| let ty = wfcx.deeply_normalize(span, Some(WellFormedLoc::Ty(def_id)), ty); | ||
| wfcx.register_wf_obligation(span, loc, ty.into()); | ||
| check_const_item(wfcx, def_id, ty); | ||
|
|
||
| let has_value = item.defaultness(tcx).has_value(); | ||
| if tcx.is_type_const(def_id) { | ||
| check_type_const(wfcx, def_id, ty, has_value)?; | ||
| } | ||
|
|
||
| if has_value { | ||
| if item.defaultness(tcx).has_value() { | ||
| let code = ObligationCauseCode::SizedConstOrStatic; | ||
| wfcx.register_bound( | ||
| ObligationCause::new(span, def_id, code), | ||
|
|
@@ -1264,17 +1260,17 @@ pub(crate) fn check_static_item<'tcx>( | |
| }) | ||
| } | ||
|
|
||
| /// Runs checks common to both free consts and associated consts | ||
| #[instrument(level = "debug", skip(wfcx))] | ||
| pub(super) fn check_type_const<'tcx>( | ||
| pub(super) fn check_const_item<'tcx>( | ||
| wfcx: &WfCheckingCtxt<'_, 'tcx>, | ||
| def_id: LocalDefId, | ||
| item_ty: Ty<'tcx>, | ||
| has_value: bool, | ||
| ) -> Result<(), ErrorGuaranteed> { | ||
|
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. why yeet the
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. no reason, there was no
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. oh lmao |
||
| ) { | ||
| let tcx = wfcx.tcx(); | ||
| let span = tcx.def_span(def_id); | ||
|
|
||
| if !tcx.features().const_param_ty_unchecked() { | ||
| if tcx.is_direct_const(def_id.into()) && !tcx.features().const_param_ty_unchecked() { | ||
| wfcx.register_bound( | ||
| ObligationCause::new(span, def_id, ObligationCauseCode::ConstParam(item_ty)), | ||
| wfcx.param_env, | ||
|
|
@@ -1283,8 +1279,8 @@ pub(super) fn check_type_const<'tcx>( | |
| ); | ||
| } | ||
|
|
||
| if has_value { | ||
| let raw_ct = tcx.const_of_item(def_id).instantiate_identity(); | ||
| if let Some(direct_rhs) = tcx.const_of_item(def_id) { | ||
| let raw_ct = direct_rhs.instantiate_identity(); | ||
| let norm_ct = wfcx.deeply_normalize(span, Some(WellFormedLoc::Ty(def_id)), raw_ct); | ||
| wfcx.register_wf_obligation(span, Some(WellFormedLoc::Ty(def_id)), norm_ct.into()); | ||
|
|
||
|
|
@@ -1295,7 +1291,6 @@ pub(super) fn check_type_const<'tcx>( | |
| ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(norm_ct, item_ty)), | ||
| )); | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| #[instrument(level = "debug", skip(tcx, impl_))] | ||
|
|
||
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.
In the long tail of history I suppose we wont have a
ConstItemKindto match on because they'll all be the same kind?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.
correct,
ConstItemKindgets nuked, and this method,lower_const_item_rhs, will only be this arm of this match statement.