Skip to content

Commit 090c24f

Browse files
committed
Merge -Zhir-stats into -Zinput-stats
1 parent 12eaa3a commit 090c24f

File tree

10 files changed

+12
-160
lines changed

10 files changed

+12
-160
lines changed

compiler/rustc_ast_passes/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
pub mod ast_validation;
1919
mod errors;
2020
pub mod feature_gate;
21-
pub mod node_count;
2221
pub mod show_span;
2322

2423
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

compiler/rustc_ast_passes/src/node_count.rs

-129
This file was deleted.

compiler/rustc_interface/src/passes.rs

+7-22
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::path::{Path, PathBuf};
55
use std::sync::{Arc, LazyLock};
66
use std::{env, fs, iter};
77

8-
use rustc_ast::{self as ast, visit};
8+
use rustc_ast as ast;
99
use rustc_codegen_ssa::traits::CodegenBackend;
1010
use rustc_data_structures::parallel;
1111
use rustc_data_structures::steal::Steal;
@@ -24,7 +24,7 @@ use rustc_middle::util::Providers;
2424
use rustc_parse::{
2525
new_parser_from_file, new_parser_from_source_str, unwrap_or_emit_fatal, validate_attr,
2626
};
27-
use rustc_passes::{abi_test, hir_stats, layout_test};
27+
use rustc_passes::{abi_test, input_stats, layout_test};
2828
use rustc_resolve::Resolver;
2929
use rustc_session::code_stats::VTableSizeInfo;
3030
use rustc_session::config::{CrateType, Input, OutFileName, OutputFilenames, OutputType};
@@ -54,28 +54,17 @@ pub(crate) fn parse<'a>(sess: &'a Session) -> Result<ast::Crate> {
5454
})
5555
.map_err(|parse_error| parse_error.emit())?;
5656

57-
if sess.opts.unstable_opts.input_stats {
58-
eprintln!("Lines of code: {}", sess.source_map().count_lines());
59-
eprintln!("Pre-expansion node count: {}", count_nodes(&krate));
60-
}
61-
6257
if let Some(ref s) = sess.opts.unstable_opts.show_span {
6358
rustc_ast_passes::show_span::run(sess.dcx(), s, &krate);
6459
}
6560

66-
if sess.opts.unstable_opts.hir_stats {
67-
hir_stats::print_ast_stats(&krate, "PRE EXPANSION AST STATS", "ast-stats-1");
61+
if sess.opts.unstable_opts.input_stats {
62+
input_stats::print_ast_stats(&krate, "PRE EXPANSION AST STATS", "ast-stats-1");
6863
}
6964

7065
Ok(krate)
7166
}
7267

73-
fn count_nodes(krate: &ast::Crate) -> usize {
74-
let mut counter = rustc_ast_passes::node_count::NodeCounter::new();
75-
visit::walk_crate(&mut counter, krate);
76-
counter.count
77-
}
78-
7968
fn pre_expansion_lint<'a>(
8069
sess: &Session,
8170
features: &Features,
@@ -290,11 +279,7 @@ fn early_lint_checks(tcx: TyCtxt<'_>, (): ()) {
290279
let mut lint_buffer = resolver.lint_buffer.steal();
291280

292281
if sess.opts.unstable_opts.input_stats {
293-
eprintln!("Post-expansion node count: {}", count_nodes(krate));
294-
}
295-
296-
if sess.opts.unstable_opts.hir_stats {
297-
hir_stats::print_ast_stats(krate, "POST EXPANSION AST STATS", "ast-stats-2");
282+
input_stats::print_ast_stats(krate, "POST EXPANSION AST STATS", "ast-stats-2");
298283
}
299284

300285
// Needs to go *after* expansion to be able to check the results of macro expansion.
@@ -820,8 +805,8 @@ pub(crate) fn create_global_ctxt<'tcx>(
820805
/// Runs all analyses that we guarantee to run, even if errors were reported in earlier analyses.
821806
/// This function never fails.
822807
fn run_required_analyses(tcx: TyCtxt<'_>) {
823-
if tcx.sess.opts.unstable_opts.hir_stats {
824-
rustc_passes::hir_stats::print_hir_stats(tcx);
808+
if tcx.sess.opts.unstable_opts.input_stats {
809+
rustc_passes::input_stats::print_hir_stats(tcx);
825810
}
826811
#[cfg(debug_assertions)]
827812
rustc_passes::hir_id_validator::check_crate(tcx);

compiler/rustc_interface/src/tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,6 @@ fn test_unstable_options_tracking_hash() {
698698
untracked!(dylib_lto, true);
699699
untracked!(emit_stack_sizes, true);
700700
untracked!(future_incompat_test, true);
701-
untracked!(hir_stats, true);
702701
untracked!(identify_regions, true);
703702
untracked!(incremental_info, true);
704703
untracked!(incremental_verify_ich, true);

compiler/rustc_passes/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub mod entry;
2727
mod errors;
2828
#[cfg(debug_assertions)]
2929
pub mod hir_id_validator;
30-
pub mod hir_stats;
30+
pub mod input_stats;
3131
mod lang_items;
3232
pub mod layout_test;
3333
mod lib_features;

compiler/rustc_session/src/options.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1805,8 +1805,6 @@ options! {
18051805
environment variable `RUSTC_GRAPHVIZ_FONT` (default: `Courier, monospace`)"),
18061806
has_thread_local: Option<bool> = (None, parse_opt_bool, [TRACKED],
18071807
"explicitly enable the `cfg(target_thread_local)` directive"),
1808-
hir_stats: bool = (false, parse_bool, [UNTRACKED],
1809-
"print some statistics about AST and HIR (default: no)"),
18101808
human_readable_cgu_names: bool = (false, parse_bool, [TRACKED],
18111809
"generate human-readable, predictable names for codegen units (default: no)"),
18121810
identify_regions: bool = (false, parse_bool, [UNTRACKED],
@@ -1838,7 +1836,7 @@ options! {
18381836
inline_mir_threshold: Option<usize> = (None, parse_opt_number, [TRACKED],
18391837
"a default MIR inlining threshold (default: 50)"),
18401838
input_stats: bool = (false, parse_bool, [UNTRACKED],
1841-
"gather statistics about the input (default: no)"),
1839+
"print some statistics about AST and HIR (default: no)"),
18421840
instrument_mcount: bool = (false, parse_bool, [TRACKED],
18431841
"insert function instrument code for mcount-based tracing (default: no)"),
18441842
instrument_xray: Option<InstrumentXRay> = (None, parse_instrument_xray, [TRACKED],

tests/ui/stats/hir-stats.rs renamed to tests/ui/stats/input-stats.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ check-pass
2-
//@ compile-flags: -Zhir-stats
2+
//@ compile-flags: -Zinput-stats
33
//@ only-64bit
44
// layout randomization affects the hir stat output
55
//@ needs-deterministic-layouts
@@ -11,7 +11,7 @@
1111

1212

1313
// The aim here is to include at least one of every different type of top-level
14-
// AST/HIR node reported by `-Zhir-stats`.
14+
// AST/HIR node reported by `-Zinput-stats`.
1515

1616
#![allow(dead_code)]
1717

File renamed without changes.

triagebot.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ message = "This PR changes a file inside `tests/crashes`. If a crash was fixed,
886886
message = "Changes to the code generated for builtin derived traits."
887887
cc = ["@nnethercote"]
888888

889-
[mentions."tests/ui/stats/hir-stats.stderr"]
889+
[mentions."tests/ui/stats/input-stats.stderr"]
890890
message = "Changes to the size of AST and/or HIR nodes."
891891
cc = ["@nnethercote"]
892892

0 commit comments

Comments
 (0)