Skip to content

rustup component list --toolchain stable panics #3547

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
majaha opened this issue Dec 1, 2023 · 1 comment · Fixed by #3548
Closed

rustup component list --toolchain stable panics #3547

majaha opened this issue Dec 1, 2023 · 1 comment · Fixed by #3548

Comments

@majaha
Copy link
Contributor

majaha commented Dec 1, 2023

Running rustup component list --toolchain stable panics on the current master branch. I tested this on 94d41c6.

It seems to be a problem with Clap. I don't know enough about clap to tell you why the type checker can't catch this kind of error, but if that's the case maybe this could do with some test coverage?

Here's the problem code:

let toolchain = m.get_one::<ResolvableToolchainName>("toolchain");

The Clap docs: https://docs.rs/clap/latest/clap/struct.ArgMatches.html#method.get_one

and a backtrace:

> RUST_BACKTRACE=full RUSTUP_DEBUG=1 RUSTUP_HOME=home CARGO_HOME=home home/bin/rustup component list --toolchain stable
thread 'main' panicked at src\cli\rustup_mode.rs:1409:23:
Mismatch between definition and access of `toolchain`. Could not downcast to rustup::toolchain::names::ResolvableToolchainName, need to downcast to rustup::dist::dist::PartialToolchainDesc

stack backtrace:
   0:     0x7ff759f6e8fa - std::sys_common::backtrace::_print::impl$0::fmt
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common\backtrace.rs:44
   1:     0x7ff759f966eb - core::fmt::rt::Argument::fmt
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\core\src\fmt\rt.rs:138
   2:     0x7ff759f966eb - core::fmt::write
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\core\src\fmt\mod.rs:1094
   3:     0x7ff759f689d1 - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\io\mod.rs:1714
   4:     0x7ff759f6e67a - std::sys_common::backtrace::_print
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common\backtrace.rs:47
   5:     0x7ff759f6e67a - std::sys_common::backtrace::print
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common\backtrace.rs:34
   6:     0x7ff759f715da - std::panicking::default_hook::closure$1
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:270
   7:     0x7ff759f71248 - std::panicking::default_hook
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:290
   8:     0x7ff7590f2e93 - alloc::boxed::impl$49::call<tuple$<ref$<core::panic::panic_info::PanicInfo> >,dyn$<core::ops::function::Fn<tuple$<ref$<core::panic::panic_info::PanicInfo> >,assoc$<Output,tuple$<> > >,core::marker::Send,core::marker::Sync>,alloc::alloc::Global>
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\alloc\src\boxed.rs:2021
   9:     0x7ff7590f20e6 - rustup::currentprocess::with::closure$0::closure$0<rustup_init::main::closure_env$0,tuple$<> >
                               at D:\programming\repos\rustup\src\currentprocess.rs:146
  10:     0x7ff759f71e1c - alloc::boxed::impl$49::call
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\alloc\src\boxed.rs:2021
  11:     0x7ff759f71e1c - std::panicking::rust_panic_with_hook
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:711
  12:     0x7ff759f71b7d - std::panicking::begin_panic_handler::closure$0
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:599
  13:     0x7ff759f6f5b9 - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common\backtrace.rs:170
  14:     0x7ff759f71880 - std::panicking::begin_panic_handler
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:595
  15:     0x7ff75a115945 - core::panicking::panic_fmt
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\core\src\panicking.rs:67
  16:     0x7ff75930a99f - enum2$<clap_builder::parser::error::MatchesError>::unwrap<enum2$<core::option::Option<ref$<enum2$<rustup::toolchain::names::ResolvableToolchainName> > > > >
                               at C:\Users\Matt\.cargo\registry\src\index.crates.io-6f17d22bba15001f\clap_builder-4.4.8\src\parser\error.rs:32
  17:     0x7ff7591ef91a - clap_builder::parser::matches::arg_matches::ArgMatches::get_one<enum2$<rustup::toolchain::names::ResolvableToolchainName> >
                               at C:\Users\Matt\.cargo\registry\src\index.crates.io-6f17d22bba15001f\clap_builder-4.4.8\src\parser\matches\arg_matches.rs:115
  18:     0x7ff7591421ec - rustup::cli::rustup_mode::explicit_or_dir_toolchain
                               at D:\programming\repos\rustup\src\cli\rustup_mode.rs:1409
  19:     0x7ff759141318 - rustup::cli::rustup_mode::component_list
                               at D:\programming\repos\rustup\src\cli\rustup_mode.rs:1358
  20:     0x7ff75912d6f2 - rustup::cli::rustup_mode::main
                               at D:\programming\repos\rustup\src\cli\rustup_mode.rs:195
  21:     0x7ff7590f2a1b - rustup_init::run_rustup_inner
                               at D:\programming\repos\rustup\src\bin\rustup-init.rs:130
  22:     0x7ff7590f2633 - rustup_init::run_rustup
                               at D:\programming\repos\rustup\src\bin\rustup-init.rs:111
  23:     0x7ff7590f2511 - rustup_init::maybe_trace_rustup
                               at D:\programming\repos\rustup\src\bin\rustup-init.rs:51
  24:     0x7ff7590f2d7b - rustup_init::main::closure$0
                               at D:\programming\repos\rustup\src\bin\rustup-init.rs:39
  25:     0x7ff7590f1f76 - rustup::currentprocess::with::closure$1<rustup_init::main::closure_env$0,tuple$<> >
                               at D:\programming\repos\rustup\src\currentprocess.rs:155
  26:     0x7ff7590f1368 - std::thread::local::LocalKey<core::cell::RefCell<enum2$<core::option::Option<enum2$<rustup::currentprocess::Process> > > > >::try_with<core::cell::RefCell<enum2$<core::option::Option<enum2$<rustup::currentprocess::Process> > > >,rustup::currentprocess::wi
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\thread\local.rs:270
  27:     0x7ff7590f1256 - std::thread::local::LocalKey<core::cell::RefCell<enum2$<core::option::Option<enum2$<rustup::currentprocess::Process> > > > >::with<core::cell::RefCell<enum2$<core::option::Option<enum2$<rustup::currentprocess::Process> > > >,rustup::currentprocess::with::
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\thread\local.rs:246
  28:     0x7ff7590f1d19 - rustup::currentprocess::with<rustup_init::main::closure_env$0,tuple$<> >
                               at D:\programming\repos\rustup\src\currentprocess.rs:150
  29:     0x7ff7590f24f8 - rustup_init::main
                               at D:\programming\repos\rustup\src\bin\rustup-init.rs:39
  30:     0x7ff7590f222b - core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\core\src\ops\function.rs:250
  31:     0x7ff7590f106e - std::sys_common::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> >
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\sys_common\backtrace.rs:154
  32:     0x7ff7590f106e - std::sys_common::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> >
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\sys_common\backtrace.rs:154
  33:     0x7ff7590f2f61 - std::rt::lang_start::closure$0<tuple$<> >
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\rt.rs:166
  34:     0x7ff759f5e2f8 - std::rt::lang_start_internal::closure$2
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\rt.rs:148
  35:     0x7ff759f5e2f8 - std::panicking::try::do_call
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:502
  36:     0x7ff759f5e2f8 - std::panicking::try
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:466
  37:     0x7ff759f5e2f8 - std::panic::catch_unwind
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panic.rs:142
  38:     0x7ff759f5e2f8 - std::rt::lang_start_internal
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\rt.rs:148
  39:     0x7ff7590f2f3a - std::rt::lang_start<tuple$<> >
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\rt.rs:165
  40:     0x7ff7590f2d59 - main
  41:     0x7ff75a112b84 - invoke_main
                               at D:\agent\_work\10\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  42:     0x7ff75a112b84 - __scrt_common_main_seh
                               at D:\agent\_work\10\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  43:     0x7ffc689e7344 - BaseThreadInitThunk
  44:     0x7ffc697a26b1 - RtlUserThreadStart
@majaha
Copy link
Contributor Author

majaha commented Dec 1, 2023

I would guess that it's this line:

.value_parser(partial_toolchain_desc_parser)

from this commit:
2c9297d
where it broke.

Changing the line in rustup_mode.rs to PartialToolchainDesc would probably fix the immediate problem. Still not sure if there's a more type-safe way to do the right thing.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant