UPDATE - accept String instead of unused 'str

This commit is contained in:
Jhonny Bill Mena 2022-08-21 00:42:59 -04:00
parent 359002bbeb
commit bd83bbc93a
2 changed files with 9 additions and 9 deletions

View File

@ -5,24 +5,24 @@
#[derive(SessionDiagnostic)]
#[error(symbol_mangling::invalid_symbol_name)]
pub struct InvalidSymbolName<'a> {
pub struct InvalidSymbolName {
#[primary_span]
pub span: Span,
pub mangled_formatted: &'a str,
pub mangled_formatted: String,
}
#[derive(SessionDiagnostic)]
#[error(symbol_mangling::invalid_trait_item)]
pub struct InvalidTraitItem<'a> {
pub struct InvalidTraitItem {
#[primary_span]
pub span: Span,
pub demangling_formatted: &'a str,
pub demangling_formatted: String,
}
#[derive(SessionDiagnostic)]
#[error(symbol_mangling::alt_invalid_trait_item)]
pub struct AltInvalidTraitItem<'a> {
pub struct AltInvalidTraitItem {
#[primary_span]
pub span: Span,
pub alt_demangling_formatted: &'a str,
pub alt_demangling_formatted: String,
}

View File

@ -62,16 +62,16 @@ fn process_attrs(&mut self, def_id: LocalDefId) {
let mangled = tcx.symbol_name(instance);
tcx.sess.emit_err(InvalidSymbolName {
span: attr.span,
mangled_formatted: &format!("{mangled}"),
mangled_formatted: format!("{mangled}"),
});
if let Ok(demangling) = rustc_demangle::try_demangle(mangled.name) {
tcx.sess.emit_err(InvalidTraitItem {
span: attr.span,
demangling_formatted: &format!("{demangling}"),
demangling_formatted: format!("{demangling}"),
});
tcx.sess.emit_err(AltInvalidTraitItem {
span: attr.span,
alt_demangling_formatted: &format!("{:#}", demangling),
alt_demangling_formatted: format!("{:#}", demangling),
});
}
}