1
Fork 0

Auto merge of #94062 - Mark-Simulacrum:drop-print-cfg, r=oli-obk

Move ty::print methods to Drop-based scope guards

Primary goal is reducing codegen of the TLS access for each closure, which shaves ~3 seconds of bootstrap time over rustc as a whole.
This commit is contained in:
bors 2022-02-20 18:12:59 +00:00
commit 523a1b1d38
30 changed files with 142 additions and 142 deletions

View file

@ -324,7 +324,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let sole_field_ty = sole_field.ty(self.tcx, substs);
if self.can_coerce(expr_ty, sole_field_ty) {
let variant_path =
with_no_trimmed_paths(|| self.tcx.def_path_str(variant.def_id));
with_no_trimmed_paths!(self.tcx.def_path_str(variant.def_id));
// FIXME #56861: DRYer prelude filtering
if let Some(path) = variant_path.strip_prefix("std::prelude::") {
if let Some((_, path)) = path.split_once("::") {

View file

@ -1346,7 +1346,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let additional_newline = if found_use { "" } else { "\n" };
format!(
"use {};\n{}",
with_crate_prefix(|| self.tcx.def_path_str(*trait_did)),
with_crate_prefix!(self.tcx.def_path_str(*trait_did)),
additional_newline
)
});
@ -1359,7 +1359,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let additional_newline = if found_use { "" } else { "\n" };
format!(
"use {}::*; // trait {}\n{}",
with_crate_prefix(|| self.tcx.def_path_str(*parent_did)),
with_crate_prefix!(self.tcx.def_path_str(*parent_did)),
self.tcx.item_name(*trait_did),
additional_newline
)
@ -1378,12 +1378,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
msg.push_str(&format!(
"\ncandidate #{}: `use {};`",
i + 1,
with_crate_prefix(|| self.tcx.def_path_str(*trait_did))
with_crate_prefix!(self.tcx.def_path_str(*trait_did))
));
} else {
msg.push_str(&format!(
"\n`use {};`",
with_crate_prefix(|| self.tcx.def_path_str(*trait_did))
with_crate_prefix!(self.tcx.def_path_str(*trait_did))
));
}
}
@ -1396,13 +1396,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
msg.push_str(&format!(
"\ncandidate #{}: `use {}::*; // trait {}`",
candidates.len() + i + 1,
with_crate_prefix(|| self.tcx.def_path_str(*parent_did)),
with_crate_prefix!(self.tcx.def_path_str(*parent_did)),
self.tcx.item_name(*trait_did),
));
} else {
msg.push_str(&format!(
"\n`use {}::*; // trait {}`",
with_crate_prefix(|| self.tcx.def_path_str(*parent_did)),
with_crate_prefix!(self.tcx.def_path_str(*parent_did)),
self.tcx.item_name(*trait_did),
));
}
@ -1442,7 +1442,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let Some(did) = edition_fix {
err.note(&format!(
"'{}' is included in the prelude starting in Edition 2021",
with_crate_prefix(|| self.tcx.def_path_str(did))
with_crate_prefix!(self.tcx.def_path_str(did))
));
}

View file

@ -59,7 +59,7 @@ fn opaque_type_bounds<'tcx>(
ast_bounds: &'tcx [hir::GenericBound<'tcx>],
span: Span,
) -> &'tcx [(ty::Predicate<'tcx>, Span)] {
ty::print::with_no_queries(|| {
ty::print::with_no_queries!({
let item_ty =
tcx.mk_opaque(opaque_def_id, InternalSubsts::identity_for_item(tcx, opaque_def_id));