ADD - InvalidSymbolName to migrate symbol-name({}) error to new diagnostics infraestructure
ADD - dependencies needed to port a module to new Diagnostics infra (rustc_macros, rustc_errors, errors file, and fluent file)
This commit is contained in:
parent
230a8ee364
commit
86f8c4e8e3
@ -4155,7 +4155,9 @@ dependencies = [
|
||||
"punycode",
|
||||
"rustc-demangle",
|
||||
"rustc_data_structures",
|
||||
"rustc_errors",
|
||||
"rustc_hir",
|
||||
"rustc_macros",
|
||||
"rustc_middle",
|
||||
"rustc_session",
|
||||
"rustc_span",
|
||||
|
@ -0,0 +1 @@
|
||||
symbol_mangling_invalid_symbol_name = symbol-name({$mangled_formatted})
|
@ -52,6 +52,7 @@
|
||||
ty_utils => "../locales/en-US/ty_utils.ftl",
|
||||
typeck => "../locales/en-US/typeck.ftl",
|
||||
mir_dataflow => "../locales/en-US/mir_dataflow.ftl",
|
||||
symbol_mangling => "../locales/en-US/symbol_mangling.ftl",
|
||||
}
|
||||
|
||||
pub use fluent_generated::{self as fluent, DEFAULT_LOCALE_RESOURCES};
|
||||
|
@ -18,3 +18,5 @@ rustc_hir = { path = "../rustc_hir" }
|
||||
rustc_target = { path = "../rustc_target" }
|
||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||
rustc_session = { path = "../rustc_session" }
|
||||
rustc_macros = { path = "../rustc_macros" }
|
||||
rustc_errors = { path = "../rustc_errors" }
|
||||
|
12
compiler/rustc_symbol_mangling/src/errors.rs
Normal file
12
compiler/rustc_symbol_mangling/src/errors.rs
Normal file
@ -0,0 +1,12 @@
|
||||
//! Errors emitted by symbol_mangling.
|
||||
|
||||
use rustc_macros::SessionDiagnostic;
|
||||
use rustc_span::Span;
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(symbol_mangling::invalid_symbol_name)]
|
||||
pub struct InvalidSymbolName<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub mangled_formatted: &'a str,
|
||||
}
|
@ -110,6 +110,7 @@
|
||||
mod legacy;
|
||||
mod v0;
|
||||
|
||||
pub mod errors;
|
||||
pub mod test;
|
||||
pub mod typeid;
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
//! def-path. This is used for unit testing the code that generates
|
||||
//! paths etc in all kinds of annoying scenarios.
|
||||
|
||||
use crate::errors::InvalidSymbolName;
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
use rustc_middle::ty::{subst::InternalSubsts, Instance, TyCtxt};
|
||||
@ -59,7 +60,10 @@ fn process_attrs(&mut self, def_id: LocalDefId) {
|
||||
tcx.erase_regions(InternalSubsts::identity_for_item(tcx, def_id)),
|
||||
);
|
||||
let mangled = tcx.symbol_name(instance);
|
||||
tcx.sess.span_err(attr.span, &format!("symbol-name({})", mangled));
|
||||
tcx.sess.emit_err(InvalidSymbolName {
|
||||
span: attr.span,
|
||||
mangled_formatted: &format!("{mangled}"),
|
||||
});
|
||||
if let Ok(demangling) = rustc_demangle::try_demangle(mangled.name) {
|
||||
tcx.sess.span_err(attr.span, &format!("demangling({})", demangling));
|
||||
tcx.sess.span_err(attr.span, &format!("demangling-alt({:#})", demangling));
|
||||
|
Loading…
Reference in New Issue
Block a user