diff options
| author | bors <bors@rust-lang.org> | 2019-01-16 15:01:20 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-01-16 15:01:20 +0000 |
| commit | ceb2512144d1fc26330e85fb9d41c22ba1866259 (patch) | |
| tree | 698f2e468d5964e3e7368af3c48e706d035df6da /src/libsyntax/ext | |
| parent | cccaf9a8c69219c8267e406f92fef895fbba80f2 (diff) | |
| parent | d3411d3ee8a350e2b8ec202a4a493e69c827245c (diff) | |
| download | rust-ceb2512144d1fc26330e85fb9d41c22ba1866259.tar.gz rust-ceb2512144d1fc26330e85fb9d41c22ba1866259.zip | |
Auto merge of #57321 - petrochenkov:atokens, r=nikomatsakis
Implement basic input validation for built-in attributes Correct top-level shape (`#[attr]` vs `#[attr(...)]` vs `#[attr = ...]`) is enforced for built-in attributes, built-in attributes must also fit into the "meta-item" syntax (aka the "classic attribute syntax"). For some subset of attributes (found by crater run), errors are lowered to deprecation warnings. NOTE: This PR previously included https://github.com/rust-lang/rust/pull/57367 as well.
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/derive.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libsyntax/ext/derive.rs b/src/libsyntax/ext/derive.rs index d5a51bc1703..7ef09ce5fbd 100644 --- a/src/libsyntax/ext/derive.rs +++ b/src/libsyntax/ext/derive.rs @@ -15,6 +15,11 @@ pub fn collect_derives(cx: &mut ExtCtxt, attrs: &mut Vec<ast::Attribute>) -> Vec if attr.path != "derive" { return true; } + if !attr.is_meta_item_list() { + cx.span_err(attr.span, + "attribute must be of the form `#[derive(Trait1, Trait2, ...)]`"); + return false; + } match attr.parse_list(cx.parse_sess, |parser| parser.parse_path_allowing_meta(PathStyle::Mod)) { |
