diff options
Diffstat (limited to 'compiler/rustc_passes/src/debugger_visualizer.rs')
| -rw-r--r-- | compiler/rustc_passes/src/debugger_visualizer.rs | 54 | 
1 files changed, 18 insertions, 36 deletions
| diff --git a/compiler/rustc_passes/src/debugger_visualizer.rs b/compiler/rustc_passes/src/debugger_visualizer.rs index 8305830bc98..9b9ee93f63d 100644 --- a/compiler/rustc_passes/src/debugger_visualizer.rs +++ b/compiler/rustc_passes/src/debugger_visualizer.rs @@ -21,9 +21,8 @@ fn check_for_debugger_visualizer<'tcx>( let attrs = tcx.hir().attrs(hir_id); for attr in attrs { if attr.has_name(sym::debugger_visualizer) { - let list = match attr.meta_item_list() { - Some(list) => list, - _ => continue, + let Some(list) = attr.meta_item_list() else { + continue }; let meta_item = match list.len() { @@ -34,45 +33,28 @@ fn check_for_debugger_visualizer<'tcx>( _ => continue, }; - let file = match (meta_item.name_or_empty(), meta_item.value_str()) { - (sym::natvis_file, Some(value)) => { + let visualizer_type = match meta_item.name_or_empty() { + sym::natvis_file => DebuggerVisualizerType::Natvis, + sym::gdb_script_file => DebuggerVisualizerType::GdbPrettyPrinter, + _ => continue, + }; + + let file = match meta_item.value_str() { + Some(value) => { match resolve_path(&tcx.sess.parse_sess, value.as_str(), attr.span) { Ok(file) => file, - Err(mut err) => { - err.emit(); - continue; - } + _ => continue, } } - (_, _) => continue, + None => continue, }; - if file.is_file() { - let contents = match std::fs::read(&file) { - Ok(contents) => contents, - Err(err) => { - tcx.sess - .struct_span_err( - attr.span, - &format!( - "Unable to read contents of file `{}`. {}", - file.display(), - err - ), - ) - .emit(); - continue; - } - }; - - debugger_visualizers.insert(DebuggerVisualizerFile::new( - Arc::from(contents), - DebuggerVisualizerType::Natvis, - )); - } else { - tcx.sess - .struct_span_err(attr.span, &format!("{} is not a valid file", file.display())) - .emit(); + match std::fs::read(&file) { + Ok(contents) => { + debugger_visualizers + .insert(DebuggerVisualizerFile::new(Arc::from(contents), visualizer_type)); + } + _ => {} } } } | 
