Migrate derivable diagnostics in check_attr.rs
This commit is contained in:
parent
17a4a68ab0
commit
0315d7c9db
@ -217,6 +217,8 @@ passes_debug_visualizer_invalid = invalid argument
|
||||
.note_2 = OR
|
||||
.note_3 = expected: `gdb_script_file = "..."`
|
||||
|
||||
passes_debug_visualizer_unreadable = couldn't read {$file}: {$error}
|
||||
|
||||
passes_rustc_allow_const_fn_unstable = attribute should be applied to `const fn`
|
||||
.label = not a `const fn`
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
//! conflicts between multiple such attributes attached to the same
|
||||
//! item.
|
||||
|
||||
use crate::errors;
|
||||
use crate::errors::{self, DebugVisualizerUnreadable};
|
||||
use rustc_ast::{ast, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::{fluent, struct_span_err, Applicability, MultiSpan};
|
||||
@ -1863,13 +1863,11 @@ fn check_debugger_visualizer(&self, attr: &Attribute, target: Target) -> bool {
|
||||
match std::fs::File::open(&file) {
|
||||
Ok(_) => true,
|
||||
Err(err) => {
|
||||
self.tcx
|
||||
.sess
|
||||
.struct_span_err(
|
||||
meta_item.span,
|
||||
&format!("couldn't read {}: {}", file.display(), err),
|
||||
)
|
||||
.emit();
|
||||
self.tcx.sess.emit_err(DebugVisualizerUnreadable {
|
||||
span: meta_item.span,
|
||||
file: &file,
|
||||
error: err,
|
||||
} );
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
use std::{io::Error, path::Path};
|
||||
|
||||
use rustc_errors::{Applicability, MultiSpan};
|
||||
use rustc_hir::Target;
|
||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||
@ -527,6 +529,15 @@ pub struct DebugVisualizerInvalid {
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(passes::debug_visualizer_unreadable)]
|
||||
pub struct DebugVisualizerUnreadable<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub file: &'a Path,
|
||||
pub error: Error,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(passes::rustc_allow_const_fn_unstable)]
|
||||
pub struct RustcAllowConstFnUnstable {
|
||||
|
Loading…
Reference in New Issue
Block a user