Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
46d39f33
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,发现更多精彩内容 >>
提交
46d39f33
编写于
10月 27, 2016
作者:
B
bors
提交者:
GitHub
10月 27, 2016
浏览文件
操作
浏览文件
下载
差异文件
Auto merge of #37128 - nrc:depr-attr, r=@alexcrichton
Deprecate no_debug and custom_derive r? @nikomatsakis
上级
bc283c94
8c4a39cd
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
199 addition
and
51 deletion
+199
-51
src/librustc/lint/mod.rs
src/librustc/lint/mod.rs
+0
-1
src/librustc_lint/builtin.rs
src/librustc_lint/builtin.rs
+50
-1
src/librustc_lint/lib.rs
src/librustc_lint/lib.rs
+13
-0
src/libsyntax/feature_gate.rs
src/libsyntax/feature_gate.rs
+116
-48
src/libsyntax/lib.rs
src/libsyntax/lib.rs
+1
-0
src/libsyntax_ext/deriving/mod.rs
src/libsyntax_ext/deriving/mod.rs
+1
-0
src/test/compile-fail/deriving-meta-unknown-trait.rs
src/test/compile-fail/deriving-meta-unknown-trait.rs
+3
-1
src/test/compile-fail/feature-gate-no-debug-2.rs
src/test/compile-fail/feature-gate-no-debug-2.rs
+15
-0
未找到文件。
src/librustc/lint/mod.rs
浏览文件 @
46d39f33
...
...
@@ -314,5 +314,4 @@ pub enum LintSource {
pub
type
LevelSource
=
(
Level
,
LintSource
);
pub
mod
builtin
;
mod
context
;
src/librustc_lint/builtin.rs
浏览文件 @
46d39f33
...
...
@@ -39,12 +39,13 @@
use
rustc
::
hir
::
map
as
hir_map
;
use
util
::
nodemap
::
NodeSet
;
use
lint
::{
Level
,
LateContext
,
LintContext
,
LintArray
,
Lint
};
use
lint
::{
LintPass
,
LateLintPass
};
use
lint
::{
LintPass
,
LateLintPass
,
EarlyLintPass
,
EarlyContext
};
use
std
::
collections
::
HashSet
;
use
syntax
::
ast
;
use
syntax
::
attr
;
use
syntax
::
feature_gate
::{
AttributeGate
,
AttributeType
,
Stability
,
deprecated_attributes
};
use
syntax_pos
::
Span
;
use
rustc
::
hir
::{
self
,
PatKind
};
...
...
@@ -741,6 +742,54 @@ fn check_foreign_item_post(&mut self, cx: &LateContext, item: &hir::ForeignItem)
}
}
declare_lint!
{
DEPRECATED_ATTR
,
Warn
,
"detects use of deprecated attributes"
}
/// Checks for use of attributes which have been deprecated.
#[derive(Clone)]
pub
struct
DeprecatedAttr
{
// This is not free to compute, so we want to keep it around, rather than
// compute it for every attribute.
depr_attrs
:
Vec
<&
'static
(
&
'static
str
,
AttributeType
,
AttributeGate
)
>
,
}
impl
DeprecatedAttr
{
pub
fn
new
()
->
DeprecatedAttr
{
DeprecatedAttr
{
depr_attrs
:
deprecated_attributes
(),
}
}
}
impl
LintPass
for
DeprecatedAttr
{
fn
get_lints
(
&
self
)
->
LintArray
{
lint_array!
(
DEPRECATED_ATTR
)
}
}
impl
EarlyLintPass
for
DeprecatedAttr
{
fn
check_attribute
(
&
mut
self
,
cx
:
&
EarlyContext
,
attr
:
&
ast
::
Attribute
)
{
let
name
=
&*
attr
.name
();
for
&&
(
n
,
_
,
ref
g
)
in
&
self
.depr_attrs
{
if
n
==
name
{
if
let
&
AttributeGate
::
Gated
(
Stability
::
Deprecated
(
link
),
ref
name
,
ref
reason
,
_
)
=
g
{
cx
.span_lint
(
DEPRECATED
,
attr
.span
,
&
format!
(
"use of deprecated attribute `{}`: {}. See {}"
,
name
,
reason
,
link
));
}
return
;
}
}
}
}
declare_lint!
{
pub
UNCONDITIONAL_RECURSION
,
Warn
,
...
...
src/librustc_lint/lib.rs
浏览文件 @
46d39f33
...
...
@@ -37,6 +37,7 @@
#![feature(rustc_private)]
#![feature(slice_patterns)]
#![feature(staged_api)]
#![feature(dotdot_in_tuple_patterns)]
#[macro_use]
extern
crate
syntax
;
...
...
@@ -95,6 +96,14 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
)
}
macro_rules!
add_early_builtin_with_new
{
(
$sess:ident
,
$
(
$name:ident
),
*
,)
=>
(
{
$
(
store
.register_early_pass
(
$sess
,
false
,
box
$name
::
new
());
)
*
}
)
}
macro_rules!
add_lint_group
{
(
$sess:ident
,
$name:expr
,
$
(
$lint:ident
),
*
)
=>
(
store
.register_group
(
$sess
,
false
,
$name
,
vec!
[
$
(
LintId
::
of
(
$lint
)),
*
]);
...
...
@@ -105,6 +114,10 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
UnusedParens
,
);
add_early_builtin_with_new!
(
sess
,
DeprecatedAttr
,
);
add_builtin!
(
sess
,
HardwiredLints
,
WhileTrue
,
...
...
src/libsyntax/feature_gate.rs
浏览文件 @
46d39f33
此差异已折叠。
点击以展开。
src/libsyntax/lib.rs
浏览文件 @
46d39f33
...
...
@@ -34,6 +34,7 @@
#![cfg_attr(stage0,
feature(question_mark))]
#![feature(rustc_diagnostic_macros)]
#![feature(specialization)]
#![feature(dotdot_in_tuple_patterns)]
extern
crate
serialize
;
extern
crate
term
;
...
...
src/libsyntax_ext/deriving/mod.rs
浏览文件 @
46d39f33
...
...
@@ -175,6 +175,7 @@ pub fn expand_derive(cx: &mut ExtCtxt,
feature_gate
::
GateIssue
::
Language
,
feature_gate
::
EXPLAIN_CUSTOM_DERIVE
);
}
else
{
cx
.span_warn
(
titem
.span
,
feature_gate
::
EXPLAIN_DEPR_CUSTOM_DERIVE
);
let
name
=
intern_and_get_ident
(
&
format!
(
"derive_{}"
,
tname
));
let
mitem
=
cx
.meta_word
(
titem
.span
,
name
);
new_attributes
.push
(
cx
.attribute
(
mitem
.span
,
mitem
));
...
...
src/test/compile-fail/deriving-meta-unknown-trait.rs
浏览文件 @
46d39f33
...
...
@@ -8,8 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-tidy-linelength
#[derive(Eqr)]
//~^ ERROR `#[derive]` for custom traits is not stable enough for use
and is subject to change
//~^ ERROR `#[derive]` for custom traits is not stable enough for use
. It is deprecated and will be removed in v1.15 (see issue #29644)
struct
Foo
;
pub
fn
main
()
{}
src/test/compile-fail/feature-gate-no-debug-2.rs
0 → 100644
浏览文件 @
46d39f33
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![deny(deprecated)]
#![feature(no_debug)]
#[no_debug]
//~ ERROR use of deprecated attribute `no_debug`
fn
main
()
{}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录