Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

compiler-errors
Copy link
Member

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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Dec 10, 2024
@rustbot
Copy link
Collaborator

rustbot commented Dec 10, 2024

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

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)
}
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

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

compiler/rustc_ast_lowering/src/lib.rs Outdated Show resolved Hide resolved
compiler/rustc_hir/src/hir.rs Outdated Show resolved Hide resolved
compiler/rustc_hir/src/hir.rs Outdated Show resolved Hide resolved
compiler/rustc_ast/src/ast.rs Show resolved Hide resolved
compiler/rustc_ast/src/ast.rs Show resolved Hide resolved
@oli-obk oli-obk changed the title Add AST support fror unsafe binders Add AST support for unsafe binders Dec 11, 2024
@bors
Copy link
Contributor

bors commented Dec 11, 2024

☔ The latest upstream changes (presumably #134164) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants