Point macros 1.1 errors to the input item
Before:
```rust
error[E0106]: missing lifetime specifier
--> src/main.rs:10:10
|
10 | #[derive(Serialize, Deserialize)]
| ^ expected lifetime parameter
error[E0038]: the trait `T` cannot be made into an object
--> src/main.rs:15:15
|
15 | #[derive(Serialize, Deserialize)]
| ^^^^^^^^^^ the trait `T` cannot be made into an object
```
After:
```rust
error[E0106]: missing lifetime specifier
--> src/main.rs:11:1
|
11 | struct A {
| ^ expected lifetime parameter
error[E0038]: the trait `T` cannot be made into an object
--> src/main.rs:16:1
|
16 | struct B<'a> {
| ^ the trait `T` cannot be made into an object
```
This commit is contained in:
parent
13c4e32e7a
commit
3784067edc
1 changed files with 3 additions and 2 deletions
|
|
@ -53,6 +53,7 @@ impl MultiItemModifier for CustomDerive {
|
|||
}
|
||||
}
|
||||
|
||||
let input_span = item.span;
|
||||
let input = __internal::new_token_stream(item);
|
||||
let res = __internal::set_parse_sess(&ecx.parse_sess, || {
|
||||
let inner = self.inner;
|
||||
|
|
@ -77,9 +78,9 @@ impl MultiItemModifier for CustomDerive {
|
|||
|
||||
// Right now we have no knowledge of spans at all in custom derive
|
||||
// macros, everything is just parsed as a string. Reassign all spans to
|
||||
// the #[derive] attribute for better errors here.
|
||||
// the input `item` for better errors here.
|
||||
item.into_iter().flat_map(|item| {
|
||||
ChangeSpan { span: span }.fold_item(item)
|
||||
ChangeSpan { span: input_span }.fold_item(item)
|
||||
}).map(Annotatable::Item).collect()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue