Rollup merge of #146391 - beepster4096:trimnt, r=saethlin

Trim paths less in MIR dumping

With this PR, the paths MIR dump filters and that are printed at the start of a dump file are no longer trimmed. They don't include the crate that is being compiled, however.
This commit is contained in:
Matthias Krüger 2025-09-10 14:17:40 +02:00 committed by GitHub
commit 212baec446
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 12 additions and 10 deletions

View file

@ -78,8 +78,9 @@ impl<'dis, 'de, 'tcx> MirDumper<'dis, 'de, 'tcx> {
pub fn new(tcx: TyCtxt<'tcx>, pass_name: &'static str, body: &Body<'tcx>) -> Option<Self> {
let dump_enabled = if let Some(ref filters) = tcx.sess.opts.unstable_opts.dump_mir {
// see notes on #41697 below
let node_path =
ty::print::with_forced_impl_filename_line!(tcx.def_path_str(body.source.def_id()));
let node_path = ty::print::with_no_trimmed_paths!(
ty::print::with_forced_impl_filename_line!(tcx.def_path_str(body.source.def_id()))
);
filters.split('|').any(|or_filter| {
or_filter.split('&').all(|and_filter| {
let and_filter_trimmed = and_filter.trim();
@ -173,9 +174,10 @@ impl<'dis, 'de, 'tcx> MirDumper<'dis, 'de, 'tcx> {
// trigger `type_of`, and this can run while we are already attempting to evaluate `type_of`.
pub fn dump_mir_to_writer(&self, body: &Body<'tcx>, w: &mut dyn io::Write) -> io::Result<()> {
// see notes on #41697 above
let def_path = ty::print::with_forced_impl_filename_line!(
self.tcx().def_path_str(body.source.def_id())
);
let def_path =
ty::print::with_no_trimmed_paths!(ty::print::with_forced_impl_filename_line!(
self.tcx().def_path_str(body.source.def_id())
));
// ignore-tidy-odd-backticks the literal below is fine
write!(w, "// MIR for `{def_path}")?;
match body.source.promoted {

View file

@ -1,4 +1,4 @@
// MIR for `drop_in_place` after SimplifyCfg-make_shim
// MIR for `std::ptr::drop_in_place` after SimplifyCfg-make_shim
fn drop_in_place(_1: *mut Test) -> () {
let mut _0: ();

View file

@ -1,4 +1,4 @@
// MIR for `drop_in_place` after SimplifyCfg-make_shim
// MIR for `std::ptr::drop_in_place` after SimplifyCfg-make_shim
fn drop_in_place(_1: *mut Test) -> () {
let mut _0: ();

View file

@ -1,4 +1,4 @@
// MIR for `drop_in_place` before AddMovesForPackedDrops
// MIR for `std::ptr::drop_in_place` before AddMovesForPackedDrops
fn drop_in_place(_1: *mut [String; 42]) -> () {
let mut _0: ();

View file

@ -1,4 +1,4 @@
// MIR for `drop_in_place` before AddMovesForPackedDrops
// MIR for `std::ptr::drop_in_place` before AddMovesForPackedDrops
fn drop_in_place(_1: *mut [String]) -> () {
let mut _0: ();

View file

@ -1,4 +1,4 @@
// MIR for `drop_in_place` before AddMovesForPackedDrops
// MIR for `std::ptr::drop_in_place` before AddMovesForPackedDrops
fn drop_in_place(_1: *mut Vec<i32>) -> () {
let mut _0: ();