Skip to content

Conversation

npmccallum
Copy link
Contributor

Related to: #143874

@rustbot
Copy link
Collaborator

rustbot commented Sep 1, 2025

r? @ibraheemdev

rustbot has assigned @ibraheemdev.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue. labels Sep 1, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 1, 2025

rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead.

cc @rust-lang/rust-analyzer

Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter
gets adapted for the changes, if necessary.

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

@rust-log-analyzer

This comment has been minimized.

@zachs18
Copy link
Contributor

zachs18 commented Sep 1, 2025

I think these two lines need to be flipped in rustfmt, so it formats the visibility of a trait before the constness.

format_constness(constness),
format_visibility(context, &item.vis),

Also, I think the tidy checks use bootstrap~~/beta~~ rustfmt, not in-tree rustfmt, so fixing rustfmt will probably need to happen first, then the stdlib changes will probably be blocked on the rustfmt fix reaching beta.

@bjorn3
Copy link
Member

bjorn3 commented Sep 1, 2025

We use a pinned nightly for rustfmt, so landing a rustfmt change and updating rustfmt the next day should work.

@npmccallum
Copy link
Contributor Author

It seems that this:

let header = format!(
"{}{}{}{}trait ",
format_constness(constness),
format_visibility(context, &item.vis),
format_safety(safety),
format_auto(is_auto),
);

Conflicts with:

https://github.com/rust-lang/rustfmt/blob/0332da01486508710f2a542111e40513bfb215aa/src/items.rs#L1169-L1174

@rustbot
Copy link
Collaborator

rustbot commented Sep 1, 2025

Some changes occurred in src/tools/rustfmt

cc @rust-lang/rustfmt

@rustbot rustbot added the T-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue. label Sep 1, 2025
@rust-log-analyzer

This comment has been minimized.

fmease added a commit to fmease/rust that referenced this pull request Sep 1, 2025
fix a constness ordering bug in rustfmt

Normally, changes to rustfmt go into the separate repo. But, in this case, the bug is introduced in a local change and therefore isn't present in the rustfmt repo.

Related to: rust-lang#146071
Fixes rust-lang/rustfmt#6619.
jhpratt added a commit to jhpratt/rust that referenced this pull request Sep 2, 2025
fix a constness ordering bug in rustfmt

Normally, changes to rustfmt go into the separate repo. But, in this case, the bug is introduced in a local change and therefore isn't present in the rustfmt repo.

Related to: rust-lang#146071
Fixes rust-lang/rustfmt#6619.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Sep 2, 2025
fix a constness ordering bug in rustfmt

Normally, changes to rustfmt go into the separate repo. But, in this case, the bug is introduced in a local change and therefore isn't present in the rustfmt repo.

Related to: rust-lang#146071
Fixes rust-lang/rustfmt#6619.
rust-timer added a commit that referenced this pull request Sep 2, 2025
Rollup merge of #146089 - npmccallum:rustfmt, r=fmease

fix a constness ordering bug in rustfmt

Normally, changes to rustfmt go into the separate repo. But, in this case, the bug is introduced in a local change and therefore isn't present in the rustfmt repo.

Related to: #146071
Fixes rust-lang/rustfmt#6619.
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Sep 3, 2025

☔ The latest upstream changes (presumably #146160) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Sep 4, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rust-log-analyzer
Copy link
Collaborator

The job tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
     #[rustc_diagnostic_item = "deref_target"]
Diff in /checkout/library/core/src/ops/deref.rs:267:
 #[doc(alias = "*")]
 #[stable(feature = "rust1", since = "1.0.0")]
 #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
-pub const trait DerefMut: [const] Deref + PointeeSized {
+const pub trait DerefMut: [const] Deref + PointeeSized {
     /// Mutably dereferences the value.
     #[stable(feature = "rust1", since = "1.0.0")]
     #[rustc_diagnostic_item = "deref_mut_method"]
Diff in /checkout/library/core/src/ops/bit.rs:32:
 #[stable(feature = "rust1", since = "1.0.0")]
 #[rustc_const_unstable(feature = "const_ops", issue = "143802")]
 #[doc(alias = "!")]
-pub const trait Not {
+const pub trait Not {
     /// The resulting type after applying the `!` operator.
     #[stable(feature = "rust1", since = "1.0.0")]
     type Output;
Diff in /checkout/library/core/src/ops/bit.rs:147:
     message = "no implementation for `{Self} & {Rhs}`",
     label = "no implementation for `{Self} & {Rhs}`"
 )]
-pub const trait BitAnd<Rhs = Self> {
+const pub trait BitAnd<Rhs = Self> {
     /// The resulting type after applying the `&` operator.
     #[stable(feature = "rust1", since = "1.0.0")]
     type Output;
Diff in /checkout/library/core/src/ops/bit.rs:251:
     message = "no implementation for `{Self} | {Rhs}`",
     label = "no implementation for `{Self} | {Rhs}`"
 )]
-pub const trait BitOr<Rhs = Self> {
+const pub trait BitOr<Rhs = Self> {
     /// The resulting type after applying the `|` operator.
     #[stable(feature = "rust1", since = "1.0.0")]
     type Output;
Diff in /checkout/library/core/src/ops/bit.rs:355:
     message = "no implementation for `{Self} ^ {Rhs}`",
     label = "no implementation for `{Self} ^ {Rhs}`"
 )]
-pub const trait BitXor<Rhs = Self> {
+const pub trait BitXor<Rhs = Self> {
     /// The resulting type after applying the `^` operator.
     #[stable(feature = "rust1", since = "1.0.0")]
     type Output;
Diff in /checkout/library/core/src/ops/bit.rs:458:
     message = "no implementation for `{Self} << {Rhs}`",
     label = "no implementation for `{Self} << {Rhs}`"
 )]
-pub const trait Shl<Rhs = Self> {
+const pub trait Shl<Rhs = Self> {
     /// The resulting type after applying the `<<` operator.
     #[stable(feature = "rust1", since = "1.0.0")]
     type Output;
Diff in /checkout/library/core/src/ops/bit.rs:580:
     message = "no implementation for `{Self} >> {Rhs}`",
     label = "no implementation for `{Self} >> {Rhs}`"
 )]
-pub const trait Shr<Rhs = Self> {
+const pub trait Shr<Rhs = Self> {
     /// The resulting type after applying the `>>` operator.
     #[stable(feature = "rust1", since = "1.0.0")]
     type Output;
Diff in /checkout/library/core/src/ops/bit.rs:711:
     message = "no implementation for `{Self} &= {Rhs}`",
     label = "no implementation for `{Self} &= {Rhs}`"
 )]
-pub const trait BitAndAssign<Rhs = Self> {
+const pub trait BitAndAssign<Rhs = Self> {
     /// Performs the `&=` operation.
     ///
     /// # Examples
Diff in /checkout/library/core/src/ops/bit.rs:786:
     message = "no implementation for `{Self} |= {Rhs}`",
     label = "no implementation for `{Self} |= {Rhs}`"
 )]
-pub const trait BitOrAssign<Rhs = Self> {
+const pub trait BitOrAssign<Rhs = Self> {
     /// Performs the `|=` operation.
     ///
     /// # Examples
Diff in /checkout/library/core/src/ops/bit.rs:861:
     message = "no implementation for `{Self} ^= {Rhs}`",
     label = "no implementation for `{Self} ^= {Rhs}`"
 )]
-pub const trait BitXorAssign<Rhs = Self> {
+const pub trait BitXorAssign<Rhs = Self> {
     /// Performs the `^=` operation.
     ///
     /// # Examples
Diff in /checkout/library/core/src/ops/bit.rs:934:
     message = "no implementation for `{Self} <<= {Rhs}`",
     label = "no implementation for `{Self} <<= {Rhs}`"
 )]
-pub const trait ShlAssign<Rhs = Self> {
+const pub trait ShlAssign<Rhs = Self> {
     /// Performs the `<<=` operation.
     ///
     /// # Examples
Diff in /checkout/library/core/src/ops/bit.rs:1020:
     message = "no implementation for `{Self} >>= {Rhs}`",
     label = "no implementation for `{Self} >>= {Rhs}`"
 )]
-pub const trait ShrAssign<Rhs = Self> {
+const pub trait ShrAssign<Rhs = Self> {
     /// Performs the `>>=` operation.
     ///
     /// # Examples
Diff in /checkout/library/core/src/ops/function.rs:73:
 #[fundamental] // so that regex can rely that `&str: !FnMut`
 #[must_use = "closures are lazy and do nothing unless called"]
 #[rustc_const_unstable(feature = "const_trait_impl", issue = "143874")]
-pub const trait Fn<Args: Tuple>: FnMut<Args> {
+const pub trait Fn<Args: Tuple>: FnMut<Args> {
     /// Performs the call operation.
     #[unstable(feature = "fn_traits", issue = "29625")]
     extern "rust-call" fn call(&self, args: Args) -> Self::Output;
Diff in /checkout/library/core/src/ops/function.rs:160:
 #[fundamental] // so that regex can rely that `&str: !FnMut`
 #[must_use = "closures are lazy and do nothing unless called"]
 #[rustc_const_unstable(feature = "const_trait_impl", issue = "143874")]
-pub const trait FnMut<Args: Tuple>: FnOnce<Args> {
+const pub trait FnMut<Args: Tuple>: FnOnce<Args> {
     /// Performs the call operation.
     #[unstable(feature = "fn_traits", issue = "29625")]
     extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
Diff in /checkout/library/core/src/ops/function.rs:239:
 #[fundamental] // so that regex can rely that `&str: !FnMut`
 #[must_use = "closures are lazy and do nothing unless called"]
 #[rustc_const_unstable(feature = "const_trait_impl", issue = "143874")]
-pub const trait FnOnce<Args: Tuple> {
+const pub trait FnOnce<Args: Tuple> {
     /// The returned type after the call operator is used.
     #[lang = "fn_once_output"]
     #[stable(feature = "fn_once_output", since = "1.12.0")]
Diff in /checkout/library/core/src/ops/index.rs:56:
 #[doc(alias = "[")]
 #[doc(alias = "[]")]
 #[rustc_const_unstable(feature = "const_index", issue = "143775")]
-pub const trait Index<Idx: ?Sized> {
+const pub trait Index<Idx: ?Sized> {
     /// The returned type after indexing.
     #[stable(feature = "rust1", since = "1.0.0")]
     #[rustc_diagnostic_item = "IndexOutput"]
Diff in /checkout/library/core/src/ops/index.rs:167:
 #[doc(alias = "]")]
 #[doc(alias = "[]")]
 #[rustc_const_unstable(feature = "const_index", issue = "143775")]
-pub const trait IndexMut<Idx: ?Sized>: [const] Index<Idx> {
+const pub trait IndexMut<Idx: ?Sized>: [const] Index<Idx> {
     /// Performs the mutable indexing (`container[index]`) operation.
     ///
     /// # Panics
Diff in /checkout/library/core/src/ops/drop.rs:204:
 #[lang = "drop"]
 #[stable(feature = "rust1", since = "1.0.0")]
---
     type Output;
Diff in /checkout/library/core/src/ops/arith.rs:187:
     append_const_msg
 )]
 #[doc(alias = "-")]
-pub const trait Sub<Rhs = Self> {
+const pub trait Sub<Rhs = Self> {
     /// The resulting type after applying the `-` operator.
     #[stable(feature = "rust1", since = "1.0.0")]
     type Output;
Diff in /checkout/library/core/src/ops/arith.rs:321:
     label = "no implementation for `{Self} * {Rhs}`"
 )]
 #[doc(alias = "*")]
-pub const trait Mul<Rhs = Self> {
+const pub trait Mul<Rhs = Self> {
     /// The resulting type after applying the `*` operator.
     #[stable(feature = "rust1", since = "1.0.0")]
     type Output;
Diff in /checkout/library/core/src/ops/arith.rs:459:
     label = "no implementation for `{Self} / {Rhs}`"
 )]
 #[doc(alias = "/")]
-pub const trait Div<Rhs = Self> {
+const pub trait Div<Rhs = Self> {
     /// The resulting type after applying the `/` operator.
     #[stable(feature = "rust1", since = "1.0.0")]
     type Output;
Diff in /checkout/library/core/src/ops/arith.rs:568:
     label = "no implementation for `{Self} % {Rhs}`"
 )]
 #[doc(alias = "%")]
-pub const trait Rem<Rhs = Self> {
+const pub trait Rem<Rhs = Self> {
     /// The resulting type after applying the `%` operator.
     #[stable(feature = "rust1", since = "1.0.0")]
     type Output;
Diff in /checkout/library/core/src/ops/arith.rs:689:
 #[stable(feature = "rust1", since = "1.0.0")]
 #[rustc_const_unstable(feature = "const_ops", issue = "143802")]
---
     #[stable(feature = "rust1", since = "1.0.0")]
     type Output;
Diff in /checkout/library/core/src/ops/arith.rs:766:
 )]
 #[doc(alias = "+")]
 #[doc(alias = "+=")]
-pub const trait AddAssign<Rhs = Self> {
+const pub trait AddAssign<Rhs = Self> {
     /// Performs the `+=` operation.
     ///
     /// # Example
Diff in /checkout/library/core/src/ops/arith.rs:837:
 )]
 #[doc(alias = "-")]
 #[doc(alias = "-=")]
-pub const trait SubAssign<Rhs = Self> {
+const pub trait SubAssign<Rhs = Self> {
     /// Performs the `-=` operation.
     ///
     /// # Example
Diff in /checkout/library/core/src/ops/arith.rs:899:
 )]
 #[doc(alias = "*")]
 #[doc(alias = "*=")]
-pub const trait MulAssign<Rhs = Self> {
+const pub trait MulAssign<Rhs = Self> {
     /// Performs the `*=` operation.
     ///
     /// # Example
Diff in /checkout/library/core/src/ops/arith.rs:961:
 )]
 #[doc(alias = "/")]
 #[doc(alias = "/=")]
-pub const trait DivAssign<Rhs = Self> {
+const pub trait DivAssign<Rhs = Self> {
     /// Performs the `/=` operation.
     ///
     /// # Example
Diff in /checkout/library/core/src/ops/arith.rs:1026:
 )]
 #[doc(alias = "%")]
 #[doc(alias = "%=")]
-pub const trait RemAssign<Rhs = Self> {
+const pub trait RemAssign<Rhs = Self> {
     /// Performs the `%=` operation.
     ///
     /// # Example
Diff in /checkout/library/core/src/ops/try_trait.rs:129:
 #[doc(alias = "?")]
 #[lang = "Try"]
 #[rustc_const_unstable(feature = "const_try", issue = "74935")]
-pub const trait Try: [const] FromResidual {
+const pub trait Try: [const] FromResidual {
     /// The type of the value produced by `?` when *not* short-circuiting.
     #[unstable(feature = "try_trait_v2", issue = "84277", old_name = "try_trait")]
     type Output;
Diff in /checkout/library/core/src/ops/try_trait.rs:306:
 #[rustc_diagnostic_item = "FromResidual"]
 #[unstable(feature = "try_trait_v2", issue = "84277", old_name = "try_trait")]
 #[rustc_const_unstable(feature = "const_try", issue = "74935")]
-pub const trait FromResidual<R = <Self as Try>::Residual> {
+const pub trait FromResidual<R = <Self as Try>::Residual> {
     /// Constructs the type from a compatible `Residual` type.
     ///
     /// This should be implemented consistently with the `branch` method such
Diff in /checkout/library/core/src/ops/try_trait.rs:360:
 /// `<Result<Infallible, E> as Residual<T>>::TryType = Result<T, E>`.
 #[unstable(feature = "try_trait_v2_residual", issue = "91285")]
 #[rustc_const_unstable(feature = "const_try", issue = "74935")]
-pub const trait Residual<O> {
+const pub trait Residual<O> {
     /// The "return" type of this meta-function.
     #[unstable(feature = "try_trait_v2_residual", issue = "91285")]
     type TryType: Try<Output = O, Residual = Self>;
Diff in /checkout/library/core/src/convert/mod.rs:217:
 #[stable(feature = "rust1", since = "1.0.0")]
 #[rustc_diagnostic_item = "AsRef"]
 #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
-pub const trait AsRef<T: PointeeSized>: PointeeSized {
+const pub trait AsRef<T: PointeeSized>: PointeeSized {
     /// Converts this type into a shared reference of the (usually inferred) input type.
     #[stable(feature = "rust1", since = "1.0.0")]
     fn as_ref(&self) -> &T;
Diff in /checkout/library/core/src/convert/mod.rs:369:
 #[stable(feature = "rust1", since = "1.0.0")]
 #[rustc_diagnostic_item = "AsMut"]
 #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
-pub const trait AsMut<T: PointeeSized>: PointeeSized {
+const pub trait AsMut<T: PointeeSized>: PointeeSized {
     /// Converts this type into a mutable reference of the (usually inferred) input type.
     #[stable(feature = "rust1", since = "1.0.0")]
     fn as_mut(&mut self) -> &mut T;
Diff in /checkout/library/core/src/convert/mod.rs:448:
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(search_unbox)]
---
     #[must_use]
     #[stable(feature = "rust1", since = "1.0.0")]
Diff in /checkout/library/core/src/convert/mod.rs:584:
 ))]
 #[doc(search_unbox)]
 #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
-pub const trait From<T>: Sized {
+const pub trait From<T>: Sized {
     /// Converts to this type from the input type.
     #[rustc_diagnostic_item = "from_fn"]
     #[must_use]
Diff in /checkout/library/core/src/convert/mod.rs:612:
 #[rustc_diagnostic_item = "TryInto"]
 #[stable(feature = "try_from", since = "1.34.0")]
 #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
-pub const trait TryInto<T>: Sized {
+const pub trait TryInto<T>: Sized {
     /// The type returned in the event of a conversion error.
     #[stable(feature = "try_from", since = "1.34.0")]
     type Error;
Diff in /checkout/library/core/src/convert/mod.rs:691:
 #[rustc_diagnostic_item = "TryFrom"]
 #[stable(feature = "try_from", since = "1.34.0")]
 #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
-pub const trait TryFrom<T>: Sized {
+const pub trait TryFrom<T>: Sized {
     /// The type returned in the event of a conversion error.
     #[stable(feature = "try_from", since = "1.34.0")]
     type Error;
Diff in /checkout/library/core/src/marker.rs:1057:
 #[rustc_on_unimplemented(message = "can't drop `{Self}`", append_const_msg)]
 #[rustc_deny_explicit_impl]
 #[rustc_do_not_implement_via_object]
-pub const trait Destruct {}
+const pub trait Destruct {}
 
 /// A marker for tuple types.
 ///
Diff in /checkout/library/core/src/cmp.rs:248:
 )]
 #[rustc_diagnostic_item = "PartialEq"]
 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
-pub const trait PartialEq<Rhs: PointeeSized = Self>: PointeeSized {
+const pub trait PartialEq<Rhs: PointeeSized = Self>: PointeeSized {
     /// Tests for `self` and `other` values to be equal, and is used by `==`.
     #[must_use]
     #[stable(feature = "rust1", since = "1.0.0")]
Diff in /checkout/library/core/src/default.rs:104:
 #[rustc_diagnostic_item = "Default"]
 #[stable(feature = "rust1", since = "1.0.0")]
 #[rustc_const_unstable(feature = "const_default", issue = "143894")]
---
-pub const trait Clone: Sized {
+const pub trait Clone: Sized {
     /// Returns a duplicate of the value.
     ///
     /// Note that what "duplicate" means varies by type:
Diff in /checkout/library/core/src/pat.rs:22:
     message = "`{Self}` is not a valid base type for range patterns",
     label = "only integer types and `char` are supported"
 )]
-pub const trait RangePattern {
+const pub trait RangePattern {
     /// Trait version of the inherent `MIN` assoc const.
     #[lang = "RangeMin"]
     const MIN: Self;
Diff in /checkout/library/core/src/intrinsics/fallback.rs:8:
 #![allow(missing_docs)]
 
 #[rustc_const_unstable(feature = "core_intrinsics_fallbacks", issue = "none")]
-pub const trait CarryingMulAdd: Copy + 'static {
+const pub trait CarryingMulAdd: Copy + 'static {
     type Unsigned: Copy + 'static;
     fn carrying_mul_add(
         self,
Diff in /checkout/library/core/src/intrinsics/fallback.rs:111:
 }
 
 #[rustc_const_unstable(feature = "core_intrinsics_fallbacks", issue = "none")]
-pub const trait DisjointBitOr: Copy + 'static {
+const pub trait DisjointBitOr: Copy + 'static {
     /// See [`super::disjoint_bitor`]; we just need the trait indirection to handle
     /// different types since calling intrinsics with generics doesn't work.
     unsafe fn disjoint_bitor(self, other: Self) -> Self;
Diff in /checkout/library/core/src/str/traits.rs:826:
 /// ```
 #[stable(feature = "rust1", since = "1.0.0")]

@npmccallum
Copy link
Contributor Author

@bjorn3 The tidy test is still failing, even after my fix for rustfmt was merged. What do we need to do? Do we have to pin tidy to a different nightly? I don't know how this works.

@fmease
Copy link
Member

fmease commented Sep 4, 2025

Yea we need to repin explicitly, lemme investigate how that works. However, I'm not sure if we even pin to some nightly rustfmt, I thought we pin to a beta rustfmt but I'm probably wrong.

@npmccallum
Copy link
Contributor Author

@fmease Any luck? I've got multiple PRs blocked on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue. T-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants