-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add AST support for unsafe binders #134140
base: master
Are you sure you want to change the base?
Add AST support for unsafe binders #134140
Conversation
Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt Some changes occurred in src/tools/clippy cc @rust-lang/clippy HIR ty lowering was modified cc @fmease |
ast::TyKind::UnsafeBinder(ref binder) => { | ||
let mut result = String::new(); | ||
if let Some(ref lifetime_str) = | ||
rewrite_bound_params(context, shape, &binder.generic_params) | ||
{ | ||
result.push_str("unsafe<"); | ||
result.push_str(lifetime_str); | ||
result.push_str("> "); | ||
} | ||
|
||
let inner_ty_shape = if context.use_block_indent() { | ||
shape | ||
.offset_left(result.len()) | ||
.max_width_error(shape.width, self.span())? | ||
} else { | ||
shape | ||
.visual_indent(result.len()) | ||
.sub_width(result.len()) | ||
.max_width_error(shape.width, self.span())? | ||
}; | ||
|
||
let rewrite = binder.inner_ty.rewrite_result(context, inner_ty_shape)?; | ||
result.push_str(&rewrite); | ||
Ok(result) | ||
} |
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 you add a rustfmt test case for #![feature(unsafe_binders)]
.
@@ -2878,6 +2886,8 @@ pub enum TyKind<'hir> { | |||
Ref(&'hir Lifetime, MutTy<'hir>), | |||
/// A bare function (e.g., `fn(usize) -> bool`). | |||
BareFn(&'hir BareFnTy<'hir>), | |||
/// Uwu |
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.
✨
431d5fe
to
81b31f4
Compare
☔ The latest upstream changes (presumably #134164) made this pull request unmergeable. Please resolve the merge conflicts. |
81b31f4
to
86e9836
Compare
I'm splitting up #130514 into pieces. It's impossible for me to keep up with a huge PR like that. I'll land type system support for this next, probably w/o MIR lowering, which will come later.
r? @oli-obk
cc @BoxyUwU and @lcnr who also may want to look at this, though this PR doesn't do too much yet