]> git.lizzy.rs Git - rust.git/blob - tests/ui/stdlib-unit-tests/log-knows-the-names-of-variants-in-std.rs
Rollup merge of #107272 - compiler-errors:new-solver-more-predicates, r=lcnr
[rust.git] / tests / ui / stdlib-unit-tests / log-knows-the-names-of-variants-in-std.rs
1 // run-pass
2
3 #![allow(non_camel_case_types)]
4 #![allow(dead_code)]
5 #[derive(Clone, Debug)]
6 enum foo {
7   a(usize),
8   b(String),
9 }
10
11 fn check_log<T: std::fmt::Debug>(exp: String, v: T) {
12     assert_eq!(exp, format!("{:?}", v));
13 }
14
15 pub fn main() {
16     let mut x = Some(foo::a(22));
17     let exp = "Some(a(22))".to_string();
18     let act = format!("{:?}", x);
19     assert_eq!(act, exp);
20     check_log(exp, x);
21
22     x = None;
23     let exp = "None".to_string();
24     let act = format!("{:?}", x);
25     assert_eq!(act, exp);
26     check_log(exp, x);
27 }