about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYacin Tmimi <yacintmimi@gmail.com>2024-09-11 23:45:41 -0400
committerGitHub <noreply@github.com>2024-09-11 23:45:41 -0400
commita1017ae046585fa5cdca5f31cdf50719a2114c4d (patch)
treec998df3aa5d4cd0d571414491cd705e560de50ae
parent182a20378b3a844e3677ff93d96f8ac70b9f009a (diff)
parentd66e974c70ea180e7d7de5ba1c6378e34cd02a7d (diff)
downloadrust-a1017ae046585fa5cdca5f31cdf50719a2114c4d.tar.gz
rust-a1017ae046585fa5cdca5f31cdf50719a2114c4d.zip
Merge pull request #6320 from ytmimi/subtree-push-nightly-2024-09-10
subtree-push nightly-2024-09-10
-rw-r--r--rust-toolchain2
-rw-r--r--src/attr.rs1
-rw-r--r--src/chains.rs1
-rw-r--r--src/closures.rs1
-rw-r--r--src/comment.rs1
-rw-r--r--src/expr.rs13
-rw-r--r--src/format-diff/main.rs4
-rw-r--r--src/formatting.rs1
-rw-r--r--src/git-rustfmt/main.rs4
-rw-r--r--src/items.rs1
-rw-r--r--src/lib.rs3
-rw-r--r--src/macros.rs7
-rw-r--r--src/matches.rs1
-rw-r--r--src/missed_spans.rs1
-rw-r--r--src/modules/visitor.rs1
-rw-r--r--src/overflow.rs1
-rw-r--r--src/test/mod.rs1
-rw-r--r--src/types.rs3
-rw-r--r--src/visitor.rs1
-rw-r--r--tests/target/raw-lifetimes.rs15
-rw-r--r--tests/target/unsafe_attributes.rs1
21 files changed, 44 insertions, 20 deletions
diff --git a/rust-toolchain b/rust-toolchain
index 7b7081bfe81..80723123274 100644
--- a/rust-toolchain
+++ b/rust-toolchain
@@ -1,3 +1,3 @@
 [toolchain]
-channel = "nightly-2024-08-17"
+channel = "nightly-2024-09-10"
 components = ["llvm-tools", "rustc-dev"]
diff --git a/src/attr.rs b/src/attr.rs
index ac57858ef7e..5c2068b6a22 100644
--- a/src/attr.rs
+++ b/src/attr.rs
@@ -3,6 +3,7 @@
 use rustc_ast::HasAttrs;
 use rustc_ast::ast;
 use rustc_span::{Span, symbol::sym};
+use tracing::debug;
 
 use self::doc_comment::DocCommentFormatter;
 use crate::comment::{CommentStyle, contains_comment, rewrite_doc_comment};
diff --git a/src/chains.rs b/src/chains.rs
index 693aaef9979..fd2ef9cb1db 100644
--- a/src/chains.rs
+++ b/src/chains.rs
@@ -60,6 +60,7 @@ use std::cmp::min;
 
 use rustc_ast::{ast, ptr};
 use rustc_span::{BytePos, Span, symbol};
+use tracing::debug;
 
 use crate::comment::{CharClasses, FullCodeCharKind, RichChar, rewrite_comment};
 use crate::config::{IndentStyle, StyleEdition};
diff --git a/src/closures.rs b/src/closures.rs
index 95d2bc5a00b..a37b47e3bc9 100644
--- a/src/closures.rs
+++ b/src/closures.rs
@@ -1,6 +1,7 @@
 use rustc_ast::{ast, ptr};
 use rustc_span::Span;
 use thin_vec::thin_vec;
+use tracing::debug;
 
 use crate::attr::get_attrs_from_stmt;
 use crate::config::StyleEdition;
diff --git a/src/comment.rs b/src/comment.rs
index b565712b326..1b3b88d68a5 100644
--- a/src/comment.rs
+++ b/src/comment.rs
@@ -4,6 +4,7 @@ use std::{borrow::Cow, iter};
 
 use itertools::{MultiPeek, multipeek};
 use rustc_span::Span;
+use tracing::{debug, trace};
 
 use crate::config::Config;
 use crate::rewrite::{RewriteContext, RewriteErrorExt, RewriteResult};
diff --git a/src/expr.rs b/src/expr.rs
index 32bfc8b4722..d6646d48d3e 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -5,6 +5,7 @@ use itertools::Itertools;
 use rustc_ast::token::{Delimiter, Lit, LitKind};
 use rustc_ast::{ForLoopKind, MatchKind, ast, ptr, token};
 use rustc_span::{BytePos, Span};
+use tracing::debug;
 
 use crate::chains::rewrite_chain;
 use crate::closures;
@@ -467,7 +468,7 @@ fn rewrite_empty_block(
         return None;
     }
 
-    let label_str = rewrite_label(label);
+    let label_str = rewrite_label(context, label);
     if attrs.map_or(false, |a| !inner_attributes(a).is_empty()) {
         return None;
     }
@@ -537,7 +538,7 @@ fn rewrite_single_line_block(
             .offset_left(last_line_width(prefix))
             .max_width_error(shape.width, block_expr.span())?;
         let expr_str = block_expr.rewrite_result(context, expr_shape)?;
-        let label_str = rewrite_label(label);
+        let label_str = rewrite_label(context, label);
         let result = format!("{prefix}{label_str}{{ {expr_str} }}");
         if result.len() <= shape.width && !result.contains('\n') {
             return Ok(result);
@@ -572,7 +573,7 @@ pub(crate) fn rewrite_block_with_visitor(
     }
 
     let inner_attrs = attrs.map(inner_attributes);
-    let label_str = rewrite_label(label);
+    let label_str = rewrite_label(context, label);
     visitor.visit_block(block, inner_attrs.as_deref(), has_braces);
     let visitor_context = visitor.get_context();
     context
@@ -956,7 +957,7 @@ impl<'a> ControlFlow<'a> {
             fresh_shape
         };
 
-        let label_string = rewrite_label(self.label);
+        let label_string = rewrite_label(context, self.label);
         // 1 = space after keyword.
         let offset = self.keyword.len() + label_string.len() + 1;
 
@@ -1189,9 +1190,9 @@ impl<'a> Rewrite for ControlFlow<'a> {
     }
 }
 
-fn rewrite_label(opt_label: Option<ast::Label>) -> Cow<'static, str> {
+fn rewrite_label(context: &RewriteContext<'_>, opt_label: Option<ast::Label>) -> Cow<'static, str> {
     match opt_label {
-        Some(label) => Cow::from(format!("{}: ", label.ident)),
+        Some(label) => Cow::from(format!("{}: ", context.snippet(label.ident.span))),
         None => Cow::from(""),
     }
 }
diff --git a/src/format-diff/main.rs b/src/format-diff/main.rs
index f9eb70f6e04..d8616c63df9 100644
--- a/src/format-diff/main.rs
+++ b/src/format-diff/main.rs
@@ -4,12 +4,10 @@
 
 #![deny(warnings)]
 
-#[macro_use]
-extern crate tracing;
-
 use serde::{Deserialize, Serialize};
 use serde_json as json;
 use thiserror::Error;
+use tracing::debug;
 use tracing_subscriber::EnvFilter;
 
 use std::collections::HashSet;
diff --git a/src/formatting.rs b/src/formatting.rs
index 1315c9c43a1..1e1e329f624 100644
--- a/src/formatting.rs
+++ b/src/formatting.rs
@@ -6,6 +6,7 @@ use std::time::{Duration, Instant};
 
 use rustc_ast::ast;
 use rustc_span::Span;
+use tracing::debug;
 
 use self::newline_style::apply_newline_style;
 use crate::comment::{CharClasses, FullCodeCharKind};
diff --git a/src/git-rustfmt/main.rs b/src/git-rustfmt/main.rs
index a487ede9284..64458420f59 100644
--- a/src/git-rustfmt/main.rs
+++ b/src/git-rustfmt/main.rs
@@ -2,9 +2,6 @@
 // `rustc_driver`.
 #![feature(rustc_private)]
 
-#[macro_use]
-extern crate tracing;
-
 use std::env;
 use std::io::stdout;
 use std::path::{Path, PathBuf};
@@ -13,6 +10,7 @@ use std::str::FromStr;
 
 use getopts::{Matches, Options};
 use rustfmt_nightly as rustfmt;
+use tracing::debug;
 use tracing_subscriber::EnvFilter;
 
 use crate::rustfmt::{
diff --git a/src/items.rs b/src/items.rs
index 1f25827e919..daa3df9e5d0 100644
--- a/src/items.rs
+++ b/src/items.rs
@@ -7,6 +7,7 @@ use regex::Regex;
 use rustc_ast::visit;
 use rustc_ast::{ast, ptr};
 use rustc_span::{BytePos, DUMMY_SP, Span, symbol};
+use tracing::debug;
 
 use crate::attr::filter_inline_attrs;
 use crate::comment::{
diff --git a/src/lib.rs b/src/lib.rs
index 7d707c341cb..898689933e6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -4,9 +4,6 @@
 #![recursion_limit = "256"]
 #![allow(clippy::match_like_matches_macro)]
 
-#[macro_use]
-extern crate tracing;
-
 // N.B. these crates are loaded from the sysroot, so they need extern crate.
 extern crate rustc_ast;
 extern crate rustc_ast_pretty;
diff --git a/src/macros.rs b/src/macros.rs
index 2085ed35324..06495e2f8e9 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -20,6 +20,7 @@ use rustc_span::{
     BytePos, DUMMY_SP, Span, Symbol,
     symbol::{self, kw},
 };
+use tracing::debug;
 
 use crate::comment::{
     CharClasses, FindUncommented, FullCodeCharKind, LineClasses, contains_comment,
@@ -1104,7 +1105,7 @@ fn force_space_before(tok: &TokenKind) -> bool {
 fn ident_like(tok: &Token) -> bool {
     matches!(
         tok.kind,
-        TokenKind::Ident(..) | TokenKind::Literal(..) | TokenKind::Lifetime(_)
+        TokenKind::Ident(..) | TokenKind::Literal(..) | TokenKind::Lifetime(..)
     )
 }
 
@@ -1129,7 +1130,9 @@ fn next_space(tok: &TokenKind) -> SpaceState {
         | TokenKind::OpenDelim(_)
         | TokenKind::CloseDelim(_) => SpaceState::Never,
 
-        TokenKind::Literal(..) | TokenKind::Ident(..) | TokenKind::Lifetime(_) => SpaceState::Ident,
+        TokenKind::Literal(..) | TokenKind::Ident(..) | TokenKind::Lifetime(..) => {
+            SpaceState::Ident
+        }
 
         _ => SpaceState::Always,
     }
diff --git a/src/matches.rs b/src/matches.rs
index ee631fa1b47..8f62648e576 100644
--- a/src/matches.rs
+++ b/src/matches.rs
@@ -4,6 +4,7 @@ use std::iter::repeat;
 
 use rustc_ast::{MatchKind, ast, ptr};
 use rustc_span::{BytePos, Span};
+use tracing::debug;
 
 use crate::comment::{FindUncommented, combine_strs_with_missing_comments, rewrite_comment};
 use crate::config::lists::*;
diff --git a/src/missed_spans.rs b/src/missed_spans.rs
index 4ef54c90d46..384de1ce9ae 100644
--- a/src/missed_spans.rs
+++ b/src/missed_spans.rs
@@ -1,4 +1,5 @@
 use rustc_span::{BytePos, Pos, Span};
+use tracing::debug;
 
 use crate::comment::{CodeCharKind, CommentCodeSlices, is_last_comment_block, rewrite_comment};
 use crate::config::FileName;
diff --git a/src/modules/visitor.rs b/src/modules/visitor.rs
index 3e05b6d0c5d..8b46899eaf2 100644
--- a/src/modules/visitor.rs
+++ b/src/modules/visitor.rs
@@ -1,6 +1,7 @@
 use rustc_ast::ast;
 use rustc_ast::visit::Visitor;
 use rustc_span::Symbol;
+use tracing::debug;
 
 use crate::attr::MetaVisitor;
 use crate::parse::macros::cfg_if::parse_cfg_if;
diff --git a/src/overflow.rs b/src/overflow.rs
index 8ce11897d26..fdc8e23e72b 100644
--- a/src/overflow.rs
+++ b/src/overflow.rs
@@ -6,6 +6,7 @@ use itertools::Itertools;
 use rustc_ast::token::Delimiter;
 use rustc_ast::{ast, ptr};
 use rustc_span::Span;
+use tracing::debug;
 
 use crate::closures;
 use crate::config::StyleEdition;
diff --git a/src/test/mod.rs b/src/test/mod.rs
index 9dc05c846de..28f95ee54e5 100644
--- a/src/test/mod.rs
+++ b/src/test/mod.rs
@@ -19,6 +19,7 @@ use crate::{
 };
 
 use rustfmt_config_proc_macro::nightly_only_test;
+use tracing::{debug, warn};
 
 mod configuration_snippet;
 mod mod_resolver;
diff --git a/src/types.rs b/src/types.rs
index 1aa3f60f868..07b483b2b37 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -3,6 +3,7 @@ use std::ops::Deref;
 use rustc_ast::ast::{self, FnRetTy, Mutability, Term};
 use rustc_ast::ptr;
 use rustc_span::{BytePos, Pos, Span, symbol::kw};
+use tracing::debug;
 
 use crate::comment::{combine_strs_with_missing_comments, contains_comment};
 use crate::config::lists::*;
@@ -598,7 +599,7 @@ impl Rewrite for ast::Lifetime {
     }
 
     fn rewrite_result(&self, context: &RewriteContext<'_>, _: Shape) -> RewriteResult {
-        Ok(rewrite_ident(context, self.ident).to_owned())
+        Ok(context.snippet(self.ident.span).to_owned())
     }
 }
 
diff --git a/src/visitor.rs b/src/visitor.rs
index 99416f85503..8102fe7ad8f 100644
--- a/src/visitor.rs
+++ b/src/visitor.rs
@@ -4,6 +4,7 @@ use std::rc::Rc;
 use rustc_ast::{ast, token::Delimiter, visit};
 use rustc_data_structures::sync::Lrc;
 use rustc_span::{BytePos, Pos, Span, symbol};
+use tracing::debug;
 
 use crate::attr::*;
 use crate::comment::{CodeCharKind, CommentCodeSlices, contains_comment, rewrite_comment};
diff --git a/tests/target/raw-lifetimes.rs b/tests/target/raw-lifetimes.rs
new file mode 100644
index 00000000000..62fb9be6882
--- /dev/null
+++ b/tests/target/raw-lifetimes.rs
@@ -0,0 +1,15 @@
+// rustfmt-edition: 2021
+
+// Simple idempotence test for raw lifetimes.
+
+fn test<'r#gen>() -> &'r#gen () {
+    // Test raw lifetimes...
+}
+
+fn label() {
+    'r#label: {
+        // Test raw labels.
+    }
+}
+
+fn main() {}
diff --git a/tests/target/unsafe_attributes.rs b/tests/target/unsafe_attributes.rs
index a05bedc751a..d79c56f2147 100644
--- a/tests/target/unsafe_attributes.rs
+++ b/tests/target/unsafe_attributes.rs
@@ -1,4 +1,3 @@
-#![feature(unsafe_attributes)]
 // https://github.com/rust-lang/rust/issues/123757
 //
 #![simple_ident]