-
Notifications
You must be signed in to change notification settings - Fork 889
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
implement 2024 expression overflowing #6260
implement 2024 expression overflowing #6260
Conversation
7869b0c
to
65bd027
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went through each commit one by one. They were organized very logically and that made the PR much easier to review. I've very happy to move forward with the PR without any bikesheding!
From a design perspective, there were a few ways I could see that we could potentially utilize for having configuration defaults that could vary by style edition (ordered only for reference, not in any preference/priority):
All of these options have drawbacks, but I opted for option (d) as I think it's the lesser of the evils in the grand scheme of things. The issue with (a) is that while it works and would likely be maintainable for the 2024 edition, it is a tad hacky and overtime would likely grow to be rather unwieldy. The issue with (b) is that there are various configuration options who have cascading effects on other options (e.g. The issue with (c) is that it's inherently inefficient; going through the entire configuration loading process just to determine the derived The downside to the proposed path here, option (d), is that I feel it does bleed some CLI specifics a bit into the configuration loading process. The |
@@ -1,3 +1,4 @@ | |||
error_on_line_overflow = true | |||
error_on_unformatted = true | |||
style_edition = "2024" | |||
overflow_delimited_expr = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this to reduce churn, as the 2024 default (true
) will require some updates to the formatting of the rustfmt codebase itself
@@ -210,7 +208,7 @@ macro_rules! create_config { | |||
)+ | |||
|
|||
#[allow(unreachable_pub)] | |||
pub fn default_with_style_edition(style_edition: StyleEdition) -> Config { | |||
pub(super) fn default_with_style_edition(style_edition: StyleEdition) -> Config { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may have just been caught up in the difficulty of naming things, but I did feel odd having this function as well as default_for_possible_style_edition
. While the function names imply a lot of overlap, I do feel they are doing very different things.
This function is very much instantiating a config with the provided style edition, whereas default_for_possible_style_edition
is more of a "figure out what style edition we should be using, and then give me the default config for that style edition"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth adding doc comments to explain what each function's purpose is within the codebase.
pub(super) fn from_toml(toml: &str, dir: &Path) -> Result<Config, String> { | ||
Self::from_toml_for_style_edition(toml, dir, None, None, None) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I debated with myself whether this was necessary, but I opted to put it in for now so as to reduce the amount of diff in the PR. I think we can consider removing it later and just updating the various call sites (which were all in tests if I recall correctly)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I didn't see any issue with from_toml
, and if it's only used in test code then we don't have to make any changes right now
Ok(parsed_config) => { | ||
if !err.is_empty() { | ||
eprint!("{err}"); | ||
} | ||
Ok(Config::default().fill_from_parsed_config(parsed_config, dir)) | ||
Ok(parsed_config.to_parsed_config(style_edition, edition, version, dir)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also didn't love the parsed_config.to_parsed_config
piece here, as the idents make for a confusing combination. I think this could be avoided with a simple rename but as always naming things is hard 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I saw that and thought the wording was a bit confusing, but nothing too bad to stop us from moving forward with these changes.
I really appreciate you taking the time to outline your thoughts and all the tradeoffs that we could have made here. (d) feels like the best option in my opinion, and it's the one that I likely would have come up with if I was working to implement this. I'm sure we can rework this in the future if it becomes an issue. |
65bd027
to
5a403eb
Compare
Bump stage0 to beta-2024-09-22 and rustfmt to nightly-2024-09-22 I'm doing this to apply the changes to version sorting (rust-lang/rustfmt#6284) that have occurred since rustfmt last upgraded (and a few other miscellaneous changes, like changes to expression overflowing: rust-lang/rustfmt#6260). Eagerly updating rustfmt and formatting-the-world will ideally move some of the pressure off of the beta bump which will happen at the beginning of the next release cycle. You can verify this is correct by checking out the changes, reverting the last commit, reapplying them, and diffing the changes: ``` git fetch [email protected]:compiler-errors/rust.git bump git checkout -b bump FETCH_HEAD git reset --hard HEAD~5 ./x.py fmt --all git diff FETCH_HEAD # ignore the changes to stage0, and rustfmt.toml, # and test file changes in rustdoc-js-std, run-make. ``` Or just take my word for it? Up to the reviewer. r? release
This PR does two things:
overflow_delimited_expr
rust#123751)These two items were combined in the same PR because it's much, much easier to test and demonstrate the former by the latter, and the latter cannot be done without the former.
The vast majority of the diff consists of test snippets taken from existing tests, so shouldn't be as difficult a review as one might infer from the diff numbers. Commits structured in a way that's hopefully logical and conducive to commit-by-commit review
There's a few things we can probably bikeshed on (names, inclusion of helper functions to minimize number of unnecessary callsite changes, etc.) that I'll add inline comments on later
r? @ytmimi