Add AST support for unsafe binders#134140
Merged
Merged
Conversation
Collaborator
|
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 |
ytmimi
reviewed
Dec 10, 2024
Comment on lines
+1019
to
+1043
| 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) | ||
| } |
Contributor
There was a problem hiding this comment.
can you add a rustfmt test case for #![feature(unsafe_binders)].
oli-obk
reviewed
Dec 11, 2024
| Ref(&'hir Lifetime, MutTy<'hir>), | ||
| /// A bare function (e.g., `fn(usize) -> bool`). | ||
| BareFn(&'hir BareFnTy<'hir>), | ||
| /// Uwu |
431d5fe to
81b31f4
Compare
Collaborator
|
☔ The latest upstream changes (presumably #134164) made this pull request unmergeable. Please resolve the merge conflicts. |
81b31f4 to
86e9836
Compare
Contributor
|
r=me with rustfmt test and docs |
86e9836 to
b8c5a0f
Compare
Contributor
Author
|
@bors r=oli-obk |
Collaborator
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Tracking: