Skip to content

Commit e3f0a53

Browse files
authored
Merge pull request #6531 from ytmimi/subtree-push-nightly-2025-04-02
subtree-push nightly-2025-04-02
2 parents f371e16 + ab78ef6 commit e3f0a53

27 files changed

+609
-334
lines changed

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2025-01-02"
2+
channel = "nightly-2025-04-02"
33
components = ["llvm-tools", "rustc-dev"]

src/bin/main.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ fn make_opts() -> Options {
167167
"Set options from command line. These settings take priority over .rustfmt.toml",
168168
"[key1=val1,key2=val2...]",
169169
);
170+
opts.optopt(
171+
"",
172+
"style-edition",
173+
"The edition of the Style Guide.",
174+
"[2015|2018|2021|2024]",
175+
);
170176

171177
if is_nightly {
172178
opts.optflag(
@@ -945,6 +951,9 @@ mod test {
945951
let config_file = Some(Path::new("tests/config/style-edition/overrides"));
946952
let config = get_config(config_file, Some(options));
947953
assert_eq!(config.style_edition(), StyleEdition::Edition2024);
954+
// FIXME: this test doesn't really exercise anything, since
955+
// `overflow_delimited_expr` is disabled by default in edition 2024.
956+
assert_eq!(config.overflow_delimited_expr(), false);
948957
}
949958

950959
#[nightly_only_test]
@@ -955,7 +964,8 @@ mod test {
955964
options.inline_config =
956965
HashMap::from([("overflow_delimited_expr".to_owned(), "true".to_owned())]);
957966
let config = get_config(config_file, Some(options));
958-
assert_eq!(config.style_edition(), StyleEdition::Edition2024);
967+
// FIXME: this test doesn't really exercise anything, since
968+
// `overflow_delimited_expr` is disabled by default in edition 2024.
959969
assert_eq!(config.overflow_delimited_expr(), true);
960970
}
961971
}

src/chains.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ enum ChainItemKind {
195195
StructField(symbol::Ident),
196196
TupleField(symbol::Ident, bool),
197197
Await,
198+
Yield,
198199
Comment(String, CommentPosition),
199200
}
200201

@@ -206,6 +207,7 @@ impl ChainItemKind {
206207
| ChainItemKind::StructField(..)
207208
| ChainItemKind::TupleField(..)
208209
| ChainItemKind::Await
210+
| ChainItemKind::Yield
209211
| ChainItemKind::Comment(..) => false,
210212
}
211213
}
@@ -260,6 +262,10 @@ impl ChainItemKind {
260262
let span = mk_sp(nested.span.hi(), expr.span.hi());
261263
(ChainItemKind::Await, span)
262264
}
265+
ast::ExprKind::Yield(ast::YieldKind::Postfix(ref nested)) => {
266+
let span = mk_sp(nested.span.hi(), expr.span.hi());
267+
(ChainItemKind::Yield, span)
268+
}
263269
_ => {
264270
return (
265271
ChainItemKind::Parent {
@@ -307,6 +313,7 @@ impl Rewrite for ChainItem {
307313
rewrite_ident(context, ident)
308314
),
309315
ChainItemKind::Await => ".await".to_owned(),
316+
ChainItemKind::Yield => ".yield".to_owned(),
310317
ChainItemKind::Comment(ref comment, _) => {
311318
rewrite_comment(comment, false, shape, context.config)?
312319
}
@@ -509,7 +516,8 @@ impl Chain {
509516
}),
510517
ast::ExprKind::Field(ref subexpr, _)
511518
| ast::ExprKind::Try(ref subexpr)
512-
| ast::ExprKind::Await(ref subexpr, _) => Some(SubExpr {
519+
| ast::ExprKind::Await(ref subexpr, _)
520+
| ast::ExprKind::Yield(ast::YieldKind::Postfix(ref subexpr)) => Some(SubExpr {
513521
expr: Self::convert_try(subexpr, context),
514522
is_method_call_receiver: false,
515523
}),

src/closures.rs

-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ fn rewrite_closure_with_block(
180180
.first()
181181
.map(|attr| attr.span.to(body.span))
182182
.unwrap_or(body.span),
183-
could_be_bare_literal: false,
184183
};
185184
let block = crate::expr::rewrite_block_with_visitor(
186185
context,

src/config/file_lines.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
use itertools::Itertools;
44
use std::collections::HashMap;
55
use std::path::PathBuf;
6+
use std::sync::Arc;
67
use std::{cmp, fmt, iter, str};
78

8-
use rustc_data_structures::sync::Lrc;
99
use rustc_span::SourceFile;
1010
use serde::{Deserialize, Deserializer, Serialize, Serializer, ser};
1111
use serde_json as json;
1212
use thiserror::Error;
1313

1414
/// A range of lines in a file, inclusive of both ends.
1515
pub struct LineRange {
16-
pub(crate) file: Lrc<SourceFile>,
16+
pub(crate) file: Arc<SourceFile>,
1717
pub(crate) lo: usize,
1818
pub(crate) hi: usize,
1919
}

src/config/options.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ config_option_with_style_edition_default!(
677677
BlankLinesLowerBound, usize, _ => 0;
678678
EditionConfig, Edition, _ => Edition::Edition2015;
679679
StyleEditionConfig, StyleEdition,
680-
Edition2024 => StyleEdition::Edition2024, _ => StyleEdition::Edition2015;
680+
Edition2024 => StyleEdition::Edition2024, _ => StyleEdition::Edition2015;
681681
VersionConfig, Version, Edition2024 => Version::Two, _ => Version::One;
682682
InlineAttributeWidth, usize, _ => 0;
683683
FormatGeneratedFiles, bool, _ => true;

src/expr.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ pub(crate) fn format_expr(
161161
ast::ExprKind::Tup(ref items) => {
162162
rewrite_tuple(context, items.iter(), expr.span, shape, items.len() == 1)
163163
}
164+
ast::ExprKind::Use(_, _) => {
165+
// FIXME: properly implement this
166+
Ok(context.snippet(expr.span()).to_owned())
167+
}
164168
ast::ExprKind::Let(ref pat, ref expr, _span, _) => rewrite_let(context, shape, pat, expr),
165169
ast::ExprKind::If(..)
166170
| ast::ExprKind::ForLoop { .. }
@@ -249,7 +253,7 @@ pub(crate) fn format_expr(
249253
Ok(format!("break{id_str}"))
250254
}
251255
}
252-
ast::ExprKind::Yield(ref opt_expr) => {
256+
ast::ExprKind::Yield(ast::YieldKind::Prefix(ref opt_expr)) => {
253257
if let Some(ref expr) = *opt_expr {
254258
rewrite_unary_prefix(context, "yield ", &**expr, shape)
255259
} else {
@@ -271,9 +275,10 @@ pub(crate) fn format_expr(
271275
ast::ExprKind::Try(..)
272276
| ast::ExprKind::Field(..)
273277
| ast::ExprKind::MethodCall(..)
274-
| ast::ExprKind::Await(_, _) => rewrite_chain(expr, context, shape),
278+
| ast::ExprKind::Await(_, _)
279+
| ast::ExprKind::Yield(ast::YieldKind::Postfix(_)) => rewrite_chain(expr, context, shape),
275280
ast::ExprKind::MacCall(ref mac) => {
276-
rewrite_macro(mac, None, context, shape, MacroPosition::Expression).or_else(|_| {
281+
rewrite_macro(mac, context, shape, MacroPosition::Expression).or_else(|_| {
277282
wrap_str(
278283
context.snippet(expr.span).to_owned(),
279284
context.config.max_width(),

0 commit comments

Comments
 (0)