Skip to content

Instantly share code, notes, and snippets.

@Snaipe
Last active September 30, 2015 13:47
Show Gist options
  • Save Snaipe/db898ece69435f88760c to your computer and use it in GitHub Desktop.
Save Snaipe/db898ece69435f88760c to your computer and use it in GitHub Desktop.
panic
struct extra_data {
int foo,
int bar,
};
struct data_type {
const char *str;
struct extra_data *data;
};
static struct extra_data extra = { .foo = 0, .bar = 1 };
static const struct data_type data = {
.str = "Hello, world",
.data = &extra
};
__attribute__((section("some_section")))
static const struct data_type *data_ptr = &data;
int main(void) { return 0; }
struct ExtraData {
foo: i32,
bar: i32,
}
struct DataType {
str: *const u8,
data: *mut ExtraData,
}
unsafe impl Sync for ExtraData { }
unsafe impl Sync for DataType { }
static mut EXTRA_DATA : ExtraData = ExtraData {
foo: 0,
bar: 1,
};
static DATA : DataType = DataType {
str: b"hello world\0" as *const u8,
data: unsafe { &mut EXTRA_DATA }
};
#[link_section="some_section"]
static DATA_PTR : *const DataType = &DATA;
fn main() {
}
$ RUST_BACKTRACE=1 rustc panic.rs
panic.rs:1:1: 4:2 warning: struct is never used: `ExtraData`, #[warn(dead_code)] on by default
panic.rs:1 struct ExtraData {
panic.rs:2 foo: i32,
panic.rs:3 bar: i32,
panic.rs:4 }
panic.rs:2:5: 2:13 warning: struct field is never used: `foo`, #[warn(dead_code)] on by default
panic.rs:2 foo: i32,
^~~~~~~~
panic.rs:3:5: 3:13 warning: struct field is never used: `bar`, #[warn(dead_code)] on by default
panic.rs:3 bar: i32,
^~~~~~~~
panic.rs:6:1: 9:2 warning: struct is never used: `DataType`, #[warn(dead_code)] on by default
panic.rs:6 struct DataType {
panic.rs:7 str: *const u8,
panic.rs:8 data: *mut ExtraData,
panic.rs:9 }
panic.rs:7:5: 7:19 warning: struct field is never used: `str`, #[warn(dead_code)] on by default
panic.rs:7 str: *const u8,
^~~~~~~~~~~~~~
panic.rs:8:5: 8:25 warning: struct field is never used: `data`, #[warn(dead_code)] on by default
panic.rs:8 data: *mut ExtraData,
^~~~~~~~~~~~~~~~~~~~
panic.rs:14:1: 17:7 warning: static item is never used: `EXTRA_DATA`, #[warn(dead_code)] on by default
panic.rs:14 static mut EXTRA_DATA : ExtraData = ExtraData {
panic.rs:15 foo: 0,
panic.rs:16 bar: 1,
panic.rs:17 };
panic.rs:19:1: 22:7 warning: static item is never used: `DATA`, #[warn(dead_code)] on by default
panic.rs:19 static DATA : DataType = DataType {
panic.rs:20 str: b"hello world\0" as *const u8,
panic.rs:21 data: unsafe { &mut EXTRA_DATA }
panic.rs:22 };
panic.rs:25:1: 25:43 warning: static item is never used: `DATA_PTR`, #[warn(dead_code)] on by default
panic.rs:25 static DATA_PTR : *const DataType = &DATA;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
panic.rs:21:29: 21:39 error: internal compiler error: expected a const, fn, struct, or variant def
panic.rs:21 data: unsafe { &mut EXTRA_DATA }
^~~~~~~~~~
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
thread 'rustc' panicked at 'Box<Any>', src/libsyntax/diagnostic.rs:176
stack backtrace:
1: 0x7f6706dcf66e - sys::backtrace::write::ha67a6a2049d22fadIvs
2: 0x7f6706dd7d55 - panicking::on_panic::hfa4bf0215983f759lzx
3: 0x7f6706d9894e - rt::unwind::begin_unwind_inner::ha1b5da93bdf7e8ffC0w
4: 0x7f67041becdc - rt::unwind::begin_unwind::h10002216390169315342
5: 0x7f67041bec7b - diagnostic::SpanHandler::span_bug::h6d3d1eb598e37d9aX6A
6: 0x7f6704c8dcf8 - session::Session::span_bug::h103bc02ef373c2e4nRt
7: 0x7f6705c357ad - trans::consts::const_expr_unadjusted::h1d2d83c04c480e728Et
8: 0x7f6705c32e7f - trans::consts::const_expr::h08aedd7988733ed6Yot
9: 0x7f6705c35a1c - trans::consts::const_expr_unadjusted::h1d2d83c04c480e728Et
10: 0x7f6705c32e7f - trans::consts::const_expr::h08aedd7988733ed6Yot
11: 0x7f6705c34fce - trans::consts::const_expr_unadjusted::h1d2d83c04c480e728Et
12: 0x7f6705c32e7f - trans::consts::const_expr::h08aedd7988733ed6Yot
13: 0x7f6705c3e727 - trans::consts::const_expr_unadjusted::closure.49914
14: 0x7f6705c3e593 - vec::Vec<T>.FromIterator<T>::from_iter::h17887475302167253138
15: 0x7f6705c3e089 - trans::consts::const_expr_unadjusted::closure.49903
16: 0x7f6705c36212 - trans::consts::const_expr_unadjusted::h1d2d83c04c480e728Et
17: 0x7f6705c32e7f - trans::consts::const_expr::h08aedd7988733ed6Yot
18: 0x7f6705bdc493 - trans::base::trans_item::hd3ac3af06c93993fPdj
19: 0x7f6705be940c - trans::base::trans_crate::h14e6ea6d455593f8i0j
20: 0x7f670733e2f4 - driver::phase_4_translate_to_llvm::h8ce7c7bfb0fd9b185Oa
21: 0x7f6707338885 - driver::phase_3_run_analysis_passes::closure.16542
22: 0x7f6707332ab1 - middle::ty::ctxt<'tcx>::create_and_enter::h9578579149294230291
23: 0x7f670732d991 - driver::phase_3_run_analysis_passes::h8415522514568150077
24: 0x7f6707311a90 - driver::compile_input::h52c7dafd49963360Tba
25: 0x7f67073f7a63 - run_compiler::h473c62e00f865fa9A7b
26: 0x7f67073f54de - boxed::F.FnBox<A>::call_box::h10713159552398332324
27: 0x7f67073f4e09 - rt::unwind::try::try_fn::h16887904248528792425
28: 0x7f6706dd784d - __rust_try
29: 0x7f6706dc28f7 - rt::unwind::try::inner_try::hafffff77ddacfa5fvWw
30: 0x7f67073f5028 - boxed::F.FnBox<A>::call_box::h5417278073590676257
31: 0x7f6706dd6991 - sys::thread::Thread::new::thread_start::h29dca2a2cf2294b535v
32: 0x7f6701678353 - start_thread
33: 0x7f6706a34bfc - __clone
34: 0x0 - <unknown>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment