Closed
Description
Hey, I'm trying to learn Rust. I have this code. It's not valid Rust, but it causes the compiler to throw an ICE.
struct Square {
xcoord :i32,
ycoord :i32,
len :i32
}
impl Square {
fn area() {
len * len
}
fn diag() {
len * 2.sqrt()
}
fn quadr() {
match (xcoord, ycoord) {
-_ =>
}
}
}
fn main() {
/// Causes a crash
/// Example usage:
/// ```
/// main() #-> Causes crash
/// ```
let q = vec!(3, 2, 1);
let x = 5_000_000_i32;
let y = &x;
println!("Hello, world! {}", q.len());
assert_eq!(q, [3, 2, 2]) // crashes
}
I ran cargo doc
on it, and was told to file a bug report. Running cargo build
or rustc main.rs
does not cause the panic.
[adam@AdamsPC src]$ RUST_BACKTRACE=1 cargo doc
Documenting kek v0.1.0 (file:///home/adam/kek)
main.rs:16:14: 16:15 error: unexpected token: `_`
main.rs:16 -_ =>
^
main.rs:22:5: 22:37 error: attributes on non-item statements and expressions are experimental. (see issue #15701)
main.rs:22 /// Causes you to crash and shit
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.rs:23:5: 23:23 error: attributes on non-item statements and expressions are experimental. (see issue #15701)
main.rs:23 /// Example usage:
^~~~~~~~~~~~~~~~~~
main.rs:24:5: 24:12 error: attributes on non-item statements and expressions are experimental. (see issue #15701)
main.rs:24 /// ```
^~~~~~~
main.rs:25:5: 25:32 error: attributes on non-item statements and expressions are experimental. (see issue #15701)
main.rs:25 /// main() #-> Causes crash
^~~~~~~~~~~~~~~~~~~~~~~~~~~
main.rs:26:5: 26:12 error: attributes on non-item statements and expressions are experimental. (see issue #15701)
main.rs:26 /// ```
^~~~~~~
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'phase_2_configure_and_expand aborted in rustdoc!: 5', src/libcore/result.rs:746
stack backtrace:
1: 0x7efe3d4fa4e0 - std::sys::backtrace::tracing::imp::write::h4c73fcd3363076f5
2: 0x7efe3d507bdb - std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::h0422dbb3077e6747
3: 0x7efe3d50777c - std::panicking::default_hook::haac48fa641db8fa2
4: 0x7efe3d4cc70f - std::sys_common::unwind::begin_unwind_inner::h39d40f52add53ef7
5: 0x7efe3d4ce7f8 - std::sys_common::unwind::begin_unwind_fmt::h64c0ff793199cc1b
6: 0x7efe3d4f7cf1 - rust_begin_unwind
7: 0x7efe3d5481af - core::panicking::panic_fmt::h73bf9d7e8e891a73
8: 0x7efe3da9b42b - core::result::unwrap_failed::h52d645c697d2a555
9: 0x7efe3da3637d - rustdoc::core::run_core::h5d51993c037675df
10: 0x7efe3da31c08 - std::sys_common::unwind::try::try_fn::he5d0ca3afe34ca3c
11: 0x7efe3d4f7c7b - __rust_try
12: 0x7efe3d4f7c0d - std::sys_common::unwind::inner_try::h9eebd8dc83f388a6
13: 0x7efe3da338ff - _<F as std..boxed..FnBox<A>>::call_box::h871bc6bfba8a323f
14: 0x7efe3d505d74 - std::sys::thread::Thread::new::thread_start::h471ad90789353b5b
15: 0x7efe36288473 - start_thread
16: 0x7efe3d15d69c - clone
17: 0x0 - <unknown>
error: Could not document `kek`.
To learn more, run the command again with --verbose.
Here's the rustc
version. I pulled it down from the Arch repositories yesterday.
rustc 1.9.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.9.0