Skip to content

Fix install message misalignment#4768

Open
Cloud0310 wants to merge 1 commit intorust-lang:mainfrom
Cloud0310:install-message-fix
Open

Fix install message misalignment#4768
Cloud0310 wants to merge 1 commit 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.

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

3 participants