Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
4d1daf86
R
Rust
项目概览
int
/
Rust
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
4d1daf86
编写于
7月 11, 2021
作者:
E
Eric Huss
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplify future incompatible reporting.
上级
e9a387d6
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
21 addition
and
48 deletion
+21
-48
compiler/rustc_errors/src/emitter.rs
compiler/rustc_errors/src/emitter.rs
+1
-2
compiler/rustc_errors/src/json.rs
compiler/rustc_errors/src/json.rs
+4
-8
compiler/rustc_errors/src/lib.rs
compiler/rustc_errors/src/lib.rs
+1
-2
compiler/rustc_lint_defs/src/builtin.rs
compiler/rustc_lint_defs/src/builtin.rs
+2
-4
compiler/rustc_lint_defs/src/lib.rs
compiler/rustc_lint_defs/src/lib.rs
+3
-10
compiler/rustc_middle/src/lint.rs
compiler/rustc_middle/src/lint.rs
+8
-3
compiler/rustc_session/src/session.rs
compiler/rustc_session/src/session.rs
+2
-19
未找到文件。
compiler/rustc_errors/src/emitter.rs
浏览文件 @
4d1daf86
...
...
@@ -9,7 +9,6 @@
use
Destination
::
*
;
use
rustc_lint_defs
::
FutureBreakage
;
use
rustc_span
::
source_map
::
SourceMap
;
use
rustc_span
::{
MultiSpan
,
SourceFile
,
Span
};
...
...
@@ -193,7 +192,7 @@ pub trait Emitter {
/// other formats can, and will, simply ignore it.
fn
emit_artifact_notification
(
&
mut
self
,
_
path
:
&
Path
,
_
artifact_type
:
&
str
)
{}
fn
emit_future_breakage_report
(
&
mut
self
,
_
diags
:
Vec
<
(
FutureBreakage
,
Diagnostic
)
>
)
{}
fn
emit_future_breakage_report
(
&
mut
self
,
_
diags
:
Vec
<
Diagnostic
>
)
{}
/// Emit list of unused externs
fn
emit_unused_externs
(
&
mut
self
,
_
lint_level
:
&
str
,
_u
nused_externs
:
&
[
&
str
])
{}
...
...
compiler/rustc_errors/src/json.rs
浏览文件 @
4d1daf86
...
...
@@ -16,7 +16,7 @@
use
crate
::
DiagnosticId
;
use
crate
::
ToolMetadata
;
use
crate
::{
CodeSuggestion
,
SubDiagnostic
};
use
rustc_lint_defs
::
{
Applicability
,
FutureBreakage
}
;
use
rustc_lint_defs
::
Applicability
;
use
rustc_data_structures
::
sync
::
Lrc
;
use
rustc_span
::
hygiene
::
ExpnData
;
...
...
@@ -134,17 +134,14 @@ fn emit_artifact_notification(&mut self, path: &Path, artifact_type: &str) {
}
}
fn
emit_future_breakage_report
(
&
mut
self
,
diags
:
Vec
<
(
FutureBreakage
,
crate
::
Diagnostic
)
>
)
{
fn
emit_future_breakage_report
(
&
mut
self
,
diags
:
Vec
<
crate
::
Diagnostic
>
)
{
let
data
:
Vec
<
FutureBreakageItem
>
=
diags
.into_iter
()
.map
(|
(
breakage
,
mut
diag
)
|
{
.map
(|
mut
diag
|
{
if
diag
.level
==
crate
::
Level
::
Allow
{
diag
.level
=
crate
::
Level
::
Warning
;
}
FutureBreakageItem
{
future_breakage_date
:
breakage
.date
,
diagnostic
:
Diagnostic
::
from_errors_diagnostic
(
&
diag
,
self
),
}
FutureBreakageItem
{
diagnostic
:
Diagnostic
::
from_errors_diagnostic
(
&
diag
,
self
)
}
})
.collect
();
let
report
=
FutureIncompatReport
{
future_incompat_report
:
data
};
...
...
@@ -326,7 +323,6 @@ struct ArtifactNotification<'a> {
#[derive(Encodable)]
struct
FutureBreakageItem
{
future_breakage_date
:
Option
<&
'static
str
>
,
diagnostic
:
Diagnostic
,
}
...
...
compiler/rustc_errors/src/lib.rs
浏览文件 @
4d1daf86
...
...
@@ -23,7 +23,6 @@
use
rustc_data_structures
::
stable_hasher
::
StableHasher
;
use
rustc_data_structures
::
sync
::{
self
,
Lock
,
Lrc
};
use
rustc_data_structures
::
AtomicRef
;
use
rustc_lint_defs
::
FutureBreakage
;
pub
use
rustc_lint_defs
::{
pluralize
,
Applicability
};
use
rustc_serialize
::
json
::
Json
;
use
rustc_serialize
::{
Decodable
,
Decoder
,
Encodable
,
Encoder
};
...
...
@@ -790,7 +789,7 @@ pub fn emit_artifact_notification(&self, path: &Path, artifact_type: &str) {
self
.inner
.borrow_mut
()
.emit_artifact_notification
(
path
,
artifact_type
)
}
pub
fn
emit_future_breakage_report
(
&
self
,
diags
:
Vec
<
(
FutureBreakage
,
Diagnostic
)
>
)
{
pub
fn
emit_future_breakage_report
(
&
self
,
diags
:
Vec
<
Diagnostic
>
)
{
self
.inner
.borrow_mut
()
.emitter
.emit_future_breakage_report
(
diags
)
}
...
...
compiler/rustc_lint_defs/src/builtin.rs
浏览文件 @
4d1daf86
...
...
@@ -6,7 +6,7 @@
//! compiler code, rather than using their own custom pass. Those
//! lints are all available in `rustc_lint::builtin`.
use
crate
::{
declare_lint
,
declare_lint_pass
,
Future
Breakage
,
Future
IncompatibilityReason
};
use
crate
::{
declare_lint
,
declare_lint_pass
,
FutureIncompatibilityReason
};
use
rustc_span
::
edition
::
Edition
;
declare_lint!
{
...
...
@@ -3176,9 +3176,7 @@
"detects usage of old versions of certain proc-macro crates"
,
@
future_incompatible
=
FutureIncompatibleInfo
{
reference
:
"issue #83125 <https://github.com/rust-lang/rust/issues/83125>"
,
future_breakage
:
Some
(
FutureBreakage
{
date
:
None
})
reason
:
FutureIncompatibilityReason
::
FutureReleaseErrorReportNow
,
};
}
...
...
compiler/rustc_lint_defs/src/lib.rs
浏览文件 @
4d1daf86
...
...
@@ -152,10 +152,6 @@ pub struct FutureIncompatibleInfo {
/// Set to false for lints that already include a more detailed
/// explanation.
pub
explain_reason
:
bool
,
/// Information about a future breakage, which will
/// be emitted in JSON messages to be displayed by Cargo
/// for upstream deps
pub
future_breakage
:
Option
<
FutureBreakage
>
,
}
/// The reason for future incompatibility
...
...
@@ -164,6 +160,9 @@ pub enum FutureIncompatibilityReason {
/// This will be an error in a future release
/// for all editions
FutureReleaseError
,
/// This will be an error in a future release, and
/// Cargo should create a report even for dependencies
FutureReleaseErrorReportNow
,
/// Previously accepted code that will become an
/// error in the provided edition
EditionError
(
Edition
),
...
...
@@ -182,18 +181,12 @@ pub fn edition(self) -> Option<Edition> {
}
}
#[derive(Copy,
Clone,
Debug)]
pub
struct
FutureBreakage
{
pub
date
:
Option
<&
'static
str
>
,
}
impl
FutureIncompatibleInfo
{
pub
const
fn
default_fields_for_macro
()
->
Self
{
FutureIncompatibleInfo
{
reference
:
""
,
reason
:
FutureIncompatibilityReason
::
FutureReleaseError
,
explain_reason
:
true
,
future_breakage
:
None
,
}
}
}
...
...
compiler/rustc_middle/src/lint.rs
浏览文件 @
4d1daf86
...
...
@@ -8,7 +8,7 @@
use
rustc_index
::
vec
::
IndexVec
;
use
rustc_session
::
lint
::{
builtin
::{
self
,
FORBIDDEN_LINT_GROUPS
},
FutureIncompatibilityReason
,
Level
,
Lint
,
LintId
,
FutureIncompatibilityReason
,
FutureIncompatibleInfo
,
Level
,
Lint
,
LintId
,
};
use
rustc_session
::{
DiagnosticMessageId
,
Session
};
use
rustc_span
::
hygiene
::
MacroKind
;
...
...
@@ -223,8 +223,13 @@ fn struct_lint_level_impl(
let
lint_id
=
LintId
::
of
(
lint
);
let
future_incompatible
=
lint
.future_incompatible
;
let
has_future_breakage
=
future_incompatible
.map_or
(
false
,
|
incompat
|
incompat
.future_breakage
.is_some
());
let
has_future_breakage
=
matches!
(
future_incompatible
,
Some
(
FutureIncompatibleInfo
{
reason
:
FutureIncompatibilityReason
::
FutureReleaseErrorReportNow
,
..
})
);
let
mut
err
=
match
(
level
,
span
)
{
(
Level
::
Allow
,
span
)
=>
{
...
...
compiler/rustc_session/src/session.rs
浏览文件 @
4d1daf86
...
...
@@ -20,8 +20,7 @@
use
rustc_errors
::
emitter
::{
Emitter
,
EmitterWriter
,
HumanReadableErrorType
};
use
rustc_errors
::
json
::
JsonEmitter
;
use
rustc_errors
::
registry
::
Registry
;
use
rustc_errors
::{
Diagnostic
,
DiagnosticBuilder
,
DiagnosticId
,
ErrorReported
};
use
rustc_lint_defs
::
FutureBreakage
;
use
rustc_errors
::{
DiagnosticBuilder
,
DiagnosticId
,
ErrorReported
};
use
rustc_macros
::
HashStable_Generic
;
pub
use
rustc_span
::
def_id
::
StableCrateId
;
use
rustc_span
::
source_map
::{
FileLoader
,
MultiSpan
,
RealFileLoader
,
SourceMap
,
Span
};
...
...
@@ -317,23 +316,7 @@ fn emit_future_breakage(&self) {
if
diags
.is_empty
()
{
return
;
}
// If any future-breakage lints were registered, this lint store
// should be available
let
lint_store
=
self
.lint_store
.get
()
.expect
(
"`lint_store` not initialized!"
);
let
diags_and_breakage
:
Vec
<
(
FutureBreakage
,
Diagnostic
)
>
=
diags
.into_iter
()
.map
(|
diag
|
{
let
lint_name
=
match
&
diag
.code
{
Some
(
DiagnosticId
::
Lint
{
name
,
has_future_breakage
:
true
,
..
})
=>
name
,
_
=>
panic!
(
"Unexpected code in diagnostic {:?}"
,
diag
),
};
let
lint
=
lint_store
.name_to_lint
(
&
lint_name
);
let
future_breakage
=
lint
.lint.future_incompatible
.unwrap
()
.future_breakage
.unwrap
();
(
future_breakage
,
diag
)
})
.collect
();
self
.parse_sess.span_diagnostic
.emit_future_breakage_report
(
diags_and_breakage
);
self
.parse_sess.span_diagnostic
.emit_future_breakage_report
(
diags
);
}
pub
fn
local_stable_crate_id
(
&
self
)
->
StableCrateId
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录