Use the new attributes throughout the codebase
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
use std::mem;
|
||||
use std::{mem, slice};
|
||||
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::visit::{self, Visitor};
|
||||
use rustc_ast::{self as ast, NodeId, attr};
|
||||
use rustc_ast::{self as ast, HasNodeId, NodeId, attr};
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_attr_data_structures::AttributeKind;
|
||||
use rustc_attr_parsing::AttributeParser;
|
||||
use rustc_errors::DiagCtxtHandle;
|
||||
use rustc_expand::base::{ExtCtxt, ResolverExpand, parse_macro_name_and_helper_attrs};
|
||||
use rustc_expand::base::{ExtCtxt, ResolverExpand};
|
||||
use rustc_expand::expand::{AstFragment, ExpansionConfig};
|
||||
use rustc_feature::Features;
|
||||
use rustc_session::Session;
|
||||
@@ -22,7 +24,7 @@ struct ProcMacroDerive {
|
||||
trait_name: Symbol,
|
||||
function_ident: Ident,
|
||||
span: Span,
|
||||
attrs: Vec<Symbol>,
|
||||
attrs: ThinVec<Symbol>,
|
||||
}
|
||||
|
||||
struct ProcMacroDef {
|
||||
@@ -41,6 +43,7 @@ struct CollectProcMacros<'a> {
|
||||
macros: Vec<ProcMacro>,
|
||||
in_root: bool,
|
||||
dcx: DiagCtxtHandle<'a>,
|
||||
session: &'a Session,
|
||||
source_map: &'a SourceMap,
|
||||
is_proc_macro_crate: bool,
|
||||
is_test_crate: bool,
|
||||
@@ -63,6 +66,7 @@ pub fn inject(
|
||||
macros: Vec::new(),
|
||||
in_root: true,
|
||||
dcx,
|
||||
session: sess,
|
||||
source_map: sess.source_map(),
|
||||
is_proc_macro_crate,
|
||||
is_test_crate,
|
||||
@@ -98,8 +102,18 @@ impl<'a> CollectProcMacros<'a> {
|
||||
function_ident: Ident,
|
||||
attr: &'a ast::Attribute,
|
||||
) {
|
||||
let Some((trait_name, proc_attrs)) =
|
||||
parse_macro_name_and_helper_attrs(self.dcx, attr, "derive")
|
||||
let Some(rustc_hir::Attribute::Parsed(AttributeKind::ProcMacroDerive {
|
||||
trait_name,
|
||||
helper_attrs,
|
||||
..
|
||||
})) = AttributeParser::parse_limited(
|
||||
self.session,
|
||||
slice::from_ref(attr),
|
||||
sym::proc_macro_derive,
|
||||
item.span,
|
||||
item.node_id(),
|
||||
None,
|
||||
)
|
||||
else {
|
||||
return;
|
||||
};
|
||||
@@ -110,7 +124,7 @@ impl<'a> CollectProcMacros<'a> {
|
||||
span: item.span,
|
||||
trait_name,
|
||||
function_ident,
|
||||
attrs: proc_attrs,
|
||||
attrs: helper_attrs,
|
||||
}));
|
||||
} else {
|
||||
let msg = if !self.in_root {
|
||||
|
||||
Reference in New Issue
Block a user