Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subtree-push nightly-2025-02-12 #6476

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2025-01-02"
channel = "nightly-2025-02-12"
components = ["llvm-tools", "rustc-dev"]
15 changes: 10 additions & 5 deletions src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ fn make_opts() -> Options {
"Set options from command line. These settings take priority over .rustfmt.toml",
"[key1=val1,key2=val2...]",
);
opts.optopt(
"",
"style-edition",
"The edition of the Style Guide.",
"[2015|2018|2021|2024]",
);

if is_nightly {
opts.optflag(
Expand Down Expand Up @@ -818,7 +824,6 @@ mod test {
options.inline_config = HashMap::from([("version".to_owned(), "Two".to_owned())]);
let config = get_config(None, Some(options));
assert_eq!(config.style_edition(), StyleEdition::Edition2024);
assert_eq!(config.overflow_delimited_expr(), true);
}

#[nightly_only_test]
Expand All @@ -828,7 +833,6 @@ mod test {
let config_file = Some(Path::new("tests/config/style-edition/just-version"));
let config = get_config(config_file, Some(options));
assert_eq!(config.style_edition(), StyleEdition::Edition2024);
assert_eq!(config.overflow_delimited_expr(), true);
}

#[nightly_only_test]
Expand Down Expand Up @@ -873,7 +877,6 @@ mod test {
]);
let config = get_config(None, Some(options));
assert_eq!(config.style_edition(), StyleEdition::Edition2024);
assert_eq!(config.overflow_delimited_expr(), true);
}

#[nightly_only_test]
Expand Down Expand Up @@ -939,7 +942,6 @@ mod test {
options.style_edition = Some(StyleEdition::Edition2024);
let config = get_config(None, Some(options));
assert_eq!(config.style_edition(), StyleEdition::Edition2024);
assert_eq!(config.overflow_delimited_expr(), true);
}

#[nightly_only_test]
Expand All @@ -949,6 +951,8 @@ mod test {
let config_file = Some(Path::new("tests/config/style-edition/overrides"));
let config = get_config(config_file, Some(options));
assert_eq!(config.style_edition(), StyleEdition::Edition2024);
// FIXME: this test doesn't really exercise anything, since
// `overflow_delimited_expr` is disabled by default in edition 2024.
assert_eq!(config.overflow_delimited_expr(), false);
}

Expand All @@ -960,7 +964,8 @@ mod test {
options.inline_config =
HashMap::from([("overflow_delimited_expr".to_owned(), "false".to_owned())]);
let config = get_config(config_file, Some(options));
assert_eq!(config.style_edition(), StyleEdition::Edition2024);
// FIXME: this test doesn't really exercise anything, since
// `overflow_delimited_expr` is disabled by default in edition 2024.
assert_eq!(config.overflow_delimited_expr(), false);
}
}
4 changes: 2 additions & 2 deletions src/config/file_lines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
use itertools::Itertools;
use std::collections::HashMap;
use std::path::PathBuf;
use std::sync::Arc;
use std::{cmp, fmt, iter, str};

use rustc_data_structures::sync::Lrc;
use rustc_span::SourceFile;
use serde::{Deserialize, Deserializer, Serialize, Serializer, ser};
use serde_json as json;
use thiserror::Error;

/// A range of lines in a file, inclusive of both ends.
pub struct LineRange {
pub(crate) file: Lrc<SourceFile>,
pub(crate) file: Arc<SourceFile>,
pub(crate) lo: usize,
pub(crate) hi: usize,
}
Expand Down
2 changes: 1 addition & 1 deletion src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ binop_separator = "Front"
remove_nested_parens = true
combine_control_expr = true
short_array_element_width_threshold = 10
overflow_delimited_expr = true
overflow_delimited_expr = false
struct_field_align_threshold = 0
enum_discrim_align_threshold = 0
match_arm_blocks = true
Expand Down
4 changes: 2 additions & 2 deletions src/config/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ config_option_with_style_edition_default!(
RemoveNestedParens, bool, _ => true;
CombineControlExpr, bool, _ => true;
ShortArrayElementWidthThreshold, usize, _ => 10;
OverflowDelimitedExpr, bool, Edition2024 => true, _ => false;
OverflowDelimitedExpr, bool, _ => false;
StructFieldAlignThreshold, usize, _ => 0;
EnumDiscrimAlignThreshold, usize, _ => 0;
MatchArmBlocks, bool, _ => true;
Expand All @@ -660,7 +660,7 @@ config_option_with_style_edition_default!(
BlankLinesLowerBound, usize, _ => 0;
EditionConfig, Edition, _ => Edition::Edition2015;
StyleEditionConfig, StyleEdition,
Edition2024 => StyleEdition::Edition2024, _ => StyleEdition::Edition2015;
Edition2024 => StyleEdition::Edition2024, _ => StyleEdition::Edition2015;
VersionConfig, Version, Edition2024 => Version::Two, _ => Version::One;
InlineAttributeWidth, usize, _ => 0;
FormatGeneratedFiles, bool, _ => true;
Expand Down
17 changes: 9 additions & 8 deletions src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,19 +327,19 @@ impl<'a> FnSig<'a> {
defaultness: ast::Defaultness,
) -> FnSig<'a> {
match *fn_kind {
visit::FnKind::Fn(visit::FnCtxt::Assoc(..), _, fn_sig, vis, generics, _) => {
let mut fn_sig = FnSig::from_method_sig(fn_sig, generics, vis);
visit::FnKind::Fn(visit::FnCtxt::Assoc(..), _, vis, ast::Fn { sig, generics, .. }) => {
let mut fn_sig = FnSig::from_method_sig(sig, generics, vis);
fn_sig.defaultness = defaultness;
fn_sig
}
visit::FnKind::Fn(_, _, fn_sig, vis, generics, _) => FnSig {
visit::FnKind::Fn(_, _, vis, ast::Fn { sig, generics, .. }) => FnSig {
decl,
generics,
ext: fn_sig.header.ext,
constness: fn_sig.header.constness,
coroutine_kind: Cow::Borrowed(&fn_sig.header.coroutine_kind),
ext: sig.header.ext,
constness: sig.header.constness,
coroutine_kind: Cow::Borrowed(&sig.header.coroutine_kind),
defaultness,
safety: fn_sig.header.safety,
safety: sig.header.safety,
visibility: vis,
},
_ => unreachable!(),
Expand Down Expand Up @@ -3440,6 +3440,7 @@ impl Rewrite for ast::ForeignItem {
ref sig,
ref generics,
ref body,
..
} = **fn_kind;
if body.is_some() {
let mut visitor = FmtVisitor::from_context(context);
Expand All @@ -3448,7 +3449,7 @@ impl Rewrite for ast::ForeignItem {
let inner_attrs = inner_attributes(&self.attrs);
let fn_ctxt = visit::FnCtxt::Foreign;
visitor.visit_fn(
visit::FnKind::Fn(fn_ctxt, &self.ident, sig, &self.vis, generics, body),
visit::FnKind::Fn(fn_ctxt, &self.ident, &self.vis, fn_kind),
&sig.decl,
self.span,
defaultness,
Expand Down
Loading
Loading