/src/test/ui/consts/const-eval/const_panic_2021.rs

https://gitlab.com/rust-lang/rust · Rust · 34 lines · 12 code · 11 blank · 11 comment · 0 complexity · dd0cc05b56b72203518efdcae69f211b MD5 · raw file

  1. // edition:2021
  2. #![crate_type = "lib"]
  3. const MSG: &str = "hello";
  4. const A: () = std::panic!("blåhaj");
  5. //~^ ERROR evaluation of constant value failed
  6. const B: () = std::panic!();
  7. //~^ ERROR evaluation of constant value failed
  8. const C: () = std::unreachable!();
  9. //~^ ERROR evaluation of constant value failed
  10. const D: () = std::unimplemented!();
  11. //~^ ERROR evaluation of constant value failed
  12. const E: () = std::panic!("{}", MSG);
  13. //~^ ERROR evaluation of constant value failed
  14. const A_CORE: () = core::panic!("shark");
  15. //~^ ERROR evaluation of constant value failed
  16. const B_CORE: () = core::panic!();
  17. //~^ ERROR evaluation of constant value failed
  18. const C_CORE: () = core::unreachable!();
  19. //~^ ERROR evaluation of constant value failed
  20. const D_CORE: () = core::unimplemented!();
  21. //~^ ERROR evaluation of constant value failed
  22. const E_CORE: () = core::panic!("{}", MSG);
  23. //~^ ERROR evaluation of constant value failed