about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2022-02-16 13:04:48 -0500
committerMark Rousskov <mark.simulacrum@gmail.com>2022-02-16 17:24:23 -0500
commit976348603485b216b0d5314eca674a2b24df4c73 (patch)
tree4b18e40496faf663e6101f16272682fd67120be2 /compiler/rustc_const_eval/src
parent393fdc10483da930cdbb00eabc3635030d2e776f (diff)
downloadrust-976348603485b216b0d5314eca674a2b24df4c73.tar.gz
rust-976348603485b216b0d5314eca674a2b24df4c73.zip
Move ty::print methods to Drop-based scope guards
Diffstat (limited to 'compiler/rustc_const_eval/src')
-rw-r--r--compiler/rustc_const_eval/src/const_eval/eval_queries.rs6
-rw-r--r--compiler/rustc_const_eval/src/interpret/validity.rs2
-rw-r--r--compiler/rustc_const_eval/src/transform/check_consts/ops.rs7
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,