]> git.lizzy.rs Git - rust.git/blob - src/test/codegen-units/item-collection/implicit-panic-call.rs
rustdoc-json: Make the `fns/generics.rs` test much more robust
[rust.git] / src / test / codegen-units / item-collection / implicit-panic-call.rs
1 // compile-flags:-Zprint-mono-items=lazy
2
3 // rust-lang/rust#90405
4 // Ensure implicit panic calls are collected
5
6 #![feature(lang_items)]
7 #![feature(no_core)]
8 #![crate_type = "lib"]
9 #![no_core]
10 #![no_std]
11
12 #[lang = "panic_location"]
13 struct Location<'a> {
14     _file: &'a str,
15     _line: u32,
16     _col: u32,
17 }
18
19 #[lang = "panic"]
20 #[inline]
21 #[track_caller]
22 fn panic(_: &'static str) -> ! {
23     loop {}
24 }
25
26 #[lang = "sized"]
27 trait Sized {}
28
29 #[lang = "copy"]
30 trait Copy {}
31
32 #[lang = "freeze"]
33 trait Freeze {}
34
35 impl Copy for i32 {}
36
37 #[lang = "div"]
38 trait Div<Rhs = Self> {
39     type Output;
40     fn div(self, rhs: Rhs) -> Self::Output;
41 }
42
43 impl Div for i32 {
44     type Output = i32;
45     fn div(self, rhs: i32) -> i32 {
46         self / rhs
47     }
48 }
49
50 #[allow(unconditional_panic)]
51 pub fn foo() {
52     // This implicitly generates a panic call.
53     let _ = 1 / 0;
54 }
55
56 //~ MONO_ITEM fn foo
57 //~ MONO_ITEM fn <i32 as Div>::div
58 //~ MONO_ITEM fn panic