mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Revert "Point macros 1.1 errors to the input item"
This reverts commit 3784067edc
.
Any errors in the derived output now point at the derive attribute
instead of the item.
This commit is contained in:
parent
31a508e118
commit
134ef4f793
@ -14,12 +14,10 @@ use errors::FatalError;
|
||||
use proc_macro::{TokenStream, __internal};
|
||||
use syntax::ast::{self, ItemKind, Attribute};
|
||||
use syntax::attr::{mark_used, mark_known};
|
||||
use syntax::codemap::{ExpnInfo, MacroAttribute, NameAndSpan, Span};
|
||||
use syntax::codemap::Span;
|
||||
use syntax::ext::base::*;
|
||||
use syntax::fold::Folder;
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax::parse::token::intern;
|
||||
use syntax::print::pprust;
|
||||
use syntax::visit::Visitor;
|
||||
|
||||
struct MarkAttrs<'a>(&'a [InternedString]);
|
||||
@ -50,7 +48,7 @@ impl MultiItemModifier for CustomDerive {
|
||||
fn expand(&self,
|
||||
ecx: &mut ExtCtxt,
|
||||
span: Span,
|
||||
meta_item: &ast::MetaItem,
|
||||
_meta_item: &ast::MetaItem,
|
||||
item: Annotatable)
|
||||
-> Vec<Annotatable> {
|
||||
let item = match item {
|
||||
@ -75,18 +73,6 @@ impl MultiItemModifier for CustomDerive {
|
||||
// Mark attributes as known, and used.
|
||||
MarkAttrs(&self.attrs).visit_item(&item);
|
||||
|
||||
let input_span = Span {
|
||||
expn_id: ecx.codemap().record_expansion(ExpnInfo {
|
||||
call_site: span,
|
||||
callee: NameAndSpan {
|
||||
format: MacroAttribute(intern(&pprust::meta_item_to_string(meta_item))),
|
||||
span: Some(span),
|
||||
allow_internal_unstable: true,
|
||||
},
|
||||
}),
|
||||
..item.span
|
||||
};
|
||||
|
||||
let input = __internal::new_token_stream(item.clone());
|
||||
let res = __internal::set_parse_sess(&ecx.parse_sess, || {
|
||||
let inner = self.inner;
|
||||
@ -113,7 +99,7 @@ impl MultiItemModifier for CustomDerive {
|
||||
// Reassign spans of all expanded items to the input `item`
|
||||
// for better errors here.
|
||||
res.extend(new_items.into_iter().flat_map(|item| {
|
||||
ChangeSpan { span: input_span }.fold_item(item)
|
||||
ChangeSpan { span: span }.fold_item(item)
|
||||
}).map(Annotatable::Item));
|
||||
res
|
||||
}
|
||||
|
@ -17,8 +17,8 @@
|
||||
extern crate derive_unstable_2;
|
||||
|
||||
#[derive(Unstable)]
|
||||
struct A;
|
||||
//~^ ERROR: reserved for internal compiler
|
||||
struct A;
|
||||
|
||||
fn main() {
|
||||
foo();
|
||||
|
@ -17,8 +17,8 @@
|
||||
extern crate derive_unstable;
|
||||
|
||||
#[derive(Unstable)]
|
||||
struct A;
|
||||
//~^ ERROR: use of unstable library feature
|
||||
struct A;
|
||||
|
||||
fn main() {
|
||||
unsafe { foo(); }
|
||||
|
Loading…
Reference in New Issue
Block a user