diff options
| author | bors <bors@rust-lang.org> | 2016-07-29 16:26:38 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-07-29 16:26:38 -0700 |
| commit | f164cf5d6443fd265f93662055d744074648189f (patch) | |
| tree | e84bccd6a04c054c1dab83eb206932e23a5c810c /src/libsyntax_ext | |
| parent | 5a7773a18098be712d7e1ce4fded36aed8c3c311 (diff) | |
| parent | 5553901146fa80c652abdc514b38360a0ae7418d (diff) | |
| download | rust-f164cf5d6443fd265f93662055d744074648189f.tar.gz rust-f164cf5d6443fd265f93662055d744074648189f.zip | |
Auto merge of #34842 - cgswords:attr_enc, r=nrc
Better attribute and metaitem encapsulation throughout the compiler This PR refactors most (hopefully all?) of the `MetaItem` interactions outside of `libsyntax` (and a few inside) to interact with MetaItems through the provided traits instead of directly creating / destruct / matching against them. This is a necessary first step to eventually converting `MetaItem`s to internally use `TokenStream` representations (which will make `MetaItem` interactions much nicer for macro writers once the new macro system is in place). r? @nrc
Diffstat (limited to 'src/libsyntax_ext')
| -rw-r--r-- | src/libsyntax_ext/deriving/mod.rs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/libsyntax_ext/deriving/mod.rs b/src/libsyntax_ext/deriving/mod.rs index 80e2a923e55..e09a64e7344 100644 --- a/src/libsyntax_ext/deriving/mod.rs +++ b/src/libsyntax_ext/deriving/mod.rs @@ -10,7 +10,7 @@ //! The compiler code necessary to implement the `#[derive]` extensions. -use syntax::ast::{self, MetaItem, MetaItemKind}; +use syntax::ast::{MetaItem, self}; use syntax::attr::AttrMetaMethods; use syntax::ext::base::{Annotatable, ExtCtxt, SyntaxEnv}; use syntax::ext::base::{MultiDecorator, MultiItemDecorator, MultiModifier}; @@ -98,15 +98,14 @@ fn expand_derive(cx: &mut ExtCtxt, let mut eq_span = None; for titem in traits.iter().rev() { - let tname = match titem.node { - MetaItemKind::Word(ref tname) => tname, - _ => { - cx.span_err(titem.span, "malformed `derive` entry"); - continue; - } - }; - - if !(is_builtin_trait(tname) || cx.ecfg.enable_custom_derive()) { + let tname = if titem.is_word() { + titem.name() } + else { + cx.span_err(titem.span, "malformed `derive` entry"); + continue; + }; + + if !(is_builtin_trait(&tname) || cx.ecfg.enable_custom_derive()) { feature_gate::emit_feature_err(&cx.parse_sess.span_diagnostic, "custom_derive", titem.span, |
