Precondition violation when printing 0/1 Rational in nightly rust
This code:
println!("{}", "0/1".parse::<rug::Rational>().unwrap());
Causes precondition violation in nightly rust in slice::from_raw_part
Error: × Main thread panicked.
├─▶ at library/core/src/panicking.rs:152:5
╰─▶ unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the
total size of the slice not to exceed `isize::MAX`
help: set the `RUST_BACKTRACE=1` environment variable to display a backtrace.
thread caused non-unwinding panic. aborting.
[1] 96386 abort ./target/debug/ppl
gavrilikhin_d@mbp:~/Code/ppl (master ±)$ RUST_BACKTRACE=1 ./target/debug/ppl
Error: × Main thread panicked.
├─▶ at library/core/src/panicking.rs:152:5
╰─▶ unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the
total size of the slice not to exceed `isize::MAX`
0: 0x107056c60 - rust_begin_unwind
at /rustc/c9f8f3438a8134a413aa5d4903e0196e44e37bbc/library/std/src/panicking.rs:646
1: 0x107593e88 - core::panicking::panic_nounwind_fmt::runtime::h8fca77982a76b544
at /rustc/c9f8f3438a8134a413aa5d4903e0196e44e37bbc/library/core/src/panicking.rs:110
- core::panicking::panic_nounwind_fmt::h14a5f31235a3bc79
at /rustc/c9f8f3438a8134a413aa5d4903e0196e44e37bbc/library/core/src/panicking.rs:120
2: 0x107593f08 - core::panicking::panic_nounwind::hc82fb3e15df99055
at /rustc/c9f8f3438a8134a413aa5d4903e0196e44e37bbc/library/core/src/panicking.rs:152
3: 0x10700e10c - core::slice::raw::from_raw_parts::precondition_check::h05097a1530372809
at /rustc/c9f8f3438a8134a413aa5d4903e0196e44e37bbc/library/core/src/ub_checks.rs:66
4: 0x10700e05c - core::slice::raw::from_raw_parts::he92b593df91fb40b
at /rustc/c9f8f3438a8134a413aa5d4903e0196e44e37bbc/library/core/src/slice/raw.rs:96
5: 0x10700f668 - rug::misc::StringLike::as_str::hdf8623904e3a52aa
at /Users/gavrilikhin_d/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rug-1.24.0/src/
misc.rs:262
6: 0x107011cb4 - rug::rational::big::append_to_string::h463da818521a0808
at /Users/gavrilikhin_d/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rug-1.24.0/src/
rational/big.rs:3029
7: 0x107012940 - rug::rational::traits::fmt_radix::h3e8468e3de22ca6c
at /Users/gavrilikhin_d/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rug-1.24.0/src/
rational/traits.rs:323
8: 0x107012890 - rug::rational::traits::<impl core::fmt::Display for
rug::rational::big::Rational>::fmt::hfc11d647529e16d9
at /Users/gavrilikhin_d/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rug-1.24.0/src/
rational/traits.rs:90
9: 0x1070711d0 - core::fmt::rt::Argument::fmt::h6aca2d3b1141d3cd
at /rustc/c9f8f3438a8134a413aa5d4903e0196e44e37bbc/library/core/src/fmt/rt.rs:142
- core::fmt::write::ha84fc24b2f574968
at /rustc/c9f8f3438a8134a413aa5d4903e0196e44e37bbc/library/core/src/fmt/mod.rs:1153
10: 0x107050acc - std::io::Write::write_fmt::hba00957b8741c727
at /rustc/c9f8f3438a8134a413aa5d4903e0196e44e37bbc/library/std/src/io/mod.rs:1843
- <&std::io::stdio::Stdout as std::io::Write>::write_fmt::he852fd30bd553d53
at /rustc/c9f8f3438a8134a413aa5d4903e0196e44e37bbc/library/std/src/io/stdio.rs:776
11: 0x107051ce0 - <std::io::stdio::Stdout as std::io::Write>::write_fmt::h4920aa5ec1e68855
at /rustc/c9f8f3438a8134a413aa5d4903e0196e44e37bbc/library/std/src/io/stdio.rs:750
- std::io::stdio::print_to::hc1afb2c0faad1893
at /rustc/c9f8f3438a8134a413aa5d4903e0196e44e37bbc/library/std/src/io/stdio.rs:1087
- std::io::stdio::_print::hf81b4c1e8d155c26
at /rustc/c9f8f3438a8134a413aa5d4903e0196e44e37bbc/library/std/src/io/stdio.rs:1164
12: 0x104b39914 - ppl::main::h082e7793de8f4d11
at /Users/gavrilikhin_d/Code/ppl/src/main.rs:128
13: 0x104b30f6c - core::ops::function::FnOnce::call_once::hcdcaeb2df177fde8
at /rustc/c9f8f3438a8134a413aa5d4903e0196e44e37bbc/library/core/src/ops/function.rs:250
help: set the `RUST_BACKTRACE=1` environment variable to display a backtrace.