From 976348603485b216b0d5314eca674a2b24df4c73 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Wed, 16 Feb 2022 13:04:48 -0500 Subject: Move ty::print methods to Drop-based scope guards --- compiler/rustc_const_eval/src/const_eval/eval_queries.rs | 6 +++--- compiler/rustc_const_eval/src/interpret/validity.rs | 2 +- compiler/rustc_const_eval/src/transform/check_consts/ops.rs | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'compiler/rustc_const_eval') 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, -- cgit 1.4.1-3-g733a5