-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
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)]
.
compiler/rustc_hir/src/hir.rs
Outdated
@@ -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
r=me with rustfmt test and docs |
86e9836
to
b8c5a0f
Compare
@bors r=oli-obk |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#133900 (Advent of `tests/ui` (misc cleanups and improvements) [1/N]) - rust-lang#133937 (Keep track of parse errors in `mod`s and don't emit resolve errors for paths involving them) - rust-lang#133938 (`rustc_mir_dataflow` cleanups, including some renamings) - rust-lang#134058 (interpret: reduce usage of TypingEnv::fully_monomorphized) - rust-lang#134130 (Stop using driver queries in the public API) - rust-lang#134140 (Add AST support for unsafe binders) - rust-lang#134229 (Fix typos in docs on provenance) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#133900 (Advent of `tests/ui` (misc cleanups and improvements) [1/N]) - rust-lang#133937 (Keep track of parse errors in `mod`s and don't emit resolve errors for paths involving them) - rust-lang#133938 (`rustc_mir_dataflow` cleanups, including some renamings) - rust-lang#134058 (interpret: reduce usage of TypingEnv::fully_monomorphized) - rust-lang#134130 (Stop using driver queries in the public API) - rust-lang#134140 (Add AST support for unsafe binders) - rust-lang#134229 (Fix typos in docs on provenance) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#134140 - compiler-errors:unsafe-binders-ast, r=oli-obk Add AST support for unsafe binders I'm splitting up rust-lang#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
…, r=oli-obk Add AST support for unsafe binders I'm splitting up rust-lang#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
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#133900 (Advent of `tests/ui` (misc cleanups and improvements) [1/N]) - rust-lang#133937 (Keep track of parse errors in `mod`s and don't emit resolve errors for paths involving them) - rust-lang#133938 (`rustc_mir_dataflow` cleanups, including some renamings) - rust-lang#134058 (interpret: reduce usage of TypingEnv::fully_monomorphized) - rust-lang#134130 (Stop using driver queries in the public API) - rust-lang#134140 (Add AST support for unsafe binders) - rust-lang#134229 (Fix typos in docs on provenance) r? `@ghost` `@rustbot` modify labels: rollup
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: