/src/test/codegen-units/item-collection/implicit-panic-call.rs

https://gitlab.com/rust-lang/rust · Rust · 58 lines · 39 code · 12 blank · 7 comment · 2 complexity · 05ae77b2eaf6b39ca73bb5a1261b7140 MD5 · raw file

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