-
Notifications
You must be signed in to change notification settings - Fork 898
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
rustfmt 1.7.0-nightly
inconsistent output across targets
#5964
Comments
As a note, the output on Darwin is alarmingly weird. The formatting differences are annoying enough, but it also eats comments after a single blank line, e.g. // This is a comment.
//
// This is more information. ^-- The second and third line of the above get removed. |
@kyle-mccarthy thanks for reaching out. I'm not quite sure what would have changed recently to cause the formatting diff. Our last subtree sync with the
Thanks for taking the time to do a little investigating on this. I checked
@calebcartwright do you think something weird could have happened with changes made to rustfmt directly from Edit: |
@lukesneeringer Are you sure that your issue is related? I just double check and I can't reproduce. It would probably be best for you to open up a separate issue fully explaining the issue that you're having as well as any configuration options that you're using.
|
I can do that. Although I'm fairly certain it's related, and this comment seems to suggest the same. I'll open a separate issue in a little bit when I get a moment. :-) P. S. I didn't know about the |
@calebcartwright it Also doesn't look like there were any changes made to rustfmt in the |
For what it's worth this doesn't seem to be an issue on the Rust Playground which as of today is using Though when I ran with Diff in <stdin> at line 3:
fn main() {
let map = json!({ "key": "value" });
- let _value: String = map
- .get("key")
- .map(|v| v.as_str())
- .flatten()
- .unwrap_or_default()
- .to_string();
+ let _value: String =
+ map.get("key")
+ .map(|v| v.as_str())
+ .flatten()
+ .unwrap_or_default()
+ .to_string();
} |
The rust playground is actually how I produced the The output that it is producing right now ( The incorrect formatting seems to happen on I don't have access to test on other targets so I am not sure if the wrong output is limited to |
Is it possible that this is caused by sth like rustup or rust nightly release pipeline? |
@ytmimi I've come up with a fairly simple repro case. I'm posting it here rather than making it a new ticket because I've proven that it only occurs on aarch64-apple-darwin (not Linux). I'm happy to open a new issue if appropriate. Here's my //! Market calendar aware utilities
//!
//! This crate primarily provides the [`MarketCalendar`] trait, which adds methods for traversing
//! trading days, determining whether the markets are open on a given date, and so on. Currently
//! the trait is only applied to [`chrono::NaiveDate`], and when brought into scope, allows you to
//! ask about the market calendar for a given date, or traverse by trading day count.
//!
//! ```
//! use chrono::NaiveDate;
//! use market_cal::MarketCalendar;
//!
//! let dt = NaiveDate::from_ymd_opt(2020, 12, 24).unwrap();
//! assert_eq!(dt.next_trading_day(), NaiveDate::from_ymd_opt(2020, 12, 28).unwrap());
//! ```
Also the following format_code_in_doc_comments = true
wrap_comments = true Expected Behavior (Linux)On Linux, using //! Market calendar aware utilities
//!
-//! This crate primarily provides the [`MarketCalendar`] trait, which adds methods for traversing
-//! trading days, determining whether the markets are open on a given date, and so on. Currently
-//! the trait is only applied to [`chrono::NaiveDate`], and when brought into scope, allows you to
-//! ask about the market calendar for a given date, or traverse by trading day count.
+//! This crate primarily provides the [`MarketCalendar`] trait, which adds
+//! methods for traversing trading days, determining whether the markets are
+//! open on a given date, and so on. Currently the trait is only applied to
+//! [`chrono::NaiveDate`], and when brought into scope, allows you to
+//! ask about the market calendar for a given date, or traverse by trading day
+//! count.
//!
//! ```
//! use chrono::NaiveDate;
Diff in /home/luke/Code/testme/src/lib.rs at line 10:
//! use market_cal::MarketCalendar;
//!
//! let dt = NaiveDate::from_ymd_opt(2020, 12, 24).unwrap();
-//! assert_eq!(dt.next_trading_day(), NaiveDate::from_ymd_opt(2020, 12, 28).unwrap());
+//! assert_eq!(
+//! dt.next_trading_day(),
+//! NaiveDate::from_ymd_opt(2020, 12, 28).unwrap()
+//! );
//! Unexpected Behavior (Darwin)On Mac/Darwin only, on //! Market calendar aware utilities
-//!
-//! This crate primarily provides the [`MarketCalendar`] trait, which adds methods for traversing
-//! trading days, determining whether the markets are open on a given date, and so on. Currently
-//! the trait is only applied to [`chrono::NaiveDate`], and when brought into scope, allows you to
-//! ask about the market calendar for a given date, or traverse by trading day count.
-//!
-//! ```
-//! use chrono::NaiveDate;
-//! use market_cal::MarketCalendar;
-//!
-//! let dt = NaiveDate::from_ymd_opt(2020, 12, 24).unwrap();
-//! assert_eq!(dt.next_trading_day(), NaiveDate::from_ymd_opt(2020, 12, 28).unwrap());
-//! ``` I'm happy to post another issue if you still believe it's unrelated, although since it popped up at the same time and appears to be isolated to Macs, I really do think it's a symptom of the same issue. |
@lukesneeringer thanks for providing a small reproducible test case. I think a new issue would be overkill at this point. I couldn't tell you why these issues are related, but something definitely seems off on @xxchan thank you for also providing some confirmation on this.
At this point I'm not too sure what the underlying issue is, but I'll be sure to report back if I figure anything out. |
Also want to highlight that neither issue is reproducible when build rustfmt from source: rustfmt 1.7.0-nightly (37489e4 2023-11-01) |
@ytmimi no, though I think this has already been borne out in subsequent discussion, both because of the seeming platform dependency and the git history. We aren't involved with the packaging and distribution aspects of rustfmt, as is the typical pattern for the dev tools that ship with the toolchains. There shouldn't be any saliant (see: behavioral, commit, etc.) differences between the rustfmt binaries per platform, so I'd guess we're looking at an upstream packaging issue, or somehow execution is occurring with a different config. I'd like to start with the most absolute minimal repro possible, and then do a platform-specific bisect, essentially walking back through each nightly version on nightly-aarch64-apple-darwin, making sure the version of If nothing jumps out from that, then next I think we'd want to take a look at the actual binary that rustup is grabbing from the upstream buckets so that we have more info when we talk to them and/or infra |
FWIW, bisecting showed the change appeared with rust-lang/rust#117500. |
CC @RalfJung, perhaps you have a theory why rust-lang/rust#117500 might have changed rustfmt to behave differently on aarch64? I tested aarch64-apple-darwin, aarch64-unknown-linux-gnu, and aarch64-pc-windows-msvc, and they all behave differently from x86_64 builds (the aarch64 hosts now have different formatting behavior). |
I'll add that the diffs seem to be related to rustfmt now thinking the width/length isn't the same across the platforms |
This reverts commit 4e590b2. Reverting because of problem in rustfmt +nightly on aarch64 architectures rust-lang/rustfmt#5964
Wow, that's wild. Could this be a symptom of rust-lang/rust#118124, where data gets corrupted on some intrinsic calls? Then rust-lang/rust#118127 would help. Otherwise there's some other use of the "Direct" ABI somewhere else [which is a bug but can sometimes produce the right results] that got uncovered by my PR, but I have no idea how to figure out where... (our current ABI code is super fragile, sadly) |
I confirmed that rust-lang/rust#118127 fixed rustfmt for me on aarch64. I haven't tested it heavily, though. |
@ehuss thanks for the confirmation. Would you mind quickly outlining what steps you took to verify that rust-lang/rust#118127 fixed rustfmt for you |
What I did to verify that the changes in rust-lang/rust#118127 resolved the issue is that I checked out Ralph's branch, built |
Yea, that's what I did. Essentially:
|
Hey just to chip in here, I ran into the same issue.
I'm working on an M2 MacBook Air, but I'm coding inside a Debian VM (hence aarch64 but Linux). Running |
I just checked and I can't reproduced the issue when using the |
Can confirm this is resolved. I just updated with
This is the rustfmt version I have now:
And formatting my (correctly formatted) code from my repository no longer crates a diff. |
+1, seems to be resolved now (since ~3 days back). |
Agreed this is sorted so going to close. Thanks for the reports, feedback, and assistance troubleshooting & resolving. I am curious about the absence of preemptive test failures, but that's something for us to dig into separately moving forward |
These skips were added in a-scie#173 to work around this issue: rust-lang/rustfmt#5964 It has been resolved; so formatting should now work on all architectures. Fixes a-scie#174
These skips were added in #173 to work around this issue: rust-lang/rustfmt#5964 It has been resolved; so formatting should now work on all architectures. Fixes #174
…ference in rustfmt output between Mac Intel and Mac Silicon: rust-lang/rustfmt#5964
…ference in rustfmt output between Mac Intel and Mac Silicon: rust-lang/rustfmt#5964
Our CI started failing at the formatting check step after updating to
1.7.0-nightly (9a66e4471 2023-11-19)
; however, when run locallycargo +nightly fmt --check
passes. I verified that they both are using the same version of rustfmt, the only differences being the platform/target.CI:
nightly-x86_64-unknown-linux-gnu installed - rustc 1.76.0-nightly (9a66e4471 2023-11-19)
Local:
nightly-aarch64-apple-darwin - Up to date : 1.76.0-nightly (9a66e4471 2023-11-19)
Note that
rustfmt 1.7.0-nightly (28317017 2023-11-17)
produces the same output regardless of platform, so I think that the issue only exists in the most recent nightly (rustfmt 1.7.0-nightly (9a66e447 2023-11-19)
) on thenightly-aarch64-apple-darwin
target.Example
CI Output (
nightly-x86_64-unknown-linux-gnu
)Local Output (
nightly-aarch64-apple-darwin
)Output Diff
The text was updated successfully, but these errors were encountered: