Merge pull request #6320 from ytmimi/subtree-push-nightly-2024-09-10
subtree-push nightly-2024-09-10
This commit is contained in:
commit
a1017ae046
@ -1,3 +1,3 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2024-08-17"
|
||||
channel = "nightly-2024-09-10"
|
||||
components = ["llvm-tools", "rustc-dev"]
|
||||
|
@ -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};
|
||||
|
@ -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};
|
||||
|
@ -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;
|
||||
|
@ -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};
|
||||
|
13
src/expr.rs
13
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(""),
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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};
|
||||
|
@ -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::{
|
||||
|
@ -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::{
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
}
|
||||
|
@ -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::*;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -19,6 +19,7 @@ use crate::{
|
||||
};
|
||||
|
||||
use rustfmt_config_proc_macro::nightly_only_test;
|
||||
use tracing::{debug, warn};
|
||||
|
||||
mod configuration_snippet;
|
||||
mod mod_resolver;
|
||||
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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};
|
||||
|
15
tests/target/raw-lifetimes.rs
Normal file
15
tests/target/raw-lifetimes.rs
Normal file
@ -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() {}
|
@ -1,4 +1,3 @@
|
||||
#![feature(unsafe_attributes)]
|
||||
// https://github.com/rust-lang/rust/issues/123757
|
||||
//
|
||||
#![simple_ident]
|
||||
|
Loading…
x
Reference in New Issue
Block a user