Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
14e09ad4
R
Rust
项目概览
int
/
Rust
接近 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
14e09ad4
编写于
2月 09, 2016
作者:
O
Oliver 'ker' Schneider
提交者:
Oliver Schneider
2月 11, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[breaking-change] don't glob export ast::MetaItem_
上级
e797e196
变更
22
隐藏空白更改
内联
并排
Showing
22 changed file
with
83 addition
and
84 deletion
+83
-84
src/librustc/lint/context.rs
src/librustc/lint/context.rs
+2
-2
src/librustc_driver/lib.rs
src/librustc_driver/lib.rs
+5
-5
src/librustc_front/fold.rs
src/librustc_front/fold.rs
+5
-5
src/librustc_lint/builtin.rs
src/librustc_lint/builtin.rs
+1
-1
src/librustc_metadata/decoder.rs
src/librustc_metadata/decoder.rs
+1
-1
src/librustc_metadata/encoder.rs
src/librustc_metadata/encoder.rs
+3
-3
src/librustc_metadata/macro_import.rs
src/librustc_metadata/macro_import.rs
+2
-2
src/librustc_trans/trans/assert_dep_graph.rs
src/librustc_trans/trans/assert_dep_graph.rs
+3
-3
src/librustc_trans/trans/debuginfo/utils.rs
src/librustc_trans/trans/debuginfo/utils.rs
+1
-1
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+3
-3
src/libsyntax/ast.rs
src/libsyntax/ast.rs
+15
-15
src/libsyntax/attr.rs
src/libsyntax/attr.rs
+21
-22
src/libsyntax/config.rs
src/libsyntax/config.rs
+1
-1
src/libsyntax/ext/build.rs
src/libsyntax/ext/build.rs
+3
-3
src/libsyntax/ext/expand.rs
src/libsyntax/ext/expand.rs
+1
-1
src/libsyntax/feature_gate.rs
src/libsyntax/feature_gate.rs
+1
-1
src/libsyntax/fold.rs
src/libsyntax/fold.rs
+4
-4
src/libsyntax/parse/attr.rs
src/libsyntax/parse/attr.rs
+3
-3
src/libsyntax/print/pprust.rs
src/libsyntax/print/pprust.rs
+3
-3
src/libsyntax/std_inject.rs
src/libsyntax/std_inject.rs
+1
-1
src/libsyntax_ext/deriving/mod.rs
src/libsyntax_ext/deriving/mod.rs
+2
-2
src/test/auxiliary/macro_crate_test.rs
src/test/auxiliary/macro_crate_test.rs
+2
-2
未找到文件。
src/librustc/lint/context.rs
浏览文件 @
14e09ad4
...
...
@@ -374,7 +374,7 @@ pub fn gather_attr(attr: &ast::Attribute)
let
meta
=
&
attr
.node.value
;
let
metas
=
match
meta
.node
{
ast
::
MetaList
(
_
,
ref
metas
)
=>
metas
,
ast
::
Meta
ItemKind
::
List
(
_
,
ref
metas
)
=>
metas
,
_
=>
{
out
.push
(
Err
(
meta
.span
));
return
out
;
...
...
@@ -383,7 +383,7 @@ pub fn gather_attr(attr: &ast::Attribute)
for
meta
in
metas
{
out
.push
(
match
meta
.node
{
ast
::
MetaWord
(
ref
lint_name
)
=>
Ok
((
lint_name
.clone
(),
level
,
meta
.span
)),
ast
::
Meta
ItemKind
::
Word
(
ref
lint_name
)
=>
Ok
((
lint_name
.clone
(),
level
,
meta
.span
)),
_
=>
Err
(
meta
.span
),
});
}
...
...
src/librustc_driver/lib.rs
浏览文件 @
14e09ad4
...
...
@@ -560,18 +560,18 @@ fn print_crate_info(sess: &Session,
PrintRequest
::
Cfg
=>
{
for
cfg
in
config
::
build_configuration
(
sess
)
{
match
cfg
.node
{
ast
::
MetaWord
(
ref
word
)
=>
println!
(
"{}"
,
word
),
ast
::
MetaNameValue
(
ref
name
,
ref
value
)
=>
{
ast
::
Meta
ItemKind
::
Word
(
ref
word
)
=>
println!
(
"{}"
,
word
),
ast
::
Meta
ItemKind
::
NameValue
(
ref
name
,
ref
value
)
=>
{
println!
(
"{}=
\"
{}
\"
"
,
name
,
match
value
.node
{
ast
::
LitKind
::
Str
(
ref
s
,
_
)
=>
s
,
_
=>
continue
,
});
}
// Right now there are not and should not be any
// MetaList items in the configuration returned by
// Meta
ItemKind::
List items in the configuration returned by
// `build_configuration`.
ast
::
MetaList
(
..
)
=>
{
panic!
(
"MetaList encountered in default cfg"
)
ast
::
Meta
ItemKind
::
List
(
..
)
=>
{
panic!
(
"Meta
ItemKind::
List encountered in default cfg"
)
}
}
}
...
...
src/librustc_front/fold.rs
浏览文件 @
14e09ad4
...
...
@@ -13,7 +13,7 @@
use
hir
::
*
;
use
syntax
::
ast
::{
Name
,
NodeId
,
DUMMY_NODE_ID
,
Attribute
,
Attribute_
,
MetaItem
};
use
syntax
::
ast
::
{
MetaWord
,
MetaList
,
MetaNameValue
}
;
use
syntax
::
ast
::
MetaItemKind
;
use
syntax
::
attr
::
ThinAttributesExt
;
use
hir
;
use
syntax
::
codemap
::{
respan
,
Span
,
Spanned
};
...
...
@@ -522,11 +522,11 @@ pub fn noop_fold_meta_item<T: Folder>(mi: P<MetaItem>, fld: &mut T) -> P<MetaIte
mi
.map
(|
Spanned
{
node
,
span
}|
{
Spanned
{
node
:
match
node
{
Meta
Word
(
id
)
=>
Meta
Word
(
id
),
MetaList
(
id
,
mis
)
=>
{
MetaList
(
id
,
mis
.move_map
(|
e
|
fld
.fold_meta_item
(
e
)))
Meta
ItemKind
::
Word
(
id
)
=>
MetaItemKind
::
Word
(
id
),
Meta
ItemKind
::
List
(
id
,
mis
)
=>
{
Meta
ItemKind
::
List
(
id
,
mis
.move_map
(|
e
|
fld
.fold_meta_item
(
e
)))
}
Meta
NameValue
(
id
,
s
)
=>
Meta
NameValue
(
id
,
s
),
Meta
ItemKind
::
NameValue
(
id
,
s
)
=>
MetaItemKind
::
NameValue
(
id
,
s
),
},
span
:
fld
.new_span
(
span
),
}
...
...
src/librustc_lint/builtin.rs
浏览文件 @
14e09ad4
...
...
@@ -308,7 +308,7 @@ fn check_missing_docs_attrs(&self,
let
has_doc
=
attrs
.iter
()
.any
(|
a
|
{
match
a
.node.value.node
{
ast
::
MetaNameValue
(
ref
name
,
_
)
if
*
name
==
"doc"
=>
true
,
ast
::
Meta
ItemKind
::
NameValue
(
ref
name
,
_
)
if
*
name
==
"doc"
=>
true
,
_
=>
false
}
});
...
...
src/librustc_metadata/decoder.rs
浏览文件 @
14e09ad4
...
...
@@ -1170,7 +1170,7 @@ fn get_meta_items(md: rbml::Doc) -> Vec<P<ast::MetaItem>> {
let
vd
=
reader
::
get_doc
(
meta_item_doc
,
tag_meta_item_value
);
let
n
=
token
::
intern_and_get_ident
(
nd
.as_str_slice
());
let
v
=
token
::
intern_and_get_ident
(
vd
.as_str_slice
());
// FIXME (#623): Should be able to decode MetaNameValue variants,
// FIXME (#623): Should be able to decode Meta
ItemKind::
NameValue variants,
// but currently the encoder just drops them
attr
::
mk_name_value_item_str
(
n
,
v
)
}))
.chain
(
reader
::
tagged_docs
(
md
,
tag_meta_item_list
)
.map
(|
meta_item_doc
|
{
...
...
src/librustc_metadata/encoder.rs
浏览文件 @
14e09ad4
...
...
@@ -1541,12 +1541,12 @@ fn encode_item_index(rbml_w: &mut Encoder, index: IndexData) {
fn
encode_meta_item
(
rbml_w
:
&
mut
Encoder
,
mi
:
&
ast
::
MetaItem
)
{
match
mi
.node
{
ast
::
MetaWord
(
ref
name
)
=>
{
ast
::
Meta
ItemKind
::
Word
(
ref
name
)
=>
{
rbml_w
.start_tag
(
tag_meta_item_word
);
rbml_w
.wr_tagged_str
(
tag_meta_item_name
,
name
);
rbml_w
.end_tag
();
}
ast
::
MetaNameValue
(
ref
name
,
ref
value
)
=>
{
ast
::
Meta
ItemKind
::
NameValue
(
ref
name
,
ref
value
)
=>
{
match
value
.node
{
ast
::
LitKind
::
Str
(
ref
value
,
_
)
=>
{
rbml_w
.start_tag
(
tag_meta_item_name_value
);
...
...
@@ -1557,7 +1557,7 @@ fn encode_meta_item(rbml_w: &mut Encoder, mi: &ast::MetaItem) {
_
=>
{
/* FIXME (#623): encode other variants */
}
}
}
ast
::
MetaList
(
ref
name
,
ref
items
)
=>
{
ast
::
Meta
ItemKind
::
List
(
ref
name
,
ref
items
)
=>
{
rbml_w
.start_tag
(
tag_meta_item_list
);
rbml_w
.wr_tagged_str
(
tag_meta_item_name
,
name
);
for
inner_item
in
items
{
...
...
src/librustc_metadata/macro_import.rs
浏览文件 @
14e09ad4
...
...
@@ -95,7 +95,7 @@ fn visit_item(&mut self, item: &ast::Item) {
}
if
let
(
Some
(
sel
),
Some
(
names
))
=
(
import
.as_mut
(),
names
)
{
for
attr
in
names
{
if
let
ast
::
MetaWord
(
ref
name
)
=
attr
.node
{
if
let
ast
::
Meta
ItemKind
::
Word
(
ref
name
)
=
attr
.node
{
sel
.insert
(
name
.clone
(),
attr
.span
);
}
else
{
span_err!
(
self
.sess
,
attr
.span
,
E0466
,
"bad macro import"
);
...
...
@@ -113,7 +113,7 @@ fn visit_item(&mut self, item: &ast::Item) {
};
for
attr
in
names
{
if
let
ast
::
MetaWord
(
ref
name
)
=
attr
.node
{
if
let
ast
::
Meta
ItemKind
::
Word
(
ref
name
)
=
attr
.node
{
reexport
.insert
(
name
.clone
(),
attr
.span
);
}
else
{
call_bad_macro_reexport
(
self
.sess
,
attr
.span
);
...
...
src/librustc_trans/trans/assert_dep_graph.rs
浏览文件 @
14e09ad4
...
...
@@ -96,7 +96,7 @@ fn process_attrs(&mut self, node_id: ast::NodeId, def_id: DefId) {
let
mut
id
=
None
;
for
meta_item
in
attr
.meta_item_list
()
.unwrap_or_default
()
{
match
meta_item
.node
{
ast
::
MetaWord
(
ref
s
)
if
id
.is_none
()
=>
id
=
Some
(
s
.clone
()),
ast
::
Meta
ItemKind
::
Word
(
ref
s
)
if
id
.is_none
()
=>
id
=
Some
(
s
.clone
()),
_
=>
{
self
.tcx.sess
.span_err
(
meta_item
.span
,
...
...
@@ -113,9 +113,9 @@ fn process_attrs(&mut self, node_id: ast::NodeId, def_id: DefId) {
let
mut
id
=
None
;
for
meta_item
in
attr
.meta_item_list
()
.unwrap_or_default
()
{
match
meta_item
.node
{
ast
::
MetaWord
(
ref
s
)
if
dep_node_interned
.is_none
()
=>
ast
::
Meta
ItemKind
::
Word
(
ref
s
)
if
dep_node_interned
.is_none
()
=>
dep_node_interned
=
Some
(
s
.clone
()),
ast
::
MetaWord
(
ref
s
)
if
id
.is_none
()
=>
ast
::
Meta
ItemKind
::
Word
(
ref
s
)
if
id
.is_none
()
=>
id
=
Some
(
s
.clone
()),
_
=>
{
self
.tcx.sess
.span_err
(
...
...
src/librustc_trans/trans/debuginfo/utils.rs
浏览文件 @
14e09ad4
...
...
@@ -48,7 +48,7 @@ pub fn contains_nodebug_attribute(attributes: &[ast::Attribute]) -> bool {
attributes
.iter
()
.any
(|
attr
|
{
let
meta_item
:
&
ast
::
MetaItem
=
&*
attr
.node.value
;
match
meta_item
.node
{
ast
::
MetaWord
(
ref
value
)
=>
&
value
[
..
]
==
"no_debug"
,
ast
::
Meta
ItemKind
::
Word
(
ref
value
)
=>
&
value
[
..
]
==
"no_debug"
,
_
=>
false
}
})
...
...
src/librustdoc/clean/mod.rs
浏览文件 @
14e09ad4
...
...
@@ -451,11 +451,11 @@ pub enum Attribute {
impl
Clean
<
Attribute
>
for
ast
::
MetaItem
{
fn
clean
(
&
self
,
cx
:
&
DocContext
)
->
Attribute
{
match
self
.node
{
ast
::
MetaWord
(
ref
s
)
=>
Word
(
s
.to_string
()),
ast
::
MetaList
(
ref
s
,
ref
l
)
=>
{
ast
::
Meta
ItemKind
::
Word
(
ref
s
)
=>
Word
(
s
.to_string
()),
ast
::
Meta
ItemKind
::
List
(
ref
s
,
ref
l
)
=>
{
List
(
s
.to_string
(),
l
.clean
(
cx
))
}
ast
::
MetaNameValue
(
ref
s
,
ref
v
)
=>
{
ast
::
Meta
ItemKind
::
NameValue
(
ref
s
,
ref
v
)
=>
{
NameValue
(
s
.to_string
(),
lit_to_string
(
v
))
}
}
...
...
src/libsyntax/ast.rs
浏览文件 @
14e09ad4
...
...
@@ -10,7 +10,6 @@
// The Rust abstract syntax tree.
pub
use
self
::
MetaItem_
::
*
;
pub
use
self
::
Mutability
::
*
;
pub
use
self
::
Pat_
::
*
;
pub
use
self
::
PathListItem_
::
*
;
...
...
@@ -476,31 +475,32 @@ pub struct Crate {
pub
exported_macros
:
Vec
<
MacroDef
>
,
}
pub
type
MetaItem
=
Spanned
<
MetaItem
_
>
;
pub
type
MetaItem
=
Spanned
<
MetaItem
Kind
>
;
#[derive(Clone,
Eq,
RustcEncodable,
RustcDecodable,
Hash,
Debug)]
pub
enum
MetaItem
_
{
Meta
Word
(
InternedString
),
Meta
List
(
InternedString
,
Vec
<
P
<
MetaItem
>>
),
Meta
NameValue
(
InternedString
,
Lit
),
pub
enum
MetaItem
Kind
{
Word
(
InternedString
),
List
(
InternedString
,
Vec
<
P
<
MetaItem
>>
),
NameValue
(
InternedString
,
Lit
),
}
// can't be derived because the MetaList requires an unordered comparison
impl
PartialEq
for
MetaItem_
{
fn
eq
(
&
self
,
other
:
&
MetaItem_
)
->
bool
{
// can't be derived because the MetaItemKind::List requires an unordered comparison
impl
PartialEq
for
MetaItemKind
{
fn
eq
(
&
self
,
other
:
&
MetaItemKind
)
->
bool
{
use
self
::
MetaItemKind
::
*
;
match
*
self
{
Meta
Word
(
ref
ns
)
=>
match
*
other
{
Meta
Word
(
ref
no
)
=>
(
*
ns
)
==
(
*
no
),
Word
(
ref
ns
)
=>
match
*
other
{
Word
(
ref
no
)
=>
(
*
ns
)
==
(
*
no
),
_
=>
false
},
Meta
NameValue
(
ref
ns
,
ref
vs
)
=>
match
*
other
{
Meta
NameValue
(
ref
no
,
ref
vo
)
=>
{
NameValue
(
ref
ns
,
ref
vs
)
=>
match
*
other
{
NameValue
(
ref
no
,
ref
vo
)
=>
{
(
*
ns
)
==
(
*
no
)
&&
vs
.node
==
vo
.node
}
_
=>
false
},
Meta
List
(
ref
ns
,
ref
miss
)
=>
match
*
other
{
Meta
List
(
ref
no
,
ref
miso
)
=>
{
List
(
ref
ns
,
ref
miss
)
=>
match
*
other
{
List
(
ref
no
,
ref
miso
)
=>
{
ns
==
no
&&
miss
.iter
()
.all
(|
mi
|
miso
.iter
()
.any
(|
x
|
x
.node
==
mi
.node
))
}
...
...
src/libsyntax/attr.rs
浏览文件 @
14e09ad4
...
...
@@ -15,7 +15,7 @@
pub
use
self
::
IntType
::
*
;
use
ast
;
use
ast
::{
AttrId
,
Attribute
,
Attribute_
,
MetaItem
,
Meta
Word
,
MetaNameValue
,
MetaList
};
use
ast
::{
AttrId
,
Attribute
,
Attribute_
,
MetaItem
,
Meta
ItemKind
};
use
ast
::{
Stmt
,
StmtKind
,
DeclKind
};
use
ast
::{
Expr
,
Item
,
Local
,
Decl
};
use
codemap
::{
Span
,
Spanned
,
spanned
,
dummy_spanned
};
...
...
@@ -66,7 +66,7 @@ fn check_name(&self, name: &str) -> bool {
/// `#[foo="bar"]` and `#[foo(bar)]`
fn
name
(
&
self
)
->
InternedString
;
/// Gets the string value if self is a MetaNameValue variant
/// Gets the string value if self is a Meta
ItemKind::
NameValue variant
/// containing a string, otherwise None.
fn
value_str
(
&
self
)
->
Option
<
InternedString
>
;
/// Gets a list of inner meta items from a list MetaItem type.
...
...
@@ -96,15 +96,15 @@ fn span(&self) -> Span { self.meta().span }
impl
AttrMetaMethods
for
MetaItem
{
fn
name
(
&
self
)
->
InternedString
{
match
self
.node
{
MetaWord
(
ref
n
)
=>
(
*
n
)
.clone
(),
MetaNameValue
(
ref
n
,
_
)
=>
(
*
n
)
.clone
(),
MetaList
(
ref
n
,
_
)
=>
(
*
n
)
.clone
(),
Meta
ItemKind
::
Word
(
ref
n
)
=>
(
*
n
)
.clone
(),
Meta
ItemKind
::
NameValue
(
ref
n
,
_
)
=>
(
*
n
)
.clone
(),
Meta
ItemKind
::
List
(
ref
n
,
_
)
=>
(
*
n
)
.clone
(),
}
}
fn
value_str
(
&
self
)
->
Option
<
InternedString
>
{
match
self
.node
{
MetaNameValue
(
_
,
ref
v
)
=>
{
Meta
ItemKind
::
NameValue
(
_
,
ref
v
)
=>
{
match
v
.node
{
ast
::
LitKind
::
Str
(
ref
s
,
_
)
=>
Some
((
*
s
)
.clone
()),
_
=>
None
,
...
...
@@ -116,7 +116,7 @@ fn value_str(&self) -> Option<InternedString> {
fn
meta_item_list
(
&
self
)
->
Option
<&
[
P
<
MetaItem
>
]
>
{
match
self
.node
{
MetaList
(
_
,
ref
l
)
=>
Some
(
&
l
[
..
]),
Meta
ItemKind
::
List
(
_
,
ref
l
)
=>
Some
(
&
l
[
..
]),
_
=>
None
}
}
...
...
@@ -179,15 +179,15 @@ pub fn mk_name_value_item_str(name: InternedString, value: InternedString)
pub
fn
mk_name_value_item
(
name
:
InternedString
,
value
:
ast
::
Lit
)
->
P
<
MetaItem
>
{
P
(
dummy_spanned
(
MetaNameValue
(
name
,
value
)))
P
(
dummy_spanned
(
Meta
ItemKind
::
NameValue
(
name
,
value
)))
}
pub
fn
mk_list_item
(
name
:
InternedString
,
items
:
Vec
<
P
<
MetaItem
>>
)
->
P
<
MetaItem
>
{
P
(
dummy_spanned
(
MetaList
(
name
,
items
)))
P
(
dummy_spanned
(
Meta
ItemKind
::
List
(
name
,
items
)))
}
pub
fn
mk_word_item
(
name
:
InternedString
)
->
P
<
MetaItem
>
{
P
(
dummy_spanned
(
MetaWord
(
name
)))
P
(
dummy_spanned
(
Meta
ItemKind
::
Word
(
name
)))
}
thread_local!
{
static
NEXT_ATTR_ID
:
Cell
<
usize
>
=
Cell
::
new
(
0
)
}
...
...
@@ -229,8 +229,7 @@ pub fn mk_sugared_doc_attr(id: AttrId, text: InternedString, lo: BytePos,
let
attr
=
Attribute_
{
id
:
id
,
style
:
style
,
value
:
P
(
spanned
(
lo
,
hi
,
MetaNameValue
(
InternedString
::
new
(
"doc"
),
lit
))),
value
:
P
(
spanned
(
lo
,
hi
,
MetaItemKind
::
NameValue
(
InternedString
::
new
(
"doc"
),
lit
))),
is_sugared_doc
:
true
};
spanned
(
lo
,
hi
,
attr
)
...
...
@@ -286,7 +285,7 @@ pub fn sort_meta_items(items: Vec<P<MetaItem>>) -> Vec<P<MetaItem>> {
v
.into_iter
()
.map
(|(
_
,
m
)|
m
.map
(|
Spanned
{
node
,
span
}|
{
Spanned
{
node
:
match
node
{
Meta
List
(
n
,
mis
)
=>
Meta
List
(
n
,
sort_meta_items
(
mis
)),
Meta
ItemKind
::
List
(
n
,
mis
)
=>
MetaItemKind
::
List
(
n
,
sort_meta_items
(
mis
)),
_
=>
node
},
span
:
span
...
...
@@ -329,11 +328,11 @@ pub enum InlineAttr {
pub
fn
find_inline_attr
(
diagnostic
:
Option
<&
Handler
>
,
attrs
:
&
[
Attribute
])
->
InlineAttr
{
attrs
.iter
()
.fold
(
InlineAttr
::
None
,
|
ia
,
attr
|
{
match
attr
.node.value.node
{
MetaWord
(
ref
n
)
if
*
n
==
"inline"
=>
{
Meta
ItemKind
::
Word
(
ref
n
)
if
*
n
==
"inline"
=>
{
mark_used
(
attr
);
InlineAttr
::
Hint
}
MetaList
(
ref
n
,
ref
items
)
if
*
n
==
"inline"
=>
{
Meta
ItemKind
::
List
(
ref
n
,
ref
items
)
if
*
n
==
"inline"
=>
{
mark_used
(
attr
);
if
items
.len
()
!=
1
{
diagnostic
.map
(|
d
|{
d
.span_err
(
attr
.span
,
"expected one argument"
);
});
...
...
@@ -365,11 +364,11 @@ pub fn cfg_matches<T: CfgDiag>(cfgs: &[P<MetaItem>],
cfg
:
&
ast
::
MetaItem
,
diag
:
&
mut
T
)
->
bool
{
match
cfg
.node
{
ast
::
MetaList
(
ref
pred
,
ref
mis
)
if
&
pred
[
..
]
==
"any"
=>
ast
::
Meta
ItemKind
::
List
(
ref
pred
,
ref
mis
)
if
&
pred
[
..
]
==
"any"
=>
mis
.iter
()
.any
(|
mi
|
cfg_matches
(
cfgs
,
&**
mi
,
diag
)),
ast
::
MetaList
(
ref
pred
,
ref
mis
)
if
&
pred
[
..
]
==
"all"
=>
ast
::
Meta
ItemKind
::
List
(
ref
pred
,
ref
mis
)
if
&
pred
[
..
]
==
"all"
=>
mis
.iter
()
.all
(|
mi
|
cfg_matches
(
cfgs
,
&**
mi
,
diag
)),
ast
::
MetaList
(
ref
pred
,
ref
mis
)
if
&
pred
[
..
]
==
"not"
=>
{
ast
::
Meta
ItemKind
::
List
(
ref
pred
,
ref
mis
)
if
&
pred
[
..
]
==
"not"
=>
{
if
mis
.len
()
!=
1
{
diag
.emit_error
(|
diagnostic
|
{
diagnostic
.span_err
(
cfg
.span
,
"expected 1 cfg-pattern"
);
...
...
@@ -378,14 +377,14 @@ pub fn cfg_matches<T: CfgDiag>(cfgs: &[P<MetaItem>],
}
!
cfg_matches
(
cfgs
,
&*
mis
[
0
],
diag
)
}
ast
::
MetaList
(
ref
pred
,
_
)
=>
{
ast
::
Meta
ItemKind
::
List
(
ref
pred
,
_
)
=>
{
diag
.emit_error
(|
diagnostic
|
{
diagnostic
.span_err
(
cfg
.span
,
&
format!
(
"invalid predicate `{}`"
,
pred
));
});
false
},
ast
::
Meta
Word
(
_
)
|
ast
::
Meta
NameValue
(
..
)
=>
{
ast
::
Meta
ItemKind
::
Word
(
_
)
|
ast
::
MetaItemKind
::
NameValue
(
..
)
=>
{
diag
.flag_gated
(|
feature_gated_cfgs
|
{
feature_gated_cfgs
.extend
(
GatedCfg
::
gate
(
cfg
)
.map
(
GatedCfgAttr
::
GatedCfg
));
...
...
@@ -707,11 +706,11 @@ pub fn require_unique_names(diagnostic: &Handler, metas: &[P<MetaItem>]) {
pub
fn
find_repr_attrs
(
diagnostic
:
&
Handler
,
attr
:
&
Attribute
)
->
Vec
<
ReprAttr
>
{
let
mut
acc
=
Vec
::
new
();
match
attr
.node.value.node
{
ast
::
MetaList
(
ref
s
,
ref
items
)
if
*
s
==
"repr"
=>
{
ast
::
Meta
ItemKind
::
List
(
ref
s
,
ref
items
)
if
*
s
==
"repr"
=>
{
mark_used
(
attr
);
for
item
in
items
{
match
item
.node
{
ast
::
MetaWord
(
ref
word
)
=>
{
ast
::
Meta
ItemKind
::
Word
(
ref
word
)
=>
{
let
hint
=
match
&
word
[
..
]
{
// Can't use "extern" because it's not a lexical identifier.
"C"
=>
Some
(
ReprExtern
),
...
...
src/libsyntax/config.rs
浏览文件 @
14e09ad4
...
...
@@ -270,7 +270,7 @@ fn in_cfg<T: CfgDiag>(cfg: &[P<ast::MetaItem>],
diag
:
&
mut
T
)
->
bool
{
attrs
.iter
()
.all
(|
attr
|
{
let
mis
=
match
attr
.node.value.node
{
ast
::
MetaList
(
_
,
ref
mis
)
if
is_cfg
(
&
attr
)
=>
mis
,
ast
::
Meta
ItemKind
::
List
(
_
,
ref
mis
)
if
is_cfg
(
&
attr
)
=>
mis
,
_
=>
return
true
};
...
...
src/libsyntax/ext/build.rs
浏览文件 @
14e09ad4
...
...
@@ -1102,21 +1102,21 @@ fn attribute(&self, sp: Span, mi: P<ast::MetaItem>) -> ast::Attribute {
}
fn
meta_word
(
&
self
,
sp
:
Span
,
w
:
InternedString
)
->
P
<
ast
::
MetaItem
>
{
P
(
respan
(
sp
,
ast
::
MetaWord
(
w
)))
P
(
respan
(
sp
,
ast
::
Meta
ItemKind
::
Word
(
w
)))
}
fn
meta_list
(
&
self
,
sp
:
Span
,
name
:
InternedString
,
mis
:
Vec
<
P
<
ast
::
MetaItem
>>
)
->
P
<
ast
::
MetaItem
>
{
P
(
respan
(
sp
,
ast
::
MetaList
(
name
,
mis
)))
P
(
respan
(
sp
,
ast
::
Meta
ItemKind
::
List
(
name
,
mis
)))
}
fn
meta_name_value
(
&
self
,
sp
:
Span
,
name
:
InternedString
,
value
:
ast
::
LitKind
)
->
P
<
ast
::
MetaItem
>
{
P
(
respan
(
sp
,
ast
::
MetaNameValue
(
name
,
respan
(
sp
,
value
))))
P
(
respan
(
sp
,
ast
::
Meta
ItemKind
::
NameValue
(
name
,
respan
(
sp
,
value
))))
}
fn
item_use
(
&
self
,
sp
:
Span
,
...
...
src/libsyntax/ext/expand.rs
浏览文件 @
14e09ad4
...
...
@@ -348,7 +348,7 @@ fn contains_macro_use(fld: &mut MacroExpander, attrs: &[ast::Attribute]) -> bool
if
is_use
{
match
attr
.node.value.node
{
ast
::
MetaWord
(
..
)
=>
(),
ast
::
Meta
ItemKind
::
Word
(
..
)
=>
(),
_
=>
fld
.cx
.span_err
(
attr
.span
,
"arguments to macro_use are not allowed here"
),
}
return
true
;
...
...
src/libsyntax/feature_gate.rs
浏览文件 @
14e09ad4
...
...
@@ -1138,7 +1138,7 @@ fn check_crate_inner<F>(cm: &CodeMap, span_handler: &Handler,
Some
(
list
)
=>
{
for
mi
in
list
{
let
name
=
match
mi
.node
{
ast
::
MetaWord
(
ref
word
)
=>
(
*
word
)
.clone
(),
ast
::
Meta
ItemKind
::
Word
(
ref
word
)
=>
(
*
word
)
.clone
(),
_
=>
{
span_handler
.span_err
(
mi
.span
,
"malformed feature, expected just
\
...
...
src/libsyntax/fold.rs
浏览文件 @
14e09ad4
...
...
@@ -556,11 +556,11 @@ pub fn noop_fold_mac<T: Folder>(Spanned {node, span}: Mac, fld: &mut T) -> Mac {
pub
fn
noop_fold_meta_item
<
T
:
Folder
>
(
mi
:
P
<
MetaItem
>
,
fld
:
&
mut
T
)
->
P
<
MetaItem
>
{
mi
.map
(|
Spanned
{
node
,
span
}|
Spanned
{
node
:
match
node
{
Meta
Word
(
id
)
=>
Meta
Word
(
id
),
MetaList
(
id
,
mis
)
=>
{
MetaList
(
id
,
mis
.move_map
(|
e
|
fld
.fold_meta_item
(
e
)))
Meta
ItemKind
::
Word
(
id
)
=>
MetaItemKind
::
Word
(
id
),
Meta
ItemKind
::
List
(
id
,
mis
)
=>
{
Meta
ItemKind
::
List
(
id
,
mis
.move_map
(|
e
|
fld
.fold_meta_item
(
e
)))
}
Meta
NameValue
(
id
,
s
)
=>
Meta
NameValue
(
id
,
s
)
Meta
ItemKind
::
NameValue
(
id
,
s
)
=>
MetaItemKind
::
NameValue
(
id
,
s
)
},
span
:
fld
.new_span
(
span
)
})
...
...
src/libsyntax/parse/attr.rs
浏览文件 @
14e09ad4
...
...
@@ -182,16 +182,16 @@ pub fn parse_meta_item(&mut self) -> PResult<'a, P<ast::MetaItem>> {
}
}
let
hi
=
self
.span.hi
;
Ok
(
P
(
spanned
(
lo
,
hi
,
ast
::
MetaNameValue
(
name
,
lit
))))
Ok
(
P
(
spanned
(
lo
,
hi
,
ast
::
Meta
ItemKind
::
NameValue
(
name
,
lit
))))
}
token
::
OpenDelim
(
token
::
Paren
)
=>
{
let
inner_items
=
try!
(
self
.parse_meta_seq
());
let
hi
=
self
.span.hi
;
Ok
(
P
(
spanned
(
lo
,
hi
,
ast
::
MetaList
(
name
,
inner_items
))))
Ok
(
P
(
spanned
(
lo
,
hi
,
ast
::
Meta
ItemKind
::
List
(
name
,
inner_items
))))
}
_
=>
{
let
hi
=
self
.last_span.hi
;
Ok
(
P
(
spanned
(
lo
,
hi
,
ast
::
MetaWord
(
name
))))
Ok
(
P
(
spanned
(
lo
,
hi
,
ast
::
Meta
ItemKind
::
Word
(
name
))))
}
}
}
...
...
src/libsyntax/print/pprust.rs
浏览文件 @
14e09ad4
...
...
@@ -766,15 +766,15 @@ fn print_attribute_inline(&mut self, attr: &ast::Attribute,
fn
print_meta_item
(
&
mut
self
,
item
:
&
ast
::
MetaItem
)
->
io
::
Result
<
()
>
{
try!
(
self
.ibox
(
INDENT_UNIT
));
match
item
.node
{
ast
::
MetaWord
(
ref
name
)
=>
{
ast
::
Meta
ItemKind
::
Word
(
ref
name
)
=>
{
try!
(
word
(
self
.writer
(),
&
name
));
}
ast
::
MetaNameValue
(
ref
name
,
ref
value
)
=>
{
ast
::
Meta
ItemKind
::
NameValue
(
ref
name
,
ref
value
)
=>
{
try!
(
self
.word_space
(
&
name
[
..
]));
try!
(
self
.word_space
(
"="
));
try!
(
self
.print_literal
(
value
));
}
ast
::
MetaList
(
ref
name
,
ref
items
)
=>
{
ast
::
Meta
ItemKind
::
List
(
ref
name
,
ref
items
)
=>
{
try!
(
word
(
self
.writer
(),
&
name
));
try!
(
self
.popen
());
try!
(
self
.commasep
(
Consistent
,
...
...
src/libsyntax/std_inject.rs
浏览文件 @
14e09ad4
...
...
@@ -157,7 +157,7 @@ fn fold_mod(&mut self, mut mod_: ast::Mod) -> ast::Mod {
style
:
ast
::
AttrStyle
::
Outer
,
value
:
P
(
ast
::
MetaItem
{
span
:
self
.span
,
node
:
ast
::
MetaWord
(
special_idents
::
prelude_import
.name
.as_str
()),
node
:
ast
::
Meta
ItemKind
::
Word
(
special_idents
::
prelude_import
.name
.as_str
()),
}),
is_sugared_doc
:
false
,
},
...
...
src/libsyntax_ext/deriving/mod.rs
浏览文件 @
14e09ad4
...
...
@@ -13,7 +13,7 @@
//! FIXME (#2810): hygiene. Search for "__" strings (in other files too). We also assume "extra" is
//! the standard library, and "std" is the core library.
use
syntax
::
ast
::{
MetaItem
,
Meta
Wor
d
};
use
syntax
::
ast
::{
MetaItem
,
Meta
ItemKin
d
};
use
syntax
::
attr
::
AttrMetaMethods
;
use
syntax
::
ext
::
base
::{
ExtCtxt
,
SyntaxEnv
,
Annotatable
};
use
syntax
::
ext
::
base
::{
MultiDecorator
,
MultiItemDecorator
,
MultiModifier
};
...
...
@@ -94,7 +94,7 @@ fn expand_derive(cx: &mut ExtCtxt,
for
titem
in
traits
.iter
()
.rev
()
{
let
tname
=
match
titem
.node
{
MetaWord
(
ref
tname
)
=>
tname
,
Meta
ItemKind
::
Word
(
ref
tname
)
=>
tname
,
_
=>
{
cx
.span_err
(
titem
.span
,
"malformed `derive` entry"
);
continue
;
...
...
src/test/auxiliary/macro_crate_test.rs
浏览文件 @
14e09ad4
...
...
@@ -101,8 +101,8 @@ fn expand_duplicate(cx: &mut ExtCtxt,
push
:
&
mut
FnMut
(
Annotatable
))
{
let
copy_name
=
match
mi
.node
{
ast
::
MetaItem
_
::
Meta
List
(
_
,
ref
xs
)
=>
{
if
let
ast
::
MetaItem
_
::
Meta
Word
(
ref
w
)
=
xs
[
0
]
.node
{
ast
::
MetaItem
Kind
::
List
(
_
,
ref
xs
)
=>
{
if
let
ast
::
MetaItem
Kind
::
Word
(
ref
w
)
=
xs
[
0
]
.node
{
token
::
str_to_ident
(
&
w
)
}
else
{
cx
.span_err
(
mi
.span
,
"Expected word"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录