Skip to content

Support const blocks in const_continue #13

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

Draft
wants to merge 1 commit into
base: loop_match_attr
Choose a base branch
from

Conversation

bjorn3
Copy link
Collaborator

@bjorn3 bjorn3 commented Mar 25, 2025

No description provided.

self.tcx
.const_eval_resolve_for_typeck(self.typing_env(), uv, constant.span)
.unwrap()
.unwrap(),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These unwraps and !has_param assertions should also be errors.

@bjorn3 bjorn3 force-pushed the loop_match_attr_consts branch from b0fed64 to af92d9d Compare March 25, 2025 15:24
@bjorn3
Copy link
Collaborator Author

bjorn3 commented Mar 25, 2025

This needs a test.

@bjorn3 bjorn3 force-pushed the loop_match_attr_consts branch from 337bf45 to 5a77008 Compare March 25, 2025 15:38
Comment on lines 769 to 786
ConstOperand {
span: self.thir[value].span,
user_ty: None,
const_: Const::Ty(
self.thir[value].ty,
ty::Const::new_value(
self.tcx,
ValTree::from_branches(
self.tcx,
[ValTree::from_scalar_int(
self.tcx,
variant_index.as_u32().into(),
)],
),
self.thir[value].ty,
),
),
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if this could reuse the logic in const eval.

@folkertdev
Copy link
Collaborator

btw do you really want to force the target to be a literal const { .. } expression? We could also change parsing to use parse_expr_anon_const for a #[const_continue]?

@bjorn3 bjorn3 force-pushed the loop_match_attr_consts branch 3 times, most recently from d372ec2 to 96c7b35 Compare March 31, 2025 13:08
@bjorn3
Copy link
Collaborator Author

bjorn3 commented Mar 31, 2025

btw do you really want to force the target to be a literal const { .. } expression? We could also change parsing to use parse_expr_anon_const for a #[const_continue]?

I prefer not changing the parser. That makes it less likely that #[loop_match]/#[loop_continue] accidentally allow something that wouldn't otherwise be allowed.

@bjorn3 bjorn3 force-pushed the loop_match_attr_consts branch 4 times, most recently from b47c983 to 2fc8c4c Compare April 1, 2025 14:35
@folkertdev folkertdev force-pushed the loop_match_attr branch 2 times, most recently from b3a87ed to 7d88da4 Compare April 4, 2025 08:22
@bjorn3 bjorn3 force-pushed the loop_match_attr_consts branch from 2fc8c4c to 7ff01ec Compare April 8, 2025 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants