Skip to content

Commit a483969

Browse files
committedOct 15, 2023
Auto merge of #116688 - compiler-errors:rustfmt-up, r=WaffleLapkin,Nilstrieb
Format all the let-chains in compiler crates Since rust-lang/rustfmt#5910 has landed, soon we will have support for formatting let-chains (as soon as rustfmt syncs and beta gets bumped). This PR applies the changes [from master rustfmt to rust-lang/rust eagerly](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/out.20formatting.20of.20prs/near/374997516), so that the next beta bump does not have to deal with a 200+ file diff and can remain concerned with other things like `cfg(bootstrap)` -- #113637 was a pain to land, for example, because of let-else. I will also add this commit to the ignore list after it has landed. The commands that were run -- I'm not great at bash-foo, but this applies rustfmt to every compiler crate, and then reverts the two crates that should probably be formatted out-of-tree. ``` ~/rustfmt $ ls -1d ~/rust/compiler/* | xargs -I@ cargo run --bin rustfmt -- `@/src/lib.rs` --config-path ~/rust --edition=2021 # format all of the compiler crates ~/rust $ git checkout HEAD -- compiler/rustc_codegen_{gcc,cranelift} # revert changes to cg-gcc and cg-clif ``` cc `@rust-lang/rustfmt` r? `@WaffleLapkin` or `@Nilstrieb` who said they may be able to review this purely mechanical PR :> cc `@Mark-Simulacrum` and `@petrochenkov,` who had some thoughts on the order of operations with big formatting changes in #95262 (comment). I think the situation has changed since then, given that let-chains support exists on master rustfmt now, and I'm fairly confident that this formatting PR should land even if *bootstrap* rustfmt doesn't yet format let-chains in order to lessen the burden of the next beta bump.
2 parents 4331c15 + e805151 commit a483969

File tree

207 files changed

+3124
-2232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

207 files changed

+3124
-2232
lines changed
 

‎compiler/rustc_ast/src/attr/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,7 @@ impl NestedMetaItem {
520520
I: Iterator<Item = &'a TokenTree>,
521521
{
522522
match tokens.peek() {
523-
Some(TokenTree::Token(token, _))
524-
if let Some(lit) = MetaItemLit::from_token(token) =>
525-
{
523+
Some(TokenTree::Token(token, _)) if let Some(lit) = MetaItemLit::from_token(token) => {
526524
tokens.next();
527525
return Some(NestedMetaItem::Lit(lit));
528526
}

‎compiler/rustc_ast/src/entry.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ pub fn entry_point_type(
2121
} else if attr::contains_name(attrs, sym::rustc_main) {
2222
EntryPointType::RustcMainAttr
2323
} else {
24-
if let Some(name) = name && name == sym::main {
24+
if let Some(name) = name
25+
&& name == sym::main
26+
{
2527
if at_root {
2628
// This is a top-level function so it can be `main`.
2729
EntryPointType::MainNamed

0 commit comments

Comments
 (0)
Please sign in to comment.