1
Fork 0

use pretty_print_const_value from MIR constant 'extra' printing

This commit is contained in:
Ralf Jung 2023-09-15 08:21:40 +02:00
parent 10a822be38
commit 57444cf9f3
6 changed files with 167 additions and 142 deletions

View file

@ -47,6 +47,8 @@ extern crate cfg_if;
#[macro_use]
extern crate rustc_macros;
use std::fmt;
pub use rustc_index::static_assert_size;
#[inline(never)]
@ -126,6 +128,23 @@ impl<F: FnOnce()> Drop for OnDrop<F> {
}
}
/// Turns a closure that takes an `&mut Formatter` into something that can be display-formatted.
pub fn make_display(f: impl Fn(&mut fmt::Formatter<'_>) -> fmt::Result) -> impl fmt::Display {
struct Printer<F> {
f: F,
}
impl<F> fmt::Display for Printer<F>
where
F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result,
{
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
(self.f)(fmt)
}
}
Printer { f }
}
// See comments in src/librustc_middle/lib.rs
#[doc(hidden)]
pub fn __noop_fix_for_27438() {}