-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Make asm label blocks safe context #131544
base: master
Are you sure you want to change the base?
Conversation
`asm!()` is forced to be wrapped inside unsafe. If there's no special treatment, the label blocks would also always be unsafe with no way of opting out.
rustbot has assigned @petrochenkov. Use |
Out { expr: None, reg: _, late: _ } | ||
| Const { value: _, span: _ } | ||
| SymFn { value: _, span: _ } | ||
| SymStatic { 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.
The default visitor uses visit_anon_const
and visit_qpath
in this place, don't you need them here?
To avoid potential mistakes, it probably makes sense to add a public fn walk_inline_asm_operand
helper to intravisit.rs.
match op {
Label { .. } => self.in_safety_context(SafetyContext::Safe, walk_inline_asm_operand(...)),
_ => walk_inline_asm_operand(...),
}
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.
This is the THIR visitor which doesn't have visit_anon_const and visit_qpath.
Tracking issue: #119364
asm!()
is forced to be wrapped inside unsafe. If there's no special treatment, the label blocks would also always be unsafe with no way of opting out. It was suggested that a simple fix is to make asm label blocks safe: #119364 (comment).@rustbot labels: +A-inline-assembly +F-asm