]> git.lizzy.rs Git - rust.git/commitdiff
migrate debugger_visualizer.rs to translateable diagnostics
authorNathan Stocks <cleancut@github.com>
Thu, 22 Sep 2022 04:55:29 +0000 (22:55 -0600)
committerNathan Stocks <cleancut@github.com>
Fri, 7 Oct 2022 19:19:27 +0000 (13:19 -0600)
compiler/rustc_passes/src/debugger_visualizer.rs

index e08683fe23b2019819cecd30edaef55b8f0b1307..253b0a88e48aa69590a0972bc17eb29e29661c44 100644 (file)
@@ -13,6 +13,8 @@
 
 use std::sync::Arc;
 
+use crate::errors::DebugVisualizerUnreadable;
+
 fn check_for_debugger_visualizer<'tcx>(
     tcx: TyCtxt<'tcx>,
     hir_id: HirId,
@@ -54,13 +56,12 @@ fn check_for_debugger_visualizer<'tcx>(
                     debugger_visualizers
                         .insert(DebuggerVisualizerFile::new(Arc::from(contents), visualizer_type));
                 }
-                Err(err) => {
-                    tcx.sess
-                        .struct_span_err(
-                            meta_item.span,
-                            &format!("couldn't read {}: {}", file.display(), err),
-                        )
-                        .emit();
+                Err(error) => {
+                    tcx.sess.emit_err(DebugVisualizerUnreadable {
+                        span: meta_item.span,
+                        file: &file,
+                        error,
+                    });
                 }
             }
         }