diff options
| author | bors <bors@rust-lang.org> | 2022-02-20 18:12:59 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-02-20 18:12:59 +0000 |
| commit | 523a1b1d388bfe82a5d0540b876d9428b6dccc9c (patch) | |
| tree | 0df7073fb1bcab18729dd7194ec8e4b5d1176531 /compiler/rustc_const_eval/src | |
| parent | c1aa85475cf5623caf50f7ef3b62903bb084e518 (diff) | |
| parent | 976348603485b216b0d5314eca674a2b24df4c73 (diff) | |
| download | rust-523a1b1d388bfe82a5d0540b876d9428b6dccc9c.tar.gz rust-523a1b1d388bfe82a5d0540b876d9428b6dccc9c.zip | |
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.
Diffstat (limited to 'compiler/rustc_const_eval/src')
3 files changed, 8 insertions, 7 deletions
diff --git a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs index bfb9c40be57..11eda987b97 100644 --- a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs @@ -53,7 +53,7 @@ fn eval_body_using_ecx<'mir, 'tcx>( trace!( "eval_body_using_ecx: pushing stack frame for global: {}{}", - with_no_trimmed_paths(|| ty::tls::with(|tcx| tcx.def_path_str(cid.instance.def_id()))), + with_no_trimmed_paths!(ty::tls::with(|tcx| tcx.def_path_str(cid.instance.def_id()))), cid.promoted.map_or_else(String::new, |p| format!("::promoted[{:?}]", p)) ); @@ -274,7 +274,7 @@ pub fn eval_to_allocation_raw_provider<'tcx>( // The next two lines concatenated contain some discussion: // https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/ // subject/anon_const_instance_printing/near/135980032 - let instance = with_no_trimmed_paths(|| key.value.instance.to_string()); + let instance = with_no_trimmed_paths!(key.value.instance.to_string()); trace!("const eval: {:?} ({})", key, instance); } @@ -317,7 +317,7 @@ pub fn eval_to_allocation_raw_provider<'tcx>( // the expression, leading to the const eval error. let instance = &key.value.instance; if !instance.substs.is_empty() { - let instance = with_no_trimmed_paths(|| instance.to_string()); + let instance = with_no_trimmed_paths!(instance.to_string()); let msg = format!("evaluation of `{}` failed", instance); Cow::from(msg) } else { diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index 4060bee7e05..e95e327618f 100644 --- a/compiler/rustc_const_eval/src/interpret/validity.rs +++ b/compiler/rustc_const_eval/src/interpret/validity.rs @@ -33,7 +33,7 @@ macro_rules! throw_validation_failure { msg.push_str(", but expected "); write!(&mut msg, $($expected_fmt),+).unwrap(); )? - let path = rustc_middle::ty::print::with_no_trimmed_paths(|| { + let path = rustc_middle::ty::print::with_no_trimmed_paths!({ let where_ = &$where; if !where_.is_empty() { let mut path = String::new(); diff --git a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs index 8c3f8e88164..888c4b997dc 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs @@ -108,9 +108,10 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> { .as_ref() .and_then(|node| node.generics()) { - let constraint = with_no_trimmed_paths(|| { - format!("~const {}", trait_ref.print_only_trait_path()) - }); + let constraint = with_no_trimmed_paths!(format!( + "~const {}", + trait_ref.print_only_trait_path() + )); suggest_constraining_type_param( tcx, generics, |
