Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
ea5d258a
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,发现更多精彩内容 >>
提交
ea5d258a
编写于
10月 14, 2022
作者:
D
David Wood
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ast_passes: use derive more
Signed-off-by:
N
David Wood
<
david.wood@huawei.com
>
上级
2a4b587a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
6 addition
and
20 deletion
+6
-20
compiler/rustc_ast_passes/src/ast_validation.rs
compiler/rustc_ast_passes/src/ast_validation.rs
+6
-3
compiler/rustc_ast_passes/src/errors.rs
compiler/rustc_ast_passes/src/errors.rs
+0
-17
未找到文件。
compiler/rustc_ast_passes/src/ast_validation.rs
浏览文件 @
ea5d258a
...
...
@@ -14,6 +14,7 @@
use
rustc_ast_pretty
::
pprust
::{
self
,
State
};
use
rustc_data_structures
::
fx
::
FxHashMap
;
use
rustc_errors
::{
error_code
,
fluent
,
pluralize
,
struct_span_err
,
Applicability
};
use
rustc_macros
::
Subdiagnostic
;
use
rustc_parse
::
validate_attr
;
use
rustc_session
::
lint
::
builtin
::{
DEPRECATED_WHERE_CLAUSE_LOCATION
,
MISSING_ABI
,
PATTERNS_IN_FNS_WITHOUT_BODY
,
...
...
@@ -1782,15 +1783,17 @@ pub fn check_crate(session: &Session, krate: &Crate, lints: &mut LintBuffer) ->
}
/// Used to forbid `let` expressions in certain syntactic locations.
#[derive(Clone,
Copy)]
#[derive(Clone,
Copy
,
Subdiagnostic
)]
pub
(
crate
)
enum
ForbiddenLetReason
{
/// `let` is not valid and the source environment is not important
GenericForbidden
,
/// A let chain with the `||` operator
NotSupportedOr
(
Span
),
#[note(ast_passes::not_supported_or)]
NotSupportedOr
(
#[primary_span]
Span
),
/// A let chain with invalid parentheses
///
/// For example, `let 1 = 1 && (expr && expr)` is allowed
/// but `(let 1 = 1 && (let 1 = 1 && (let 1 = 1))) && let a = 1` is not
NotSupportedParentheses
(
Span
),
#[note(ast_passes::not_supported_parentheses)]
NotSupportedParentheses
(
#[primary_span]
Span
),
}
compiler/rustc_ast_passes/src/errors.rs
浏览文件 @
ea5d258a
...
...
@@ -16,23 +16,6 @@ pub struct ForbiddenLet {
pub
(
crate
)
reason
:
ForbiddenLetReason
,
}
impl
AddToDiagnostic
for
ForbiddenLetReason
{
fn
add_to_diagnostic_with
<
F
>
(
self
,
diag
:
&
mut
Diagnostic
,
_
:
F
)
where
F
:
Fn
(
&
mut
Diagnostic
,
SubdiagnosticMessage
)
->
SubdiagnosticMessage
,
{
match
self
{
Self
::
GenericForbidden
=>
{}
Self
::
NotSupportedOr
(
span
)
=>
{
diag
.span_note
(
span
,
fluent
::
ast_passes
::
not_supported_or
);
}
Self
::
NotSupportedParentheses
(
span
)
=>
{
diag
.span_note
(
span
,
fluent
::
ast_passes
::
not_supported_parentheses
);
}
}
}
}
#[derive(Diagnostic)]
#[diag(ast_passes::forbidden_let_stable)]
#[note]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录