Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2026-09-23"
channel = "nightly-2026-10-05"
components = ["llvm-tools", "rustc-dev"]
2 changes: 1 addition & 1 deletion src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ pub(crate) fn format_expr(
| ast::ExprKind::IncludedBytes(..)
| ast::ExprKind::OffsetOf(..)
| ast::ExprKind::UnsafeBinderCast(..)
| ast::ExprKind::DirectConstArg(..) => {
| ast::ExprKind::GcaMacro(..) => {
// These don't normally occur in the AST because macros aren't expanded. However,
// rustfmt tries to parse macro arguments when formatting macros, so it's not totally
// impossible for rustfmt to come across one of these nodes when formatting a file.
Expand Down
8 changes: 4 additions & 4 deletions src/parse/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ mod tests {
Some(ignore_list),
);
let span = MultiSpan::from_span(mk_sp(BytePos(0), BytePos(1)));
let non_fatal_diagnostic = build_diagnostic(DiagnosticLevel::Warning, Some(span));
let non_fatal_diagnostic = build_diagnostic(DiagnosticLevel::Warning(None), Some(span));
emitter.emit_diagnostic(non_fatal_diagnostic);
assert_eq!(num_emitted_errors.load(Ordering::Acquire), 0);
assert_eq!(can_reset_errors.load(Ordering::Acquire), true);
Expand All @@ -439,7 +439,7 @@ mod tests {
None,
);
let span = MultiSpan::from_span(mk_sp(BytePos(0), BytePos(1)));
let non_fatal_diagnostic = build_diagnostic(DiagnosticLevel::Warning, Some(span));
let non_fatal_diagnostic = build_diagnostic(DiagnosticLevel::Warning(None), Some(span));
emitter.emit_diagnostic(non_fatal_diagnostic);
assert_eq!(num_emitted_errors.load(Ordering::Acquire), 1);
assert_eq!(can_reset_errors.load(Ordering::Acquire), false);
Expand Down Expand Up @@ -467,8 +467,8 @@ mod tests {
);
let bar_span = MultiSpan::from_span(mk_sp(BytePos(0), BytePos(1)));
let foo_span = MultiSpan::from_span(mk_sp(BytePos(21), BytePos(22)));
let bar_diagnostic = build_diagnostic(DiagnosticLevel::Warning, Some(bar_span));
let foo_diagnostic = build_diagnostic(DiagnosticLevel::Warning, Some(foo_span));
let bar_diagnostic = build_diagnostic(DiagnosticLevel::Warning(None), Some(bar_span));
let foo_diagnostic = build_diagnostic(DiagnosticLevel::Warning(None), Some(foo_span));
let fatal_diagnostic = build_diagnostic(DiagnosticLevel::Fatal, None);
emitter.emit_diagnostic(bar_diagnostic);
emitter.emit_diagnostic(foo_diagnostic);
Expand Down
30 changes: 15 additions & 15 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -821,17 +821,17 @@ impl Rewrite for ast::Ty {
}
Ok(format!("{prefix}{res}"))
}
ast::TyKind::Ptr(ref mt) => {
let prefix = match mt.mutbl {
ast::TyKind::Ptr(ref ty, mutbl) => {
let prefix = match mutbl {
Mutability::Mut => "*mut ",
Mutability::Not => "*const ",
};

rewrite_unary_prefix(context, prefix, &*mt.ty, shape)
rewrite_unary_prefix(context, prefix, &*ty, shape)
}
ast::TyKind::Ref(ref lifetime, ref mt)
| ast::TyKind::PinnedRef(ref lifetime, ref mt) => {
let mut_str = format_mutability(mt.mutbl);
ast::TyKind::Ref(ref lifetime, ref ty, mutbl)
| ast::TyKind::PinnedRef(ref lifetime, ref ty, mutbl) => {
let mut_str = format_mutability(mutbl);
let mut_len = mut_str.len();
let mut result = String::with_capacity(128);
result.push('&');
Expand Down Expand Up @@ -866,12 +866,12 @@ impl Rewrite for ast::Ty {

if let ast::TyKind::PinnedRef(..) = self.kind {
result.push_str("pin ");
if ast::Mutability::Not == mt.mutbl {
if ast::Mutability::Not == mutbl {
result.push_str("const ");
}
}

if ast::Mutability::Mut == mt.mutbl {
if ast::Mutability::Mut == mutbl {
let mut_hi = context.snippet_provider.span_after(self.span(), "mut");
let before_mut_span = mk_sp(cmnt_lo, mut_hi - BytePos::from_usize(3));
if contains_comment(context.snippet(before_mut_span)) {
Expand All @@ -889,12 +889,12 @@ impl Rewrite for ast::Ty {
cmnt_lo = mut_hi;
}

let before_ty_span = mk_sp(cmnt_lo, mt.ty.span.lo());
let before_ty_span = mk_sp(cmnt_lo, ty.span.lo());
if contains_comment(context.snippet(before_ty_span)) {
result = combine_strs_with_missing_comments(
context,
result.trim_end(),
&mt.ty.rewrite_result(context, shape)?,
&ty.rewrite_result(context, shape)?,
before_ty_span,
shape,
true,
Expand All @@ -905,7 +905,7 @@ impl Rewrite for ast::Ty {
.width
.checked_sub(used_width)
.max_width_error(shape.width, self.span())?;
let ty_str = mt.ty.rewrite_result(
let ty_str = ty.rewrite_result(
context,
Shape::legacy(budget, shape.indent + used_width),
)?;
Expand Down Expand Up @@ -1043,7 +1043,7 @@ impl Rewrite for ast::Ty {
result.push_str(&rewrite);
Ok(result)
}
ast::TyKind::Pat(..) | ast::TyKind::View(..) | ast::TyKind::DirectConstArg(..) => {
ast::TyKind::Pat(..) | ast::TyKind::View(..) | ast::TyKind::GcaMacro(..) => {
// These don't normally occur in the AST because macros aren't expanded. However,
// rustfmt tries to parse macro arguments when formatting macros, so it's not
// totally impossible for rustfmt to come across these nodes when formatting a file.
Expand Down Expand Up @@ -1333,9 +1333,9 @@ pub(crate) fn can_be_overflowed_type(
) -> bool {
match ty.kind {
ast::TyKind::Tup(..) => context.use_block_indent() && len == 1,
ast::TyKind::Ref(_, ref mutty)
| ast::TyKind::PinnedRef(_, ref mutty)
| ast::TyKind::Ptr(ref mutty) => can_be_overflowed_type(context, &*mutty.ty, len),
ast::TyKind::Ref(_, ref ty, _)
| ast::TyKind::PinnedRef(_, ref ty, _)
| ast::TyKind::Ptr(ref ty, _) => can_be_overflowed_type(context, &*ty, len),
_ => false,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr
| ast::ExprKind::Unary(_, ref expr)
| ast::ExprKind::Try(ref expr)
| ast::ExprKind::Yield(YieldKind::Prefix(Some(ref expr)))
| ast::ExprKind::DirectConstArg(ref expr) => is_block_expr(context, expr, repr),
| ast::ExprKind::GcaMacro(ref expr) => is_block_expr(context, expr, repr),
ast::ExprKind::Closure(ref closure) => is_block_expr(context, &closure.body, repr),
// This can only be a string lit
ast::ExprKind::Lit(_) => {
Expand Down
15 changes: 0 additions & 15 deletions tests/source/direct_const_arg.rs

This file was deleted.

17 changes: 17 additions & 0 deletions tests/source/gca.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// gca! is a built-in macro relevant to gca_min_const_items; its contents should be formatted as
// if its contents were passed through unchanged (the macro changes the semantics of the contained
// expression, the syntax is unchanged)

#![feature(gca_min_const_items)]

use std::gca;

trait Trait {
#[rustc_always_gca]
const TYPE_CONST: usize;
}

struct S<const N: usize>;

fn parsed_as_expr_kind<T: Trait>(_: S<{ gca!( T :: TYPE_CONST ) }>) {}
fn parsed_as_ty_kind<T: Trait>(_: S< gca!( T :: TYPE_CONST ) >) {}
2 changes: 1 addition & 1 deletion tests/source/match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ fn issue383() {

fn issue507() {
match 1 {
1 => unsafe { std::intrinsics::abort() },
1 => unsafe { std::intrinsics::abort_immediate() },
_ => (),
}
}
Expand Down
15 changes: 0 additions & 15 deletions tests/target/direct_const_arg.rs

This file was deleted.

17 changes: 17 additions & 0 deletions tests/target/gca.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// gca! is a built-in macro relevant to gca_min_const_items; its contents should be formatted as
// if its contents were passed through unchanged (the macro changes the semantics of the contained
// expression, the syntax is unchanged)

#![feature(gca_min_const_items)]

use std::gca;

trait Trait {
#[rustc_always_gca]
const TYPE_CONST: usize;
}

struct S<const N: usize>;

fn parsed_as_expr_kind<T: Trait>(_: S<{ gca!(T::TYPE_CONST) }>) {}
fn parsed_as_ty_kind<T: Trait>(_: S<gca!(T::TYPE_CONST)>) {}
2 changes: 1 addition & 1 deletion tests/target/match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ fn issue383() {

fn issue507() {
match 1 {
1 => unsafe { std::intrinsics::abort() },
1 => unsafe { std::intrinsics::abort_immediate() },
_ => (),
}
}
Expand Down
Loading