• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #![deny(clippy::all, clippy::pedantic)]
2 #![allow(dead_code)]
3 
4 use std::fmt::{self, Display};
5 use std::io;
6 use thiserror::Error;
7 
8 macro_rules! unimplemented_display {
9     ($ty:ty) => {
10         impl Display for $ty {
11             fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result {
12                 unimplemented!()
13             }
14         }
15     };
16 }
17 
18 #[derive(Error, Debug)]
19 struct BracedError {
20     msg: String,
21     pos: usize,
22 }
23 
24 #[derive(Error, Debug)]
25 struct TupleError(String, usize);
26 
27 #[derive(Error, Debug)]
28 struct UnitError;
29 
30 #[derive(Error, Debug)]
31 struct WithSource {
32     #[source]
33     cause: io::Error,
34 }
35 
36 #[derive(Error, Debug)]
37 struct WithAnyhow {
38     #[source]
39     cause: anyhow::Error,
40 }
41 
42 #[derive(Error, Debug)]
43 enum EnumError {
44     Braced {
45         #[source]
46         cause: io::Error,
47     },
48     Tuple(#[source] io::Error),
49     Unit,
50 }
51 
52 unimplemented_display!(BracedError);
53 unimplemented_display!(TupleError);
54 unimplemented_display!(UnitError);
55 unimplemented_display!(WithSource);
56 unimplemented_display!(WithAnyhow);
57 unimplemented_display!(EnumError);
58