-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[WIP] mgca: Add ConstArg representation for const items #139558
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
base: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
fa42f86
to
6054bd5
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
ac73a4a
to
4f6c9ab
Compare
let ty = this | ||
.lower_ty(ty, ImplTraitContext::Disallowed(ImplTraitPosition::ConstTy)); | ||
let body = | ||
this.lower_const_item(span, body_id.unwrap(), expr.as_deref().unwrap()); |
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.
These new unwraps should be correct in theory since an error should've already been emitted, but they might ICE if the compiler didn't stop earlier. It might be a good idea to add ConstArgKind::Err and use delayed_span_bug.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #141343) made this pull request unmergeable. Please resolve the merge conflicts. |
// HACK(mgca): see lower_const_item in ast_lowering | ||
ItemKind::Const(box ConstItem { body_id: Some(body_id), .. }) => { | ||
this.create_def(body_id, None, DefKind::AnonConst, i.span); | ||
} |
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.
Shouldn't need to be changing def collector, it should just handle anon consts in the AST correctly already. Just need to change ast::ConstItem
to store an AnonConst
instead of NodeId/Expr as separate fields. This should also fix some of the ICEs you've been encountering
DefKind::Const if tcx.generics_of(item_def_id).is_empty() => { | ||
let instance = ty::Instance::new_raw(item_def_id.into(), ty::GenericArgs::empty()); | ||
let cid = GlobalId { instance, promoted: None }; | ||
let typing_env = ty::TypingEnv::fully_monomorphized(); | ||
tcx.ensure_ok().eval_to_const_value_raw(typing_env.as_query_input(cid)); | ||
} |
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.
We should properly handle this before landing 🤔 don't need to care too much rn while everything is still ICEing. I expect we'll just want to update fn check_associated_item
and fn check_item
in wfcheck.rs
to handle const aliases like we do type aliases and then get rid of this codepath
r? @BoxyUwU