Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
8f3aa5e8
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,发现更多精彩内容 >>
提交
8f3aa5e8
编写于
9月 06, 2021
作者:
B
bors
浏览文件
操作
浏览文件
下载
差异文件
Auto merge of #88493 - chenyukang:fix-duplicated-diagnostic, r=estebank
Fix #88256 remove duplicated diagnostics Fix #88256
上级
7849e3e9
ca27f03c
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
59 addition
and
65 deletion
+59
-65
compiler/rustc_errors/src/diagnostic.rs
compiler/rustc_errors/src/diagnostic.rs
+48
-1
compiler/rustc_errors/src/diagnostic_builder.rs
compiler/rustc_errors/src/diagnostic_builder.rs
+1
-0
compiler/rustc_middle/src/lint.rs
compiler/rustc_middle/src/lint.rs
+1
-0
src/test/ui/lint/issue-70819-dont-override-forbid-in-same-scope.rs
...ui/lint/issue-70819-dont-override-forbid-in-same-scope.rs
+0
-2
src/test/ui/lint/issue-70819-dont-override-forbid-in-same-scope.stderr
...int/issue-70819-dont-override-forbid-in-same-scope.stderr
+1
-12
src/test/ui/lint/outer-forbid.rs
src/test/ui/lint/outer-forbid.rs
+1
-2
src/test/ui/lint/outer-forbid.stderr
src/test/ui/lint/outer-forbid.stderr
+3
-15
src/tools/clippy/tests/ui/match_same_arms.stderr
src/tools/clippy/tests/ui/match_same_arms.stderr
+1
-19
src/tools/clippy/tests/ui/modulo_one.stderr
src/tools/clippy/tests/ui/modulo_one.stderr
+1
-7
src/tools/clippy/tests/ui/suspicious_operation_groupings.stderr
...ols/clippy/tests/ui/suspicious_operation_groupings.stderr
+1
-7
src/tools/rustfmt/src/syntux/session.rs
src/tools/rustfmt/src/syntux/session.rs
+1
-0
未找到文件。
compiler/rustc_errors/src/diagnostic.rs
浏览文件 @
8f3aa5e8
...
...
@@ -9,9 +9,10 @@
use
rustc_serialize
::
json
::
Json
;
use
rustc_span
::{
MultiSpan
,
Span
,
DUMMY_SP
};
use
std
::
fmt
;
use
std
::
hash
::{
Hash
,
Hasher
};
#[must_use]
#[derive(Clone,
Debug,
PartialEq,
Hash,
Encodable,
Decodable)]
#[derive(Clone,
Debug,
Encodable,
Decodable)]
pub
struct
Diagnostic
{
pub
level
:
Level
,
pub
message
:
Vec
<
(
String
,
Style
)
>
,
...
...
@@ -24,6 +25,10 @@ pub struct Diagnostic {
/// as a sort key to sort a buffer of diagnostics. By default, it is the primary span of
/// `span` if there is one. Otherwise, it is `DUMMY_SP`.
pub
sort_span
:
Span
,
/// If diagnostic is from Lint, custom hash function ignores notes
/// otherwise hash is based on the all the fields
pub
is_lint
:
bool
,
}
#[derive(Clone,
Debug,
PartialEq,
Eq,
Hash,
Encodable,
Decodable)]
...
...
@@ -91,6 +96,7 @@ pub fn new_with_code(level: Level, code: Option<DiagnosticId>, message: &str) ->
children
:
vec!
[],
suggestions
:
vec!
[],
sort_span
:
DUMMY_SP
,
is_lint
:
false
,
}
}
...
...
@@ -558,6 +564,11 @@ pub fn set_span<S: Into<MultiSpan>>(&mut self, sp: S) -> &mut Self {
self
}
pub
fn
set_is_lint
(
&
mut
self
)
->
&
mut
Self
{
self
.is_lint
=
true
;
self
}
pub
fn
code
(
&
mut
self
,
s
:
DiagnosticId
)
->
&
mut
Self
{
self
.code
=
Some
(
s
);
self
...
...
@@ -617,6 +628,42 @@ fn sub_with_highlights(
let
sub
=
SubDiagnostic
{
level
,
message
,
span
,
render_span
};
self
.children
.push
(
sub
);
}
/// Fields used for Hash, and PartialEq trait
fn
keys
(
&
self
,
)
->
(
&
Level
,
&
Vec
<
(
String
,
Style
)
>
,
&
Option
<
DiagnosticId
>
,
&
MultiSpan
,
&
Vec
<
CodeSuggestion
>
,
Option
<&
Vec
<
SubDiagnostic
>>
,
)
{
(
&
self
.level
,
&
self
.message
,
&
self
.code
,
&
self
.span
,
&
self
.suggestions
,
(
if
self
.is_lint
{
None
}
else
{
Some
(
&
self
.children
)
}),
)
}
}
impl
Hash
for
Diagnostic
{
fn
hash
<
H
>
(
&
self
,
state
:
&
mut
H
)
where
H
:
Hasher
,
{
self
.keys
()
.hash
(
state
);
}
}
impl
PartialEq
for
Diagnostic
{
fn
eq
(
&
self
,
other
:
&
Self
)
->
bool
{
self
.keys
()
==
other
.keys
()
}
}
impl
SubDiagnostic
{
...
...
compiler/rustc_errors/src/diagnostic_builder.rs
浏览文件 @
8f3aa5e8
...
...
@@ -242,6 +242,7 @@ pub fn span_labels(
sp
:
S
,
msg
:
&
str
,
)
->
&
mut
Self
);
forward!
(
pub
fn
set_is_lint
(
&
mut
self
,)
->
&
mut
Self
);
/// See [`Diagnostic::multipart_suggestion()`].
pub
fn
multipart_suggestion
(
...
...
compiler/rustc_middle/src/lint.rs
浏览文件 @
8f3aa5e8
...
...
@@ -192,6 +192,7 @@ impl<'a> LintDiagnosticBuilder<'a> {
/// Return the inner DiagnosticBuilder, first setting the primary message to `msg`.
pub
fn
build
(
mut
self
,
msg
:
&
str
)
->
DiagnosticBuilder
<
'a
>
{
self
.0
.set_primary_message
(
msg
);
self
.0
.set_is_lint
();
self
.0
}
...
...
src/test/ui/lint/issue-70819-dont-override-forbid-in-same-scope.rs
浏览文件 @
8f3aa5e8
...
...
@@ -21,8 +21,6 @@ fn forbid_first(num: i32) -> i32 {
#![deny(unused)]
//~^ ERROR: deny(unused) incompatible with previous forbid
//~| WARNING being phased out
//~| ERROR: deny(unused) incompatible with previous forbid
//~| WARNING being phased out
#![warn(unused)]
#![allow(unused)]
...
...
src/test/ui/lint/issue-70819-dont-override-forbid-in-same-scope.stderr
浏览文件 @
8f3aa5e8
...
...
@@ -14,16 +14,5 @@ LL | #![forbid(forbidden_lint_groups)]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
error: deny(unused) incompatible with previous forbid
--> $DIR/issue-70819-dont-override-forbid-in-same-scope.rs:21:13
|
LL | #![forbid(unused)]
| ------ `forbid` level set here
LL | #![deny(unused)]
| ^^^^^^ overruled by previous forbid
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
error: aborting due to 2 previous errors
error: aborting due to previous error
src/test/ui/lint/outer-forbid.rs
浏览文件 @
8f3aa5e8
...
...
@@ -17,10 +17,9 @@
#![forbid(unused,
non_snake_case)]
#![forbid(forbidden_lint_groups)]
#[allow(unused_variables)]
//~ ERROR incompatible with previous
#[allow(unused_variables)]
//~^ ERROR incompatible with previous
//~| WARNING this was previously accepted by the compiler
//~| WARNING this was previously accepted by the compiler
fn
foo
()
{}
#[allow(unused)]
//~ ERROR incompatible with previous
...
...
src/test/ui/lint/outer-forbid.stderr
浏览文件 @
8f3aa5e8
...
...
@@ -16,7 +16,7 @@ LL | #![forbid(forbidden_lint_groups)]
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
error: allow(unused) incompatible with previous forbid
--> $DIR/outer-forbid.rs:2
6
:9
--> $DIR/outer-forbid.rs:2
5
:9
|
LL | #![forbid(unused, non_snake_case)]
| ------ `forbid` level set here
...
...
@@ -28,7 +28,7 @@ LL | #[allow(unused)]
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
error[E0453]: allow(nonstandard_style) incompatible with previous forbid
--> $DIR/outer-forbid.rs:
30
:9
--> $DIR/outer-forbid.rs:
29
:9
|
LL | #![forbid(unused, non_snake_case)]
| -------------- `forbid` level set here
...
...
@@ -36,18 +36,6 @@ LL | #![forbid(unused, non_snake_case)]
LL | #[allow(nonstandard_style)]
| ^^^^^^^^^^^^^^^^^ overruled by previous forbid
error: allow(unused_variables) incompatible with previous forbid
--> $DIR/outer-forbid.rs:20:9
|
LL | #![forbid(unused, non_snake_case)]
| ------ `forbid` level set here
...
LL | #[allow(unused_variables)]
| ^^^^^^^^^^^^^^^^ overruled by previous forbid
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
error: aborting due to 4 previous errors
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0453`.
src/tools/clippy/tests/ui/match_same_arms.stderr
浏览文件 @
8f3aa5e8
...
...
@@ -106,24 +106,6 @@ LL | 1 => 2,
| ^
= help: ...or consider changing the match arm bodies
error: this `match` has identical arm bodies
--> $DIR/match_same_arms.rs:33:14
|
LL | 3 => 2, //~ ERROR 3rd matched arms have same body
| ^
|
note: same as this
--> $DIR/match_same_arms.rs:32:14
|
LL | 2 => 2, //~ ERROR 2nd matched arms have same body
| ^
help: consider refactoring into `2 | 3`
--> $DIR/match_same_arms.rs:32:9
|
LL | 2 => 2, //~ ERROR 2nd matched arms have same body
| ^
= help: ...or consider changing the match arm bodies
error: this `match` has identical arm bodies
--> $DIR/match_same_arms.rs:50:55
|
...
...
@@ -142,5 +124,5 @@ LL | CommandInfo::BuiltIn { name, .. } => name.to_string(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: ...or consider changing the match arm bodies
error: aborting due to
8
previous errors
error: aborting due to
7
previous errors
src/tools/clippy/tests/ui/modulo_one.stderr
浏览文件 @
8f3aa5e8
...
...
@@ -46,12 +46,6 @@ LL | const ONE: u32 = 1 * 1;
|
= note: `-D clippy::identity-op` implied by `-D warnings`
error: the operation is ineffective. Consider reducing it to `1`
--> $DIR/modulo_one.rs:13:22
|
LL | const ONE: u32 = 1 * 1;
| ^^^^^
error: any number modulo 1 will be 0
--> $DIR/modulo_one.rs:17:5
|
...
...
@@ -70,5 +64,5 @@ error: any number modulo -1 will panic/overflow or result in 0
LL | INT_MIN % NEG_ONE; // also caught by rustc
| ^^^^^^^^^^^^^^^^^
error: aborting due to 1
1
previous errors
error: aborting due to 1
0
previous errors
src/tools/clippy/tests/ui/suspicious_operation_groupings.stderr
浏览文件 @
8f3aa5e8
...
...
@@ -6,12 +6,6 @@ LL | self.x == other.y && self.y == other.y && self.z == other.z
|
= note: `-D clippy::suspicious-operation-groupings` implied by `-D warnings`
error: this sequence of operators looks suspiciously like a bug
--> $DIR/suspicious_operation_groupings.rs:14:9
|
LL | self.x == other.y && self.y == other.y && self.z == other.z
| ^^^^^^^^^^^^^^^^^ help: did you mean: `self.x == other.x`
error: this sequence of operators looks suspiciously like a bug
--> $DIR/suspicious_operation_groupings.rs:27:20
|
...
...
@@ -162,5 +156,5 @@ error: this sequence of operators looks suspiciously like a bug
LL | -(if -s1.a < -s2.a && -s1.a < -s2.b { s1.c } else { s2.a })
| ^^^^^^^^^^^^^ help: did you mean: `-s1.b < -s2.b`
error: aborting due to 2
7
previous errors
error: aborting due to 2
6
previous errors
src/tools/rustfmt/src/syntux/session.rs
浏览文件 @
8f3aa5e8
...
...
@@ -311,6 +311,7 @@ fn build_diagnostic(level: DiagnosticLevel, span: Option<MultiSpan>) -> Diagnost
suggestions
:
vec!
[],
span
:
span
.unwrap_or_else
(
MultiSpan
::
new
),
sort_span
:
DUMMY_SP
,
is_lint
:
false
,
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录