Ok(Some(ext))
}
- fn resolve_macro_path(&mut self, path: &ast::Path, kind: MacroKind, invoc_id: Mark,
- derives_in_scope: Vec<ast::Path>, force: bool)
- -> Result<Lrc<SyntaxExtension>, Determinacy> {
- let parent_scope = self.invoc_parent_scope(invoc_id, derives_in_scope);
- Ok(self.resolve_macro_to_res(path, kind, &parent_scope, false, force)?.1)
- }
-
fn check_unused_macros(&self) {
for (&node_id, &span) in self.unused_macros.iter() {
self.session.buffer_lint(
fn resolve_macro_invocation(&mut self, invoc: &Invocation, invoc_id: Mark, force: bool)
-> Result<Option<Lrc<SyntaxExtension>>, Determinacy>;
- fn resolve_macro_path(&mut self, path: &ast::Path, kind: MacroKind, invoc_id: Mark,
- derives_in_scope: Vec<ast::Path>, force: bool)
- -> Result<Lrc<SyntaxExtension>, Determinacy>;
fn check_unused_macros(&self);
}
Derive {
path: Path,
item: Annotatable,
+ item_with_markers: Annotatable,
},
}
derives.reserve(traits.len());
invocations.reserve(traits.len());
- for path in &traits {
+ for path in traits {
let mark = Mark::fresh(self.cx.current_expansion.mark);
derives.push(mark);
- let item = match self.cx.resolver.resolve_macro_path(
- path, MacroKind::Derive, Mark::root(), Vec::new(), false) {
- Ok(ext) => match ext.kind {
- SyntaxExtensionKind::LegacyDerive(..) => item_with_markers.clone(),
- _ => item.clone(),
- },
- _ => item.clone(),
- };
invocations.push(Invocation {
- kind: InvocationKind::Derive { path: path.clone(), item },
+ kind: InvocationKind::Derive {
+ path,
+ item: item.clone(),
+ item_with_markers: item_with_markers.clone(),
+ },
fragment_kind: invoc.fragment_kind,
expansion_data: ExpansionData {
mark,
ext: &SyntaxExtension)
-> Option<AstFragment> {
let (path, item) = match invoc.kind {
- InvocationKind::Derive { path, item } => (path, item),
+ InvocationKind::Derive { path, item, item_with_markers } => match ext.kind {
+ SyntaxExtensionKind::LegacyDerive(..) => (path, item_with_markers),
+ _ => (path, item),
+ }
_ => unreachable!(),
};
if !item.derive_allowed() {