Skip to content

deriving should give expn_info #13150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/libsyntax/ext/deriving/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt,
mitem: @MetaItem,
item: @Item,
push: |@Item|) {
assert!(span.expn_info.is_some(), "derived trait should have expn_info set");
let trait_def = TraitDef {
span: span,
attributes: Vec::new(),
Expand Down
2 changes: 2 additions & 0 deletions src/libsyntax/ext/deriving/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ impl<'a> TraitDef<'a> {
InternedString::new("automatically_derived")));
let opt_trait_ref = Some(trait_ref);
let ident = ast_util::impl_pretty_name(&opt_trait_ref, self_type);
assert!(self.span.expn_info.is_some(), "Should have expansion info")
cx.item(
self.span,
ident,
Expand Down Expand Up @@ -613,6 +614,7 @@ impl<'a> MethodDef<'a> {
Vec::new()
};

assert!(trait_.span.expn_info.is_some(), "Should have expansion info")
// Create the method.
@ast::Method {
ident: method_ident,
Expand Down
13 changes: 12 additions & 1 deletion src/libsyntax/ext/deriving/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ library.

use ast::{Item, MetaItem, MetaList, MetaNameValue, MetaWord};
use ext::base::ExtCtxt;
use codemap;
use codemap::Span;

pub mod clone;
Expand Down Expand Up @@ -65,7 +66,17 @@ pub fn expand_meta_deriving(cx: &mut ExtCtxt,
MetaNameValue(ref tname, _) |
MetaList(ref tname, _) |
MetaWord(ref tname) => {
macro_rules! expand(($func:path) => ($func(cx, titem.span,
let mut span = titem.span;
span.expn_info = Some(@codemap::ExpnInfo {
call_site: span,
callee: codemap::NameAndSpan {
name: format!("deriving({})", tname.get()),
format: codemap::MacroAttribute,
span: None,
}
});

macro_rules! expand(($func:path) => ($func(cx, span,
titem, item,
|i| push(i))));
match tname.get() {
Expand Down