cranelift_codegen/
dbg.rs

1//! Debug tracing helpers.
2use core::fmt;
3
4/// Prefix added to the log file names, just before the thread name or id.
5pub static LOG_FILENAME_PREFIX: &str = "cranelift.dbg.";
6
7/// Helper for printing lists.
8pub struct DisplayList<'a, T>(pub &'a [T])
9where
10    T: 'a + fmt::Display;
11
12impl<'a, T> fmt::Display for DisplayList<'a, T>
13where
14    T: 'a + fmt::Display,
15{
16    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
17        match self.0.split_first() {
18            None => write!(f, "[]"),
19            Some((first, rest)) => {
20                write!(f, "[{first}")?;
21                for x in rest {
22                    write!(f, ", {x}")?;
23                }
24                write!(f, "]")
25            }
26        }
27    }
28}