Skip to content

some cleanup in rustc_session - #159398

Open
hkBst wants to merge 1 commit into
rust-lang:mainfrom
hkBst:rustc-session-cleanup-1
Open

some cleanup in rustc_session#159398
hkBst wants to merge 1 commit into
rust-lang:mainfrom
hkBst:rustc-session-cleanup-1

Conversation

@hkBst

@hkBst hkBst commented Jul 16, 2026

Copy link
Copy Markdown
Member

No description provided.

@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. labels Jul 16, 2026
@rustbot

rustbot commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

r? @eholk

rustbot has assigned @eholk.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 19 candidates

Comment on lines +1361 to 1362
let mut v: Vec<&str> = v.unwrap_or_default().split(",").collect();
v.sort_unstable();

@hkBst hkBst Jul 16, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new code does not reset the slot to an empty Vec for a None argument. I'm curious to see if that matters.

View changes since the review

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would cause -Zoffload= to no longer override -Zoffload=a,b,c and instead silently get igbored, right? That is inconsistent with other cli flags where the last occurence does win.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is true, but at the same time, the empty value is the only one that overrides in this way: -Zoffload=a -Zoffload=b is the same as -Zoffload=a,b not as `-Zoffload=b', so it seems to already be inconsistent.

Anyway, no change was intended, so I'll revert. Thanks for explaining the significance to me!

@bjorn3 bjorn3 Jul 19, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-Zoffload=a -Zoffload=b is the same as -Zoffload=a,b not as `-Zoffload=b'

Huh, that is inconsistent with other args that use parse_comma_list.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the reset only happens for an empty argument.

@hkBst hkBst Jul 21, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function just before doesn't do a reset ever. Should it?

pub(crate) fn parse_dump_mono_stats(slot: &mut DumpMonoStatsFormat, v: Option<&str>) -> bool {
    match v {
        None => true, // hkBst: empty arg, no reset <-----
        Some("json") => {
            *slot = DumpMonoStatsFormat::Json;
            true
        }
        Some("markdown") => {
            *slot = DumpMonoStatsFormat::Markdown;
            true
        }
        Some(_) => false,
    }
}

@hkBst hkBst changed the title cleanup some cleanup in rustc_session Jul 16, 2026
let mut v: Vec<&str> = v.unwrap_or_default().split(",").collect();
v.sort_unstable();
for &val in v.iter() {
v.iter().all(|val| {

@bjorn3 bjorn3 Jul 17, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think using side-effects inside of an iterator method is an improvement.

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that that is not ideal, but I think that disadvantage is outweighed by the advantage of showing this is an all combinator instead of some random for loop that just happens to be a manual implementation of the all combinator.

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants