Skip to content

Commit b88d62e

Browse files
authored
Rollup merge of #117615 - bjorn3:misc_changes, r=davidtwco
Couple of small changes These are unrelated to each other, but they are each small enough that opening separate PR's doesn't make sense to me either. * Remove a place where the parse driver query is stolen. * Update an outdated doc comment * Use correct crate name in `-Zprint-vtable-sizes` when using `#![crate_name = "..."]`.
2 parents ec35c03 + ec29a02 commit b88d62e

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

compiler/rustc_codegen_ssa/src/traits/backend.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,7 @@ pub trait CodegenBackend {
104104
outputs: &OutputFilenames,
105105
) -> Result<(CodegenResults, FxIndexMap<WorkProductId, WorkProduct>), ErrorGuaranteed>;
106106

107-
/// This is called on the returned `Box<dyn Any>` from `join_codegen`
108-
///
109-
/// # Panics
110-
///
111-
/// Panics when the passed `Box<dyn Any>` was not returned by `join_codegen`.
107+
/// This is called on the returned `CodegenResults` from `join_codegen`
112108
fn link(
113109
&self,
114110
sess: &Session,

compiler/rustc_driver_impl/src/lib.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ use rustc_session::cstore::MetadataLoader;
4141
use rustc_session::getopts::{self, Matches};
4242
use rustc_session::lint::{Lint, LintId};
4343
use rustc_session::{config, EarlyErrorHandler, Session};
44+
use rustc_span::def_id::LOCAL_CRATE;
4445
use rustc_span::source_map::FileLoader;
4546
use rustc_span::symbol::sym;
4647
use rustc_span::FileName;
@@ -421,8 +422,12 @@ fn run_compiler(
421422
// effects of writing the dep-info and reporting errors.
422423
queries.global_ctxt()?.enter(|tcx| tcx.output_filenames(()));
423424
} else {
424-
let krate = queries.parse()?.steal();
425-
pretty::print(sess, *ppm, pretty::PrintExtra::AfterParsing { krate });
425+
let krate = queries.parse()?;
426+
pretty::print(
427+
sess,
428+
*ppm,
429+
pretty::PrintExtra::AfterParsing { krate: &*krate.borrow() },
430+
);
426431
}
427432
trace!("finished pretty-printing");
428433
return early_exit();
@@ -477,8 +482,7 @@ fn run_compiler(
477482
}
478483

479484
if sess.opts.unstable_opts.print_vtable_sizes {
480-
let crate_name =
481-
compiler.session().opts.crate_name.as_deref().unwrap_or("<UNKNOWN_CRATE>");
485+
let crate_name = queries.global_ctxt()?.enter(|tcx| tcx.crate_name(LOCAL_CRATE));
482486

483487
sess.code_stats.print_vtable_sizes(crate_name);
484488
}

compiler/rustc_driver_impl/src/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ fn write_or_print(out: &str, sess: &Session) {
217217
// Extra data for pretty-printing, the form of which depends on what kind of
218218
// pretty-printing we are doing.
219219
pub enum PrintExtra<'tcx> {
220-
AfterParsing { krate: ast::Crate },
220+
AfterParsing { krate: &'tcx ast::Crate },
221221
NeedsAstMap { tcx: TyCtxt<'tcx> },
222222
}
223223

compiler/rustc_session/src/code_stats.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl CodeStats {
226226
}
227227
}
228228

229-
pub fn print_vtable_sizes(&self, crate_name: &str) {
229+
pub fn print_vtable_sizes(&self, crate_name: Symbol) {
230230
let mut infos =
231231
std::mem::take(&mut *self.vtable_sizes.lock()).into_values().collect::<Vec<_>>();
232232

Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "E", "entries": "6", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "2", "upcasting_cost_percent": "50" }
2-
print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "G", "entries": "14", "entries_ignoring_upcasting": "11", "entries_for_upcasting": "3", "upcasting_cost_percent": "27.27272727272727" }
3-
print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "A", "entries": "6", "entries_ignoring_upcasting": "5", "entries_for_upcasting": "1", "upcasting_cost_percent": "20" }
4-
print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "B", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" }
5-
print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "D", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" }
6-
print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "F", "entries": "6", "entries_ignoring_upcasting": "6", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" }
7-
print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "_::S", "entries": "3", "entries_ignoring_upcasting": "3", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" }
8-
print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "_::S", "entries": "3", "entries_ignoring_upcasting": "3", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" }
9-
print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "help::MarkerWithSuper", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" }
10-
print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "help::Super", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" }
11-
print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "help::V", "entries": "3", "entries_ignoring_upcasting": "3", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" }
1+
print-vtable-sizes { "crate_name": "print_vtable_sizes", "trait_name": "E", "entries": "6", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "2", "upcasting_cost_percent": "50" }
2+
print-vtable-sizes { "crate_name": "print_vtable_sizes", "trait_name": "G", "entries": "14", "entries_ignoring_upcasting": "11", "entries_for_upcasting": "3", "upcasting_cost_percent": "27.27272727272727" }
3+
print-vtable-sizes { "crate_name": "print_vtable_sizes", "trait_name": "A", "entries": "6", "entries_ignoring_upcasting": "5", "entries_for_upcasting": "1", "upcasting_cost_percent": "20" }
4+
print-vtable-sizes { "crate_name": "print_vtable_sizes", "trait_name": "B", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" }
5+
print-vtable-sizes { "crate_name": "print_vtable_sizes", "trait_name": "D", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" }
6+
print-vtable-sizes { "crate_name": "print_vtable_sizes", "trait_name": "F", "entries": "6", "entries_ignoring_upcasting": "6", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" }
7+
print-vtable-sizes { "crate_name": "print_vtable_sizes", "trait_name": "_::S", "entries": "3", "entries_ignoring_upcasting": "3", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" }
8+
print-vtable-sizes { "crate_name": "print_vtable_sizes", "trait_name": "_::S", "entries": "3", "entries_ignoring_upcasting": "3", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" }
9+
print-vtable-sizes { "crate_name": "print_vtable_sizes", "trait_name": "help::MarkerWithSuper", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" }
10+
print-vtable-sizes { "crate_name": "print_vtable_sizes", "trait_name": "help::Super", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" }
11+
print-vtable-sizes { "crate_name": "print_vtable_sizes", "trait_name": "help::V", "entries": "3", "entries_ignoring_upcasting": "3", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" }

0 commit comments

Comments
 (0)