Skip to content

Fix install message misalignment#4768

Open
Cloud0310 wants to merge 3 commits intorust-lang:mainfrom
Cloud0310:install-message-fix
Open

Fix install message misalignment#4768
Cloud0310 wants to merge 3 commits intorust-lang:mainfrom
Cloud0310:install-message-fix

Conversation

@Cloud0310
Copy link

@Cloud0310 Cloud0310 commented Mar 22, 2026

Fix #4759 with dynamic name width.

don't know how to test the output yet.....
@Cloud0310
Copy link
Author

Cloud0310 commented Mar 22, 2026

image

The formatted result would be like this.
Still, I don't have an good way to test out whether the fix on rustup update instantly (after tormorrow's nightly build is out I could test out this?).
For now, I added a const var for default minimal name width with value 15.
And for the illustrated component of llvm-bitcode-linker (19 chars) in the picture, the name length scaled as wished.

Thanks @rami3l for helping me out on this small issue here.

Copy link
Member

@rami3l rami3l left a comment

Choose a reason for hiding this comment

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

Looks great in general modulo some tiny nits. Thanks a lot for helping out!

View changes since this review

}

impl DownloadStatus {
fn style(&self, suffix: &str) -> ProgressStyle {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Consider extracting this to a standalone function and to be used above as well, since the only dependency on &self is self.name_width().

You can make this clearer by extracting this function in the first commit which is separate from other changes with a fix named_width = 13, and then add the name_width parameter.

.replace(DEFAULT_DIST_SERVER, dl_cfg.tmp_cx.dist_server.as_str());

let status = dl_cfg.status_for("rust");
let status = dl_cfg.status_for("rust", 15);
Copy link
Member

Choose a reason for hiding this comment

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

I think given the fact that the only component name is "rust" in v1, we'd just do:

let component = "rust"; let status = dl_cfg.status_for(component, component.len());

let max_name_width = update
.components_to_install
.iter()
.map(|component| new_manifest.short_name(component).len())
Copy link
Member

Choose a reason for hiding this comment

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

Nit: This implementation implicitly relied on the fact that .short_name() will be used in ComponentBinary for the component name.

Suggest extracting a function ComponentBinary::(component: Component, manifest: &'a Manifest) and use that on both sides instead.

progress.set_style(
ProgressStyle::with_template(
"{msg:>13.bold} downloading [{bar:15}] {total_bytes:>11} ({bytes_per_sec}, ETA: {eta})",
&format!("{{msg:>{}.bold}} downloading [{{bar:15}}] {{total_bytes:>11}} ({{bytes_per_sec}}, ETA: {{eta}})", name_width)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I think it's clearer to use the new style format!() both here and in other places, e.g. "{{msg:>{name_width}.bold}} ...

@FranciscoTGouveia
Copy link
Contributor

Still, I don't have an good way to test out whether the fix on rustup update instantly (after tormorrow's nightly build is out I could test out this?)

If you change the hash in .rustup/update-hashes/<some-toolchain> and remove the .rustup/toolchains/<some-toolchain>/lib/rustlib/multirust-channel-manifest.toml, you can force an update of that toolchain.

@rustbot
Copy link
Collaborator

rustbot commented Mar 24, 2026

This PR was rebased onto a different main 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.

@Cloud0310 Cloud0310 force-pushed the install-message-fix branch from 455ce11 to dfb927b Compare March 24, 2026 16:02
@Cloud0310
Copy link
Author

@rami3l Thanks for your code style suggestions, I refactored the code, and tested with @FranciscoTGouveia method.
image
Seems to me everything is fine?

@rami3l rami3l self-assigned this Mar 24, 2026
Copy link
Member

@rami3l rami3l left a comment

Choose a reason for hiding this comment

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

The overall logic looks fine to me now. Nice!

It must be noted though, in terms of history manipulation in nontrivial rustup PRs like this, it will require some more work to be done.

Basically we use atomic commits here so if there's one refactoring plus one new feature in the total list of changes that'd be two commits (and preferably refactoring comes first).

I suggest you do the same thing with this PR: split it into one or two refactoring PRs beforehand, and finally introduce the new feature. After that we can go back to the implementation details.

Many thanks in advance 🙏

View changes since this review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

installation output could be more column-y

4 participants