1
Fork 0

Auto merge of #118405 - matthiaskrgr:rollup-3a2eevc, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #115331 (optimize str::iter::Chars::advance_by)
 - #118236 (Update mod comment)
 - #118299 (Update `OnceLock` documentation to give a concrete 'lazy static' example, and expand on the existing example.)
 - #118314 (Rename `{collections=>alloc}{tests,benches}`)
 - #118341 (Simplify indenting in THIR printing)
 - #118366 (Detect and reject malformed `repr(Rust)` hints)
 - #118397 (Fix comments for unsigned non-zero `checked_add`, `saturating_add`)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2023-11-28 10:21:41 +00:00
commit 46a24ed2f4
13 changed files with 174 additions and 29 deletions

View file

@ -31,8 +31,8 @@ const INDENT: &str = " ";
macro_rules! print_indented {
($writer:ident, $s:expr, $indent_lvl:expr) => {
let indent = (0..$indent_lvl).map(|_| INDENT).collect::<Vec<_>>().concat();
writeln!($writer, "{}{}", indent, $s).expect("unable to write to ThirPrinter");
$writer.indent($indent_lvl);
writeln!($writer, "{}", $s).expect("unable to write to ThirPrinter");
};
}
@ -48,6 +48,12 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
Self { thir, fmt: String::new() }
}
fn indent(&mut self, level: usize) {
for _ in 0..level {
self.fmt.push_str(INDENT);
}
}
fn print(&mut self) {
print_indented!(self, "params: [", 0);
for param in self.thir.params.iter() {