Skip to content

Allow pretty printing paths with -Zself-profile-events=args #144462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions compiler/rustc_data_structures/src/profiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,11 @@ impl SelfProfilerRef {
pub fn get_self_profiler(&self) -> Option<Arc<SelfProfiler>> {
self.profiler.clone()
}

/// Is expensive recording of query keys and/or function arguments enabled?
pub fn is_args_recording_enabled(&self) -> bool {
self.enabled() && self.event_filter_mask.intersects(EventFilter::ARGS)
}
}

/// A helper for recording costly arguments to self-profiling events. Used with
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ impl Session {
|| self.opts.unstable_opts.query_dep_graph
|| self.opts.unstable_opts.dump_mir.is_some()
|| self.opts.unstable_opts.unpretty.is_some()
|| self.prof.is_args_recording_enabled()
|| self.opts.output_types.contains_key(&OutputType::Mir)
|| std::env::var_os("RUSTC_LOG").is_some()
{
Expand Down
4 changes: 4 additions & 0 deletions tests/ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,10 @@ Exercises sanitizer support. See [Sanitizer | The rustc book](https://doc.rust-l

Tests with erroneous ways of using `self`, such as using `this.x` syntax as seen in other languages, having it not be the first argument, or using it in a non-associated function (no `impl` or `trait`). It also contains correct uses of `self` which have previously been observed to cause ICEs.

## `tests/ui/self-profile/`: self-profiling

Tests related to the self-profiler (`-Zself-profile`) functionality of rustc.

## `tests/ui/sepcomp/`: Separate Compilation

In this directory, multiple crates are compiled, but some of them have `inline` functions, meaning they must be inlined into a different crate despite having been compiled separately.
Expand Down
14 changes: 14 additions & 0 deletions tests/ui/self-profile/pretty_print_no_ice.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Checks that when we use `-Zself-profile-events=args`, it is possible to pretty print paths
// using `trimmed_def_paths` even without producing diagnostics.
//
// Issue: <https://github.com/rust-lang/rust/issues/144457>.

//@ compile-flags: -Zself-profile={{build-base}} -Zself-profile-events=args
//@ build-pass

use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::Relaxed;

fn main() {
AtomicUsize::new(0).load(Relaxed);
}
Loading