Skip to content

Commit 134ef4f

Browse files
Revert "Point macros 1.1 errors to the input item"
This reverts commit 3784067. Any errors in the derived output now point at the derive attribute instead of the item.
1 parent 31a508e commit 134ef4f

File tree

3 files changed

+5
-19
lines changed

3 files changed

+5
-19
lines changed

src/libsyntax_ext/deriving/custom.rs

+3-17
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ use errors::FatalError;
1414
use proc_macro::{TokenStream, __internal};
1515
use syntax::ast::{self, ItemKind, Attribute};
1616
use syntax::attr::{mark_used, mark_known};
17-
use syntax::codemap::{ExpnInfo, MacroAttribute, NameAndSpan, Span};
17+
use syntax::codemap::Span;
1818
use syntax::ext::base::*;
1919
use syntax::fold::Folder;
2020
use syntax::parse::token::InternedString;
21-
use syntax::parse::token::intern;
22-
use syntax::print::pprust;
2321
use syntax::visit::Visitor;
2422

2523
struct MarkAttrs<'a>(&'a [InternedString]);
@@ -50,7 +48,7 @@ impl MultiItemModifier for CustomDerive {
5048
fn expand(&self,
5149
ecx: &mut ExtCtxt,
5250
span: Span,
53-
meta_item: &ast::MetaItem,
51+
_meta_item: &ast::MetaItem,
5452
item: Annotatable)
5553
-> Vec<Annotatable> {
5654
let item = match item {
@@ -75,18 +73,6 @@ impl MultiItemModifier for CustomDerive {
7573
// Mark attributes as known, and used.
7674
MarkAttrs(&self.attrs).visit_item(&item);
7775

78-
let input_span = Span {
79-
expn_id: ecx.codemap().record_expansion(ExpnInfo {
80-
call_site: span,
81-
callee: NameAndSpan {
82-
format: MacroAttribute(intern(&pprust::meta_item_to_string(meta_item))),
83-
span: Some(span),
84-
allow_internal_unstable: true,
85-
},
86-
}),
87-
..item.span
88-
};
89-
9076
let input = __internal::new_token_stream(item.clone());
9177
let res = __internal::set_parse_sess(&ecx.parse_sess, || {
9278
let inner = self.inner;
@@ -113,7 +99,7 @@ impl MultiItemModifier for CustomDerive {
11399
// Reassign spans of all expanded items to the input `item`
114100
// for better errors here.
115101
res.extend(new_items.into_iter().flat_map(|item| {
116-
ChangeSpan { span: input_span }.fold_item(item)
102+
ChangeSpan { span: span }.fold_item(item)
117103
}).map(Annotatable::Item));
118104
res
119105
}

src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable-2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
extern crate derive_unstable_2;
1818

1919
#[derive(Unstable)]
20-
struct A;
2120
//~^ ERROR: reserved for internal compiler
21+
struct A;
2222

2323
fn main() {
2424
foo();

src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
extern crate derive_unstable;
1818

1919
#[derive(Unstable)]
20-
struct A;
2120
//~^ ERROR: use of unstable library feature
21+
struct A;
2222

2323
fn main() {
2424
unsafe { foo(); }

0 commit comments

Comments
 (0)