Skip to content

Commit 4b620cd

Browse files
authored
Merge pull request #6807 from ytmimi/subtree-push-nightly-2026-02-19
subtree-push nightly-2026-02-19
2 parents d21c8f3 + 89c18c5 commit 4b620cd

60 files changed

Lines changed: 897 additions & 482 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 49 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,20 @@ path = "src/git-rustfmt/main.rs"
3030
default = ["cargo-fmt", "rustfmt-format-diff"]
3131
cargo-fmt = []
3232
rustfmt-format-diff = []
33-
generic-simd = ["bytecount/generic-simd"]
33+
# FIXME(ytmimi) re-enable "bytecount/generic-simd" to the `generic-simd` features
34+
# once bytecount releases a fix. rustfmt's `generic-simd` features is breaking CI
35+
# and interfering with the next subtree-sync
36+
generic-simd = []
3437

3538
[dependencies]
3639
annotate-snippets = { version = "0.11" }
3740
anyhow = "1.0"
38-
bytecount = "0.6.8"
41+
bytecount = "0.6.9"
3942
cargo_metadata = "0.18"
4043
clap = { version = "4.4.2", features = ["derive"] }
4144
clap-cargo = "0.12.0"
4245
diff = "0.1"
43-
dirs = "5.0"
46+
dirs = "6.0"
4447
getopts = "0.2"
4548
ignore = "0.4"
4649
itertools = "0.12"

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2025-04-02"
2+
channel = "nightly-2026-02-19"
33
components = ["llvm-tools", "rustc-dev"]

src/attr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,8 @@ impl Rewrite for ast::Attribute {
333333
rewrite_doc_comment(snippet, shape.comment(context.config), context.config)
334334
} else {
335335
let should_skip = self
336-
.ident()
337-
.map(|s| context.skip_context.attributes.skip(s.name.as_str()))
336+
.name()
337+
.map(|s| context.skip_context.attributes.skip(s.as_str()))
338338
.unwrap_or(false);
339339
let prefix = attr_prefix(self);
340340

src/chains.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
use std::borrow::Cow;
5959
use std::cmp::min;
6060

61-
use rustc_ast::{ast, ptr};
61+
use rustc_ast::ast;
6262
use rustc_span::{BytePos, Span, symbol};
6363
use tracing::debug;
6464

@@ -190,7 +190,7 @@ enum ChainItemKind {
190190
MethodCall(
191191
ast::PathSegment,
192192
Vec<ast::GenericArg>,
193-
ThinVec<ptr::P<ast::Expr>>,
193+
ThinVec<Box<ast::Expr>>,
194194
),
195195
StructField(symbol::Ident),
196196
TupleField(symbol::Ident, bool),
@@ -351,7 +351,7 @@ impl ChainItem {
351351
fn rewrite_method_call(
352352
method_name: symbol::Ident,
353353
types: &[ast::GenericArg],
354-
args: &[ptr::P<ast::Expr>],
354+
args: &[Box<ast::Expr>],
355355
span: Span,
356356
context: &RewriteContext<'_>,
357357
shape: Shape,

src/closures.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_ast::{Label, ast, ptr};
1+
use rustc_ast::{Label, ast};
22
use rustc_span::Span;
33
use thin_vec::thin_vec;
44
use tracing::debug;
@@ -169,7 +169,7 @@ fn rewrite_closure_with_block(
169169
let block = ast::Block {
170170
stmts: thin_vec![ast::Stmt {
171171
id: ast::NodeId::root(),
172-
kind: ast::StmtKind::Expr(ptr::P(body.clone())),
172+
kind: ast::StmtKind::Expr(Box::new(body.clone())),
173173
span: body.span,
174174
}],
175175
id: ast::NodeId::root(),

src/config/file_lines.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@ pub enum FileName {
2828
impl From<rustc_span::FileName> for FileName {
2929
fn from(name: rustc_span::FileName) -> FileName {
3030
match name {
31-
rustc_span::FileName::Real(rustc_span::RealFileName::LocalPath(p)) => FileName::Real(p),
31+
rustc_span::FileName::Real(real) => {
32+
if let Some(p) = real.into_local_path() {
33+
FileName::Real(p)
34+
} else {
35+
// rustfmt does not remap filenames; the local path should always
36+
// remain accessible.
37+
unreachable!()
38+
}
39+
}
3240
rustc_span::FileName::Custom(ref f) if f == "stdin" => FileName::Stdin,
3341
_ => unreachable!(),
3442
}

src/config/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,6 @@ mod test {
558558
#[allow(dead_code)]
559559
mod mock {
560560
use super::super::*;
561-
use crate::config_option_with_style_edition_default;
562561
use rustfmt_config_proc_macro::config_type;
563562

564563
#[config_type]

src/expr.rs

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::cmp::min;
33

44
use itertools::Itertools;
55
use rustc_ast::token::{Delimiter, Lit, LitKind};
6-
use rustc_ast::{ForLoopKind, MatchKind, ast, ptr, token};
6+
use rustc_ast::{ForLoopKind, MatchKind, ast, token};
77
use rustc_span::{BytePos, Span};
88
use tracing::debug;
99

@@ -392,12 +392,13 @@ pub(crate) fn format_expr(
392392
// Style Guide RFC for InlineAsm variant pending
393393
// https://github.com/rust-dev-tools/fmt-rfcs/issues/152
394394
ast::ExprKind::InlineAsm(..) => Ok(context.snippet(expr.span).to_owned()),
395-
ast::ExprKind::TryBlock(ref block) => {
395+
ast::ExprKind::TryBlock(ref block, None) => {
396396
if let rw @ Ok(_) =
397397
rewrite_single_line_block(context, "try ", block, Some(&expr.attrs), None, shape)
398398
{
399399
rw
400400
} else {
401+
// FIXME: 9 sounds like `"do catch ".len()`, so may predate the rename
401402
// 9 = `try `
402403
let budget = shape.width.saturating_sub(9);
403404
Ok(format!(
@@ -413,6 +414,33 @@ pub(crate) fn format_expr(
413414
))
414415
}
415416
}
417+
ast::ExprKind::TryBlock(ref block, Some(ref ty)) => {
418+
let keyword = "try bikeshed ";
419+
// 2 = " {".len()
420+
let ty_shape = shape
421+
.shrink_left(keyword.len(), expr.span)
422+
.and_then(|shape| shape.sub_width(2, expr.span))?;
423+
424+
let ty_str = ty.rewrite_result(context, ty_shape)?;
425+
let prefix = format!("{keyword}{ty_str} ");
426+
if let rw @ Ok(_) =
427+
rewrite_single_line_block(context, &prefix, block, Some(&expr.attrs), None, shape)
428+
{
429+
rw
430+
} else {
431+
let budget = shape.width.saturating_sub(prefix.len());
432+
Ok(format!(
433+
"{prefix}{}",
434+
rewrite_block(
435+
block,
436+
Some(&expr.attrs),
437+
None,
438+
context,
439+
Shape::legacy(budget, shape.indent)
440+
)?
441+
))
442+
}
443+
}
416444
ast::ExprKind::Gen(capture_by, ref block, ref kind, _) => {
417445
let mover = if matches!(capture_by, ast::CaptureBy::Value { .. }) {
418446
"move "
@@ -1469,7 +1497,7 @@ fn choose_separator_tactic(context: &RewriteContext<'_>, span: Span) -> Option<S
14691497
pub(crate) fn rewrite_call(
14701498
context: &RewriteContext<'_>,
14711499
callee: &str,
1472-
args: &[ptr::P<ast::Expr>],
1500+
args: &[Box<ast::Expr>],
14731501
span: Span,
14741502
shape: Shape,
14751503
) -> RewriteResult {
@@ -1732,7 +1760,7 @@ fn struct_lit_can_be_aligned(fields: &[ast::ExprField], has_base: bool) -> bool
17321760
fn rewrite_struct_lit<'a>(
17331761
context: &RewriteContext<'_>,
17341762
path: &ast::Path,
1735-
qself: &Option<ptr::P<ast::QSelf>>,
1763+
qself: &Option<Box<ast::QSelf>>,
17361764
fields: &'a [ast::ExprField],
17371765
struct_rest: &ast::StructRest,
17381766
attrs: &[ast::Attribute],
@@ -2135,7 +2163,7 @@ fn rewrite_assignment(
21352163
context: &RewriteContext<'_>,
21362164
lhs: &ast::Expr,
21372165
rhs: &ast::Expr,
2138-
op: Option<&ast::BinOp>,
2166+
op: Option<&ast::AssignOp>,
21392167
shape: Shape,
21402168
) -> RewriteResult {
21412169
let operator_str = match op {
@@ -2365,8 +2393,10 @@ fn rewrite_expr_addrof(
23652393
) -> RewriteResult {
23662394
let operator_str = match (mutability, borrow_kind) {
23672395
(ast::Mutability::Not, ast::BorrowKind::Ref) => "&",
2396+
(ast::Mutability::Not, ast::BorrowKind::Pin) => "&pin const ",
23682397
(ast::Mutability::Not, ast::BorrowKind::Raw) => "&raw const ",
23692398
(ast::Mutability::Mut, ast::BorrowKind::Ref) => "&mut ",
2399+
(ast::Mutability::Mut, ast::BorrowKind::Pin) => "&pin mut ",
23702400
(ast::Mutability::Mut, ast::BorrowKind::Raw) => "&raw mut ",
23712401
};
23722402
rewrite_unary_prefix(context, operator_str, expr, shape)

src/imports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ impl UseSegment {
191191
modsep: bool,
192192
) -> Option<UseSegment> {
193193
let name = rewrite_ident(context, path_seg.ident);
194-
if name.is_empty() || name == "{{root}}" {
194+
if name.is_empty() {
195195
return None;
196196
}
197197
let kind = match name {

0 commit comments

Comments
 (0)