Skip to content

Commit 7e942b8

Browse files
authored
Use lookahead.error() (#142)
* Use lookahead.error() * Create UI test for invalid scale-info attributes
1 parent cb18c8e commit 7e942b8

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

derive/src/attr.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,7 @@ impl Parse for ScaleInfoAttr {
250250
let capture_docs = input.parse()?;
251251
Ok(Self::CaptureDocs(capture_docs))
252252
} else {
253-
Err(input
254-
.error("Expected one of: `bounds`, `skip_type_params` or `capture_docs"))
253+
Err(lookahead.error())
255254
}
256255
}
257256
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use scale_info::TypeInfo;
2+
use scale::Encode;
3+
4+
#[derive(TypeInfo, Encode)]
5+
#[scale_info(foo)]
6+
struct InvalidKeywordInScaleInfoAttr {
7+
a: u8,
8+
b: u16,
9+
}
10+
11+
fn main() {}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
error: expected one of: `bounds`, `skip_type_params`, `capture_docs`
2+
--> tests/ui/fail_with_invalid_scale_info_attrs.rs:5:14
3+
|
4+
5 | #[scale_info(foo)]
5+
| ^^^

0 commit comments

Comments
 (0)