Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
9b3aea60
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,发现更多精彩内容 >>
未验证
提交
9b3aea60
编写于
1月 30, 2018
作者:
S
Seiichi Uchida
提交者:
flip1995
5月 02, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove Option from the return type of Attribute::name()
上级
759bd01e
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
28 addition
and
36 deletion
+28
-36
src/librustc/hir/check_attr.rs
src/librustc/hir/check_attr.rs
+1
-4
src/librustc/ich/impls_syntax.rs
src/librustc/ich/impls_syntax.rs
+2
-3
src/librustc/lint/levels.rs
src/librustc/lint/levels.rs
+1
-1
src/librustc/middle/stability.rs
src/librustc/middle/stability.rs
+1
-1
src/librustc_lint/builtin.rs
src/librustc_lint/builtin.rs
+1
-2
src/librustc_lint/lib.rs
src/librustc_lint/lib.rs
+0
-1
src/librustc_lint/unused.rs
src/librustc_lint/unused.rs
+1
-2
src/librustc_resolve/macros.rs
src/librustc_resolve/macros.rs
+3
-3
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+1
-1
src/librustdoc/html/render.rs
src/librustdoc/html/render.rs
+1
-1
src/libsyntax/attr.rs
src/libsyntax/attr.rs
+4
-5
src/libsyntax/ext/derive.rs
src/libsyntax/ext/derive.rs
+2
-1
src/libsyntax/feature_gate.rs
src/libsyntax/feature_gate.rs
+1
-1
src/libsyntax/parse/parser.rs
src/libsyntax/parse/parser.rs
+4
-4
src/libsyntax/print/pprust.rs
src/libsyntax/print/pprust.rs
+1
-0
src/libsyntax_ext/deriving/custom.rs
src/libsyntax_ext/deriving/custom.rs
+3
-5
src/libsyntax_ext/deriving/generic/mod.rs
src/libsyntax_ext/deriving/generic/mod.rs
+1
-1
未找到文件。
src/librustc/hir/check_attr.rs
浏览文件 @
9b3aea60
...
...
@@ -153,10 +153,7 @@ fn check_repr(&self, item: &hir::Item, target: Target) {
// ```
let
hints
:
Vec
<
_
>
=
item
.attrs
.iter
()
.filter
(|
attr
|
match
attr
.name
()
{
Some
(
name
)
=>
name
==
"repr"
,
None
=>
false
,
})
.filter
(|
attr
|
attr
.name
()
==
"repr"
)
.filter_map
(|
attr
|
attr
.meta_item_list
())
.flat_map
(|
hints
|
hints
)
.collect
();
...
...
src/librustc/ich/impls_syntax.rs
浏览文件 @
9b3aea60
...
...
@@ -199,8 +199,7 @@ fn hash_stable<W: StableHasherResult>(&self,
let
filtered
:
AccumulateVec
<
[
&
ast
::
Attribute
;
8
]
>
=
self
.iter
()
.filter
(|
attr
|
{
!
attr
.is_sugared_doc
&&
attr
.name
()
.map
(|
name
|
!
hcx
.is_ignored_attr
(
name
))
.unwrap_or
(
true
)
!
attr
.is_sugared_doc
&&
!
hcx
.is_ignored_attr
(
attr
.name
())
})
.collect
();
...
...
@@ -227,7 +226,7 @@ fn hash_stable<W: StableHasherResult>(&self,
hcx
:
&
mut
StableHashingContext
<
'a
>
,
hasher
:
&
mut
StableHasher
<
W
>
)
{
// Make sure that these have been filtered out.
debug_assert!
(
self
.name
()
.map
(|
name
|
!
hcx
.is_ignored_attr
(
name
))
.unwrap_or
(
true
));
debug_assert!
(
!
hcx
.is_ignored_attr
(
self
.name
()
));
debug_assert!
(
!
self
.is_sugared_doc
);
let
ast
::
Attribute
{
...
...
src/librustc/lint/levels.rs
浏览文件 @
9b3aea60
...
...
@@ -198,7 +198,7 @@ pub fn push(&mut self, attrs: &[ast::Attribute]) -> BuilderPush {
"malformed lint attribute"
);
};
for
attr
in
attrs
{
let
level
=
match
attr
.name
()
.and_then
(|
name
|
Level
::
from_str
(
&
name
.as_str
()
))
{
let
level
=
match
Level
::
from_str
(
&
attr
.name
()
.as_str
(
))
{
None
=>
continue
,
Some
(
lvl
)
=>
lvl
,
};
...
...
src/librustc/middle/stability.rs
浏览文件 @
9b3aea60
...
...
@@ -205,7 +205,7 @@ fn annotate<F>(&mut self, id: NodeId, attrs: &[Attribute],
}
else
{
// Emit errors for non-staged-api crates.
for
attr
in
attrs
{
let
tag
=
unwrap_or!
(
attr
.name
(),
continue
);
let
tag
=
attr
.name
(
);
if
tag
==
"unstable"
||
tag
==
"stable"
||
tag
==
"rustc_deprecated"
{
attr
::
mark_used
(
attr
);
self
.tcx.sess
.span_err
(
attr
.span
(),
"stability attributes may not be used
\
...
...
src/librustc_lint/builtin.rs
浏览文件 @
9b3aea60
...
...
@@ -675,9 +675,8 @@ fn get_lints(&self) -> LintArray {
impl
EarlyLintPass
for
DeprecatedAttr
{
fn
check_attribute
(
&
mut
self
,
cx
:
&
EarlyContext
,
attr
:
&
ast
::
Attribute
)
{
let
name
=
unwrap_or!
(
attr
.name
(),
return
);
for
&&
(
n
,
_
,
ref
g
)
in
&
self
.depr_attrs
{
if
name
==
n
{
if
attr
.name
()
==
n
{
if
let
&
AttributeGate
::
Gated
(
Stability
::
Deprecated
(
link
),
ref
name
,
ref
reason
,
...
...
src/librustc_lint/lib.rs
浏览文件 @
9b3aea60
...
...
@@ -30,7 +30,6 @@
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
#[macro_use]
extern
crate
syntax
;
#[macro_use]
extern
crate
rustc
;
...
...
src/librustc_lint/unused.rs
浏览文件 @
9b3aea60
...
...
@@ -192,8 +192,6 @@ fn get_lints(&self) -> LintArray {
impl
<
'a
,
'tcx
>
LateLintPass
<
'a
,
'tcx
>
for
UnusedAttributes
{
fn
check_attribute
(
&
mut
self
,
cx
:
&
LateContext
,
attr
:
&
ast
::
Attribute
)
{
debug!
(
"checking attribute: {:?}"
,
attr
);
let
name
=
unwrap_or!
(
attr
.name
(),
return
);
// Note that check_name() marks the attribute as used if it matches.
for
&
(
ref
name
,
ty
,
_
)
in
BUILTIN_ATTRIBUTES
{
match
ty
{
...
...
@@ -213,6 +211,7 @@ fn check_attribute(&mut self, cx: &LateContext, attr: &ast::Attribute) {
}
}
let
name
=
attr
.name
();
if
!
attr
::
is_used
(
attr
)
{
debug!
(
"Emitting warning for: {:?}"
,
attr
);
cx
.span_lint
(
UNUSED_ATTRIBUTES
,
attr
.span
,
"unused attribute"
);
...
...
src/librustc_resolve/macros.rs
浏览文件 @
9b3aea60
...
...
@@ -209,7 +209,7 @@ fn resolve_imports(&mut self) {
fn
find_legacy_attr_invoc
(
&
mut
self
,
attrs
:
&
mut
Vec
<
ast
::
Attribute
>
,
allow_derive
:
bool
)
->
Option
<
ast
::
Attribute
>
{
for
i
in
0
..
attrs
.len
()
{
let
name
=
unwrap_or!
(
attrs
[
i
]
.name
(),
continue
);
let
name
=
attrs
[
i
]
.name
(
);
if
self
.session.plugin_attributes
.borrow
()
.iter
()
.any
(|
&
(
ref
attr_nm
,
_
)|
name
==
&**
attr_nm
)
{
...
...
@@ -231,11 +231,11 @@ fn find_legacy_attr_invoc(&mut self, attrs: &mut Vec<ast::Attribute>, allow_deri
// Check for legacy derives
for
i
in
0
..
attrs
.len
()
{
let
name
=
unwrap_or!
(
attrs
[
i
]
.name
(),
continue
);
let
name
=
attrs
[
i
]
.name
(
);
if
name
==
"derive"
{
let
result
=
attrs
[
i
]
.parse_list
(
&
self
.session.parse_sess
,
|
parser
|
{
parser
.parse_path
(
PathStyle
::
Mod
)
parser
.parse_path
_allowing_meta
(
PathStyle
::
Mod
)
});
let
mut
traits
=
match
result
{
...
...
src/librustdoc/clean/mod.rs
浏览文件 @
9b3aea60
...
...
@@ -3661,7 +3661,7 @@ fn clean(&self, cx: &DocContext) -> Vec<Item> {
// #[doc(no_inline)] attribute is present.
// Don't inline doc(hidden) imports so they can be stripped at a later stage.
let
denied
=
self
.vis
!=
hir
::
Public
||
self
.attrs
.iter
()
.any
(|
a
|
{
a
.name
()
.unwrap
()
==
"doc"
&&
match
a
.meta_item_list
()
{
a
.name
()
==
"doc"
&&
match
a
.meta_item_list
()
{
Some
(
l
)
=>
attr
::
list_contains_name
(
&
l
,
"no_inline"
)
||
attr
::
list_contains_name
(
&
l
,
"hidden"
),
None
=>
false
,
...
...
src/librustdoc/html/render.rs
浏览文件 @
9b3aea60
...
...
@@ -3319,7 +3319,7 @@ fn render_attributes(w: &mut fmt::Formatter, it: &clean::Item) -> fmt::Result {
let
mut
attrs
=
String
::
new
();
for
attr
in
&
it
.attrs.other_attrs
{
let
name
=
attr
.name
()
.unwrap
()
;
let
name
=
attr
.name
();
if
!
ATTRIBUTE_WHITELIST
.contains
(
&&*
name
.as_str
())
{
continue
;
}
...
...
src/libsyntax/attr.rs
浏览文件 @
9b3aea60
...
...
@@ -217,11 +217,10 @@ pub fn check_name(&self, name: &str) -> bool {
matches
}
pub
fn
name
(
&
self
)
->
Option
<
Name
>
{
match
self
.path.segments
.len
()
{
1
=>
Some
(
self
.path.segments
[
0
]
.identifier.name
),
_
=>
None
,
}
/// Returns the first segment of the name of this attribute.
/// E.g. `foo` for `#[foo]`, `rustfmt` for `#[rustfmt::skip]`.
pub
fn
name
(
&
self
)
->
Name
{
name_from_path
(
&
self
.path
)
}
pub
fn
value_str
(
&
self
)
->
Option
<
Symbol
>
{
...
...
src/libsyntax/ext/derive.rs
浏览文件 @
9b3aea60
...
...
@@ -26,7 +26,8 @@ pub fn collect_derives(cx: &mut ExtCtxt, attrs: &mut Vec<ast::Attribute>) -> Vec
return
true
;
}
match
attr
.parse_list
(
cx
.parse_sess
,
|
parser
|
parser
.parse_path
(
PathStyle
::
Mod
))
{
match
attr
.parse_list
(
cx
.parse_sess
,
|
parser
|
parser
.parse_path_allowing_meta
(
PathStyle
::
Mod
))
{
Ok
(
ref
traits
)
if
traits
.is_empty
()
=>
{
cx
.span_warn
(
attr
.span
,
"empty trait list in `derive`"
);
false
...
...
src/libsyntax/feature_gate.rs
浏览文件 @
9b3aea60
...
...
@@ -1132,7 +1132,7 @@ struct Context<'a> {
impl
<
'a
>
Context
<
'a
>
{
fn
check_attribute
(
&
self
,
attr
:
&
ast
::
Attribute
,
is_macro
:
bool
)
{
debug!
(
"check_attribute(attr = {:?})"
,
attr
);
let
name
=
unwrap_or!
(
attr
.name
(),
return
)
.as_str
();
let
name
=
attr
.name
(
)
.as_str
();
for
&
(
n
,
ty
,
ref
gateage
)
in
BUILTIN_ATTRIBUTES
{
if
name
==
n
{
if
let
Gated
(
_
,
name
,
desc
,
ref
has_feature
)
=
*
gateage
{
...
...
src/libsyntax/parse/parser.rs
浏览文件 @
9b3aea60
...
...
@@ -1955,19 +1955,19 @@ pub fn parse_path_common(&mut self, style: PathStyle, enable_warning: bool)
/// Like `parse_path`, but also supports parsing `Word` meta items into paths for back-compat.
/// This is used when parsing derive macro paths in `#[derive]` attributes.
pub
fn
parse_path_allowing_meta
(
&
mut
self
,
style
:
PathStyle
)
->
PResult
<
'a
,
ast
::
Path
>
{
let
meta_
ident
=
match
self
.token
{
let
meta_
name
=
match
self
.token
{
token
::
Interpolated
(
ref
nt
)
=>
match
nt
.0
{
token
::
NtMeta
(
ref
meta
)
=>
match
meta
.node
{
ast
::
MetaItemKind
::
Word
=>
Some
(
meta
.
ident
),
ast
::
MetaItemKind
::
Word
=>
Some
(
meta
.
name
.clone
()
),
_
=>
None
,
},
_
=>
None
,
},
_
=>
None
,
};
if
let
Some
(
ident
)
=
meta_ident
{
if
let
Some
(
path
)
=
meta_name
{
self
.bump
();
return
Ok
(
ast
::
Path
::
from_ident
(
ident
)
);
return
Ok
(
path
);
}
self
.parse_path
(
style
)
}
...
...
src/libsyntax/print/pprust.rs
浏览文件 @
9b3aea60
...
...
@@ -776,6 +776,7 @@ fn print_meta_item(&mut self, item: &ast::MetaItem) -> io::Result<()> {
ast
::
MetaItemKind
::
Word
=>
self
.print_attribute_path
(
&
item
.name
)
?
,
ast
::
MetaItemKind
::
NameValue
(
ref
value
)
=>
{
self
.print_attribute_path
(
&
item
.name
)
?
;
self
.writer
()
.space
()
?
;
self
.word_space
(
"="
)
?
;
self
.print_literal
(
value
)
?
;
}
...
...
src/libsyntax_ext/deriving/custom.rs
浏览文件 @
9b3aea60
...
...
@@ -22,11 +22,9 @@
impl
<
'a
>
Visitor
<
'a
>
for
MarkAttrs
<
'a
>
{
fn
visit_attribute
(
&
mut
self
,
attr
:
&
Attribute
)
{
if
let
Some
(
name
)
=
attr
.name
()
{
if
self
.0
.contains
(
&
name
)
{
mark_used
(
attr
);
mark_known
(
attr
);
}
if
self
.0
.contains
(
&
attr
.name
())
{
mark_used
(
attr
);
mark_known
(
attr
);
}
}
...
...
src/libsyntax_ext/deriving/generic/mod.rs
浏览文件 @
9b3aea60
...
...
@@ -472,7 +472,7 @@ pub fn expand_ext(self,
attrs
.extend
(
item
.attrs
.iter
()
.filter
(|
a
|
{
a
.name
()
.is_some
()
&&
match
&*
a
.name
()
.unwrap
()
.as_str
()
{
match
&*
a
.name
()
.as_str
()
{
"allow"
|
"warn"
|
"deny"
|
"forbid"
|
"stable"
|
"unstable"
=>
true
,
_
=>
false
,
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录