Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
a090bb1d
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,发现更多精彩内容 >>
提交
a090bb1d
编写于
1月 25, 2022
作者:
M
Michael Goulet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove delayed bug when encountering label in bad turbofish
上级
e7825f2b
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
45 addition
and
6 deletion
+45
-6
compiler/rustc_parse/src/parser/diagnostics.rs
compiler/rustc_parse/src/parser/diagnostics.rs
+1
-1
compiler/rustc_parse/src/parser/expr.rs
compiler/rustc_parse/src/parser/expr.rs
+3
-2
src/test/ui/parser/issues/issue-93282.rs
src/test/ui/parser/issues/issue-93282.rs
+5
-0
src/test/ui/parser/issues/issue-93282.stderr
src/test/ui/parser/issues/issue-93282.stderr
+19
-0
src/test/ui/parser/require-parens-for-chained-comparison.rs
src/test/ui/parser/require-parens-for-chained-comparison.rs
+2
-0
src/test/ui/parser/require-parens-for-chained-comparison.stderr
...st/ui/parser/require-parens-for-chained-comparison.stderr
+15
-3
未找到文件。
compiler/rustc_parse/src/parser/diagnostics.rs
浏览文件 @
a090bb1d
...
...
@@ -737,7 +737,7 @@ pub(super) fn check_mistyped_turbofish_with_multiple_type_params(
"::"
.to_string
(),
Applicability
::
MaybeIncorrect
,
);
if
self
.check
(
&
TokenKind
::
Semi
)
{
if
matches!
(
self
.token.kind
,
token
::
Semi
|
token
::
CloseDelim
(
_
)
)
{
turbo_err
.emit
();
*
expr
=
self
.mk_expr_err
(
expr
.span
);
return
Ok
(());
...
...
compiler/rustc_parse/src/parser/expr.rs
浏览文件 @
a090bb1d
...
...
@@ -1448,6 +1448,8 @@ fn parse_labeled_expr(
let
lo
=
label
.ident.span
;
let
label
=
Some
(
label
);
let
ate_colon
=
self
.eat
(
&
token
::
Colon
);
let
msg
=
"expected `while`, `for`, `loop` or `{` after a label"
;
let
expr
=
if
self
.eat_keyword
(
kw
::
While
)
{
self
.parse_while_expr
(
label
,
lo
,
attrs
)
}
else
if
self
.eat_keyword
(
kw
::
For
)
{
...
...
@@ -1457,13 +1459,12 @@ fn parse_labeled_expr(
}
else
if
self
.check
(
&
token
::
OpenDelim
(
token
::
Brace
))
||
self
.token
.is_whole_block
()
{
self
.parse_block_expr
(
label
,
lo
,
BlockCheckMode
::
Default
,
attrs
)
}
else
if
!
ate_colon
&&
(
self
.check
(
&
TokenKind
::
Comma
)
||
self
.check
(
&
TokenKind
::
Gt
))
{
self
.struct_span_err
(
self
.token.span
,
msg
)
.span_label
(
self
.token.span
,
msg
)
.emit
();
// We're probably inside of a `Path<'a>` that needs a turbofish, so suppress the
// "must be followed by a colon" error.
self
.diagnostic
()
.delay_span_bug
(
lo
,
"this label wasn't parsed correctly"
);
consume_colon
=
false
;
Ok
(
self
.mk_expr_err
(
lo
))
}
else
{
let
msg
=
"expected `while`, `for`, `loop` or `{` after a label"
;
self
.struct_span_err
(
self
.token.span
,
msg
)
.span_label
(
self
.token.span
,
msg
)
.emit
();
// Continue as an expression in an effort to recover on `'label: non_block_expr`.
self
.parse_expr
()
...
...
src/test/ui/parser/issues/issue-93282.rs
0 → 100644
浏览文件 @
a090bb1d
fn
main
()
{
f
<
'a
,
>
//~^ ERROR expected
//~| ERROR expected
}
src/test/ui/parser/issues/issue-93282.stderr
0 → 100644
浏览文件 @
a090bb1d
error: expected `while`, `for`, `loop` or `{` after a label
--> $DIR/issue-93282.rs:2:9
|
LL | f<'a,>
| ^ expected `while`, `for`, `loop` or `{` after a label
error: expected one of `.`, `:`, `;`, `?`, `for`, `loop`, `while`, `{`, `}`, or an operator, found `,`
--> $DIR/issue-93282.rs:2:9
|
LL | f<'a,>
| ^ expected one of 10 possible tokens
|
help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments
|
LL | f::<'a,>
| ++
error: aborting due to 2 previous errors
src/test/ui/parser/require-parens-for-chained-comparison.rs
浏览文件 @
a090bb1d
...
...
@@ -21,10 +21,12 @@ fn main() {
let
_
=
f
<
'_
,
i8
>
();
//~^ ERROR expected one of
//~| ERROR expected
//~| HELP use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments
f
<
'_
>
();
//~^ comparison operators cannot be chained
//~| ERROR expected
//~| HELP use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments
let
_
=
f
<
u8
>
;
...
...
src/test/ui/parser/require-parens-for-chained-comparison.stderr
浏览文件 @
a090bb1d
...
...
@@ -53,6 +53,12 @@ help: use `::<...>` instead of `<...>` to specify lifetime, type, or const argum
LL | let _ = f::<u8, i8>();
| ++
error: expected `while`, `for`, `loop` or `{` after a label
--> $DIR/require-parens-for-chained-comparison.rs:22:17
|
LL | let _ = f<'_, i8>();
| ^ expected `while`, `for`, `loop` or `{` after a label
error: expected one of `.`, `:`, `;`, `?`, `else`, `for`, `loop`, `while`, `{`, or an operator, found `,`
--> $DIR/require-parens-for-chained-comparison.rs:22:17
|
...
...
@@ -64,8 +70,14 @@ help: use `::<...>` instead of `<...>` to specify lifetime, type, or const argum
LL | let _ = f::<'_, i8>();
| ++
error: expected `while`, `for`, `loop` or `{` after a label
--> $DIR/require-parens-for-chained-comparison.rs:27:9
|
LL | f<'_>();
| ^ expected `while`, `for`, `loop` or `{` after a label
error: comparison operators cannot be chained
--> $DIR/require-parens-for-chained-comparison.rs:2
6
:6
--> $DIR/require-parens-for-chained-comparison.rs:2
7
:6
|
LL | f<'_>();
| ^ ^
...
...
@@ -76,7 +88,7 @@ LL | f::<'_>();
| ++
error: comparison operators cannot be chained
--> $DIR/require-parens-for-chained-comparison.rs:3
0
:14
--> $DIR/require-parens-for-chained-comparison.rs:3
2
:14
|
LL | let _ = f<u8>;
| ^ ^
...
...
@@ -84,5 +96,5 @@ LL | let _ = f<u8>;
= help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments
= help: or use `(...)` if you meant to specify fn arguments
error: aborting due to
8
previous errors
error: aborting due to
10
previous errors
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录