diff --git a/src/tools/rustfmt/.github/workflows/check_diff.yml b/src/tools/rustfmt/.github/workflows/check_diff.yml index 90944500a44b0..b3543a49c3e9b 100644 --- a/src/tools/rustfmt/.github/workflows/check_diff.yml +++ b/src/tools/rustfmt/.github/workflows/check_diff.yml @@ -50,7 +50,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Build check_diff binary working-directory: ./check_diff diff --git a/src/tools/rustfmt/.github/workflows/clippy.yml b/src/tools/rustfmt/.github/workflows/clippy.yml index 92e385d135c0e..a5aa91346dd84 100644 --- a/src/tools/rustfmt/.github/workflows/clippy.yml +++ b/src/tools/rustfmt/.github/workflows/clippy.yml @@ -12,7 +12,7 @@ jobs: name: check clippy configs steps: - name: checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: install rustup run: | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh @@ -34,7 +34,7 @@ jobs: - config_proc_macro steps: - name: checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: install rustup run: | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh diff --git a/src/tools/rustfmt/.github/workflows/integration.yml b/src/tools/rustfmt/.github/workflows/integration.yml index 09fc59114e97e..224605740e55e 100644 --- a/src/tools/rustfmt/.github/workflows/integration.yml +++ b/src/tools/rustfmt/.github/workflows/integration.yml @@ -59,7 +59,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 # Run build - name: install rustup diff --git a/src/tools/rustfmt/.github/workflows/rustdoc_check.yml b/src/tools/rustfmt/.github/workflows/rustdoc_check.yml index 04bb8e1d240f6..b3978005fdf62 100644 --- a/src/tools/rustfmt/.github/workflows/rustdoc_check.yml +++ b/src/tools/rustfmt/.github/workflows/rustdoc_check.yml @@ -12,7 +12,7 @@ jobs: name: rustdoc check steps: - name: checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: install rustup run: | diff --git a/src/tools/rustfmt/.github/workflows/test.yml b/src/tools/rustfmt/.github/workflows/test.yml index aed79eb2e7b72..6d0f25834e596 100644 --- a/src/tools/rustfmt/.github/workflows/test.yml +++ b/src/tools/rustfmt/.github/workflows/test.yml @@ -42,7 +42,7 @@ jobs: if: ${{ matrix.os == 'windows-latest' }} run: git config --global core.autocrlf false - name: checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Install Rustup using win.rustup.rs if: ${{ matrix.os == 'windows-latest' }} diff --git a/src/tools/rustfmt/.github/workflows/upload-assets.yml b/src/tools/rustfmt/.github/workflows/upload-assets.yml index a6a3d3bc51a85..991cc965e3d51 100644 --- a/src/tools/rustfmt/.github/workflows/upload-assets.yml +++ b/src/tools/rustfmt/.github/workflows/upload-assets.yml @@ -31,7 +31,7 @@ jobs: target: x86_64-pc-windows-msvc runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 # Run build - name: install rustup diff --git a/src/tools/rustfmt/rust-toolchain.toml b/src/tools/rustfmt/rust-toolchain.toml index 0d01929160891..05c048743fe34 100644 --- a/src/tools/rustfmt/rust-toolchain.toml +++ b/src/tools/rustfmt/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2026-09-23" +channel = "nightly-2026-10-05" components = ["llvm-tools", "rustc-dev"] diff --git a/src/tools/rustfmt/src/items.rs b/src/tools/rustfmt/src/items.rs index 60d8d8963c524..449cca87afe4a 100644 --- a/src/tools/rustfmt/src/items.rs +++ b/src/tools/rustfmt/src/items.rs @@ -3121,8 +3121,13 @@ fn rewrite_where_keyword( let (span_before, span_after) = missing_span_before_after_where(span_end_before_where, predicates, where_span); - let (comment_before, comment_after) = - rewrite_comments_before_after_where(context, span_before, span_after, shape)?; + let (comment_before, comment_after) = rewrite_comments_before_after_where( + context, + span_before, + span_after, + block_shape, + clause_shape, + )?; let starting_newline = match where_clause_option.snuggle { WhereClauseSpace::Space if comment_before.is_empty() => Cow::from(" "), @@ -3316,14 +3321,11 @@ fn rewrite_comments_before_after_where( context: &RewriteContext<'_>, span_before_where: Span, span_after_where: Span, - shape: Shape, + before_shape: Shape, + after_shape: Shape, ) -> Result<(String, String), RewriteError> { - let before_comment = rewrite_missing_comment(span_before_where, shape, context)?; - let after_comment = rewrite_missing_comment( - span_after_where, - shape.block_indent(context.config.tab_spaces()), - context, - )?; + let before_comment = rewrite_missing_comment(span_before_where, before_shape, context)?; + let after_comment = rewrite_missing_comment(span_after_where, after_shape, context)?; Ok((before_comment, after_comment)) } diff --git a/src/tools/rustfmt/tests/source/where-clause-comment-wrap-issue-7148.rs b/src/tools/rustfmt/tests/source/where-clause-comment-wrap-issue-7148.rs new file mode 100644 index 0000000000000..ba6b3966f6c2c --- /dev/null +++ b/src/tools/rustfmt/tests/source/where-clause-comment-wrap-issue-7148.rs @@ -0,0 +1,29 @@ +// rustfmt-wrap_comments: true +// rustfmt-max_width: 100 +// rustfmt-comment_width: 100 + +// Comments between `where` and the first predicate should be formatted using +// the full column budget rather than a budget derived from the header width. +impl SomeTrait for LongTypeName +where + // A long comment line between where and the first clause that fits within max width limit + // already. So no additional wrapping should occur. + T: SomeTrait, + + // A long comment line between where and the first clause that fits within max width limit + // already. So no additional wrapping should occur. + T: OtherTrait, +{ +} + +// Comments between `where` and the first predicate should be formatted using +// the full column budget rather than a budget derived from the header width. +impl SomeOtherTrait for LongTypeName +where + // A long comment line between where and the first clause that doesn't fit within max width limit already. So additional wrapping should occur. + T: SomeTrait, + + // A long comment line between where and the first clause that doesn't fit within max width limit already. So additional wrapping should occur. + T: OtherTrait, +{ +} diff --git a/src/tools/rustfmt/tests/target/where-clause-comment-wrap-issue-7148.rs b/src/tools/rustfmt/tests/target/where-clause-comment-wrap-issue-7148.rs new file mode 100644 index 0000000000000..08f3d3e43123c --- /dev/null +++ b/src/tools/rustfmt/tests/target/where-clause-comment-wrap-issue-7148.rs @@ -0,0 +1,31 @@ +// rustfmt-wrap_comments: true +// rustfmt-max_width: 100 +// rustfmt-comment_width: 100 + +// Comments between `where` and the first predicate should be formatted using +// the full column budget rather than a budget derived from the header width. +impl SomeTrait for LongTypeName +where + // A long comment line between where and the first clause that fits within max width limit + // already. So no additional wrapping should occur. + T: SomeTrait, + + // A long comment line between where and the first clause that fits within max width limit + // already. So no additional wrapping should occur. + T: OtherTrait, +{ +} + +// Comments between `where` and the first predicate should be formatted using +// the full column budget rather than a budget derived from the header width. +impl SomeOtherTrait for LongTypeName +where + // A long comment line between where and the first clause that doesn't fit within max width + // limit already. So additional wrapping should occur. + T: SomeTrait, + + // A long comment line between where and the first clause that doesn't fit within max width + // limit already. So additional wrapping should occur. + T: OtherTrait, +{ +} diff --git a/src/tools/rustfmt/triagebot.toml b/src/tools/rustfmt/triagebot.toml index d156d2b70ae58..de28ad00a4272 100644 --- a/src/tools/rustfmt/triagebot.toml +++ b/src/tools/rustfmt/triagebot.toml @@ -102,57 +102,6 @@ add_labels = ["S-waiting-on-review"] # Documentation at: [shortcut] -# ------------------------------------------------------------------------------ -# Backport nominations (rustfmt repo side) -# ------------------------------------------------------------------------------ - -[notify-zulip."beta-nominated".rustfmt] -zulip_stream = 621384 # #t-rustfmt/backports -topic = "rustfmt#{number}: beta-nominated" -message_on_add = [ - """\ -@*T-rustfmt* @*T-rustfmt-contributors* PR rustfmt#{number} "{title}" has been nominated -for beta backport. -""", - """\ -/poll Approve beta backport of rustfmt#{number}? -approve -decline -don't know -""", -] -message_on_remove = "PR rustfmt#{number}'s beta-nomination has been removed." - -[notify-zulip."beta-accepted".rustfmt] -zulip_stream = 621384 # #t-rustfmt/backports -# Put it in the same thread as beta-nominated. -topic = "rustfmt#{number}: beta-nominated" -message_on_add = "PR rustfmt#{number} has been **accepted** for **beta** backport." - -[notify-zulip."stable-nominated".rustfmt] -zulip_stream = 621384 # #t-rustfmt/backports -topic = "rustfmt#{number}: stable-nominated" -message_on_add = [ - """\ -@*T-rustfmt* @*T-rustfmt-contributors* PR rustfmt#{number} "{title}" has been nominated -for stable backport. -""", - """\ -/poll Approve stable backport of rustfmt#{number}? -approve -approve (but does not justify new dot release on its own) -decline -don't know -""", -] -message_on_remove = "PR rustfmt#{number}'s stable-nomination has been removed." - -[notify-zulip."stable-accepted".rustfmt] -zulip_stream = 621384 # #t-rustfmt/backports -# Put it in the same thread as stable-nominated. -topic = "rustfmt#{number}: stable-nominated" -message_on_add = "PR rustfmt#{number} has been **accepted** for **stable** backport." - # ------------------------------------------------------------------------------ # PR assignments # ------------------------------------------------------------------------------