Open
Description
Problem
cargo install
panics on some non-ASCII input.
I executed this command: cargo install greĉ
.
Then cargo paniced with message:
thread 'main' panicked at 'byte index 4 is not a char boundary; it is inside 'ĉ' (bytes 3..5) of `greĉ`', library/core/src/str/mod.rs:127:5
Steps
- Execute
cargo install greĉ
Possible Solution(s)
_ => format!("{}/{}{}{}", &dep_name[0..2], &dep_name[2..4], slash, name),
causes the panic.
If one rewrite this code avoiding division on possibly invalid position issue will be solved.
Notes
Backtrace:
0: rust_begin_unwind
at /rustc/801821d1560f84e4716fcbd9244ec959320a13d5/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /rustc/801821d1560f84e4716fcbd9244ec959320a13d5/library/core/src/panicking.rs:142:14
2: core::str::slice_error_fail_rt
3: core::ops::function::FnOnce::call_once
at /rustc/801821d1560f84e4716fcbd9244ec959320a13d5/library/core/src/ops/function.rs:248:5
4: core::intrinsics::const_eval_select
at /rustc/801821d1560f84e4716fcbd9244ec959320a13d5/library/core/src/intrinsics.rs:2485:5
5: core::str::slice_error_fail
at /rustc/801821d1560f84e4716fcbd9244ec959320a13d5/library/core/src/str/mod.rs:86:9
6: cargo_util::registry::make_dep_path
7: <cargo::sources::registry::index::RegistryIndex>::summaries
8: <cargo::sources::registry::index::RegistryIndex>::query_inner_with_online
9: <cargo::sources::registry::RegistrySource as cargo::core::source::Source>::query
10: cargo::ops::common_for_install_and_uninstall::select_dep_pkg::<alloc::boxed::Box<dyn cargo::core::source::Source>>
11: <cargo::ops::cargo_install::InstallablePackage>::new
12: cargo::ops::cargo_install::install
13: cargo::commands::install::exec
14: cargo::cli::main
15: cargo::main
Version
cargo 1.65.0-nightly (efd4ca3dc 2022-08-12)