Skip to content

Commit a1017ae

Browse files
authored
Merge pull request #6320 from ytmimi/subtree-push-nightly-2024-09-10
subtree-push nightly-2024-09-10
2 parents 182a203 + d66e974 commit a1017ae

21 files changed

+44
-20
lines changed

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-2024-08-17"
2+
channel = "nightly-2024-09-10"
33
components = ["llvm-tools", "rustc-dev"]

src/attr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use rustc_ast::HasAttrs;
44
use rustc_ast::ast;
55
use rustc_span::{Span, symbol::sym};
6+
use tracing::debug;
67

78
use self::doc_comment::DocCommentFormatter;
89
use crate::comment::{CommentStyle, contains_comment, rewrite_doc_comment};

src/chains.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ use std::cmp::min;
6060

6161
use rustc_ast::{ast, ptr};
6262
use rustc_span::{BytePos, Span, symbol};
63+
use tracing::debug;
6364

6465
use crate::comment::{CharClasses, FullCodeCharKind, RichChar, rewrite_comment};
6566
use crate::config::{IndentStyle, StyleEdition};

src/closures.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use rustc_ast::{ast, ptr};
22
use rustc_span::Span;
33
use thin_vec::thin_vec;
4+
use tracing::debug;
45

56
use crate::attr::get_attrs_from_stmt;
67
use crate::config::StyleEdition;

src/comment.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::{borrow::Cow, iter};
44

55
use itertools::{MultiPeek, multipeek};
66
use rustc_span::Span;
7+
use tracing::{debug, trace};
78

89
use crate::config::Config;
910
use crate::rewrite::{RewriteContext, RewriteErrorExt, RewriteResult};

src/expr.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use itertools::Itertools;
55
use rustc_ast::token::{Delimiter, Lit, LitKind};
66
use rustc_ast::{ForLoopKind, MatchKind, ast, ptr, token};
77
use rustc_span::{BytePos, Span};
8+
use tracing::debug;
89

910
use crate::chains::rewrite_chain;
1011
use crate::closures;
@@ -467,7 +468,7 @@ fn rewrite_empty_block(
467468
return None;
468469
}
469470

470-
let label_str = rewrite_label(label);
471+
let label_str = rewrite_label(context, label);
471472
if attrs.map_or(false, |a| !inner_attributes(a).is_empty()) {
472473
return None;
473474
}
@@ -537,7 +538,7 @@ fn rewrite_single_line_block(
537538
.offset_left(last_line_width(prefix))
538539
.max_width_error(shape.width, block_expr.span())?;
539540
let expr_str = block_expr.rewrite_result(context, expr_shape)?;
540-
let label_str = rewrite_label(label);
541+
let label_str = rewrite_label(context, label);
541542
let result = format!("{prefix}{label_str}{{ {expr_str} }}");
542543
if result.len() <= shape.width && !result.contains('\n') {
543544
return Ok(result);
@@ -572,7 +573,7 @@ pub(crate) fn rewrite_block_with_visitor(
572573
}
573574

574575
let inner_attrs = attrs.map(inner_attributes);
575-
let label_str = rewrite_label(label);
576+
let label_str = rewrite_label(context, label);
576577
visitor.visit_block(block, inner_attrs.as_deref(), has_braces);
577578
let visitor_context = visitor.get_context();
578579
context
@@ -956,7 +957,7 @@ impl<'a> ControlFlow<'a> {
956957
fresh_shape
957958
};
958959

959-
let label_string = rewrite_label(self.label);
960+
let label_string = rewrite_label(context, self.label);
960961
// 1 = space after keyword.
961962
let offset = self.keyword.len() + label_string.len() + 1;
962963

@@ -1189,9 +1190,9 @@ impl<'a> Rewrite for ControlFlow<'a> {
11891190
}
11901191
}
11911192

1192-
fn rewrite_label(opt_label: Option<ast::Label>) -> Cow<'static, str> {
1193+
fn rewrite_label(context: &RewriteContext<'_>, opt_label: Option<ast::Label>) -> Cow<'static, str> {
11931194
match opt_label {
1194-
Some(label) => Cow::from(format!("{}: ", label.ident)),
1195+
Some(label) => Cow::from(format!("{}: ", context.snippet(label.ident.span))),
11951196
None => Cow::from(""),
11961197
}
11971198
}

src/format-diff/main.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44

55
#![deny(warnings)]
66

7-
#[macro_use]
8-
extern crate tracing;
9-
107
use serde::{Deserialize, Serialize};
118
use serde_json as json;
129
use thiserror::Error;
10+
use tracing::debug;
1311
use tracing_subscriber::EnvFilter;
1412

1513
use std::collections::HashSet;

src/formatting.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::time::{Duration, Instant};
66

77
use rustc_ast::ast;
88
use rustc_span::Span;
9+
use tracing::debug;
910

1011
use self::newline_style::apply_newline_style;
1112
use crate::comment::{CharClasses, FullCodeCharKind};

src/git-rustfmt/main.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// `rustc_driver`.
33
#![feature(rustc_private)]
44

5-
#[macro_use]
6-
extern crate tracing;
7-
85
use std::env;
96
use std::io::stdout;
107
use std::path::{Path, PathBuf};
@@ -13,6 +10,7 @@ use std::str::FromStr;
1310

1411
use getopts::{Matches, Options};
1512
use rustfmt_nightly as rustfmt;
13+
use tracing::debug;
1614
use tracing_subscriber::EnvFilter;
1715

1816
use crate::rustfmt::{

src/items.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use regex::Regex;
77
use rustc_ast::visit;
88
use rustc_ast::{ast, ptr};
99
use rustc_span::{BytePos, DUMMY_SP, Span, symbol};
10+
use tracing::debug;
1011

1112
use crate::attr::filter_inline_attrs;
1213
use crate::comment::{

0 commit comments

Comments
 (0)