Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
83756d97
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,发现更多精彩内容 >>
未验证
提交
83756d97
编写于
8月 12, 2023
作者:
M
Matthias Krüger
提交者:
GitHub
8月 12, 2023
浏览文件
操作
浏览文件
下载
差异文件
Rollup merge of #114584 - darklyspaced:master, r=cjgillot
E0277 nolonger points at phantom `.await` fixes #113203
上级
8a997b15
89284af8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
38 addition
and
74 deletion
+38
-74
compiler/rustc_parse/src/parser/diagnostics.rs
compiler/rustc_parse/src/parser/diagnostics.rs
+1
-7
tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.rs
...async-await/await-keyword/incorrect-syntax-suggestions.rs
+3
-8
tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr
...c-await/await-keyword/incorrect-syntax-suggestions.stderr
+19
-59
tests/ui/parser/issues/issue-113203.rs
tests/ui/parser/issues/issue-113203.rs
+7
-0
tests/ui/parser/issues/issue-113203.stderr
tests/ui/parser/issues/issue-113203.stderr
+8
-0
未找到文件。
compiler/rustc_parse/src/parser/diagnostics.rs
浏览文件 @
83756d97
...
...
@@ -1717,13 +1717,7 @@ pub(super) fn recover_incorrect_await_syntax(
self
.recover_await_prefix
(
await_sp
)
?
};
let
sp
=
self
.error_on_incorrect_await
(
lo
,
hi
,
&
expr
,
is_question
);
let
kind
=
match
expr
.kind
{
// Avoid knock-down errors as we don't know whether to interpret this as `foo().await?`
// or `foo()?.await` (the very reason we went with postfix syntax 😅).
ExprKind
::
Try
(
_
)
=>
ExprKind
::
Err
,
_
=>
ExprKind
::
Await
(
expr
,
await_sp
),
};
let
expr
=
self
.mk_expr
(
lo
.to
(
sp
),
kind
);
let
expr
=
self
.mk_expr
(
lo
.to
(
sp
),
ExprKind
::
Err
);
self
.maybe_recover_from_bad_qpath
(
expr
)
}
...
...
tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.rs
浏览文件 @
83756d97
...
...
@@ -49,13 +49,11 @@ async fn foo8() -> Result<(), ()> {
Ok
(())
}
fn
foo9
()
->
Result
<
(),
()
>
{
let
_
=
await
bar
();
//~ ERROR `await` is only allowed inside `async` functions and blocks
//~^ ERROR incorrect use of `await`
let
_
=
await
bar
();
//~ ERROR incorrect use of `await`
Ok
(())
}
fn
foo10
()
->
Result
<
(),
()
>
{
let
_
=
await
?
bar
();
//~ ERROR `await` is only allowed inside `async` functions and blocks
//~^ ERROR incorrect use of `await`
let
_
=
await
?
bar
();
//~ ERROR incorrect use of `await`
Ok
(())
}
fn
foo11
()
->
Result
<
(),
()
>
{
...
...
@@ -63,8 +61,7 @@ fn foo11() -> Result<(), ()> {
Ok
(())
}
fn
foo12
()
->
Result
<
(),
()
>
{
let
_
=
(
await
bar
())
?
;
//~ ERROR `await` is only allowed inside `async` functions and blocks
//~^ ERROR incorrect use of `await`
let
_
=
(
await
bar
())
?
;
//~ ERROR incorrect use of `await`
Ok
(())
}
fn
foo13
()
->
Result
<
(),
()
>
{
...
...
@@ -111,7 +108,6 @@ async fn foo27() -> Result<(), ()> {
fn
foo28
()
->
Result
<
(),
()
>
{
fn
foo
()
->
Result
<
(),
()
>
{
let
_
=
await
!
(
bar
())
?
;
//~ ERROR incorrect use of `await`
//~^ ERROR `await` is only allowed inside `async` functions
Ok
(())
}
foo
()
...
...
@@ -119,7 +115,6 @@ fn foo() -> Result<(), ()> {
fn
foo29
()
->
Result
<
(),
()
>
{
let
foo
=
||
{
let
_
=
await
!
(
bar
())
?
;
//~ ERROR incorrect use of `await`
//~^ ERROR `await` is only allowed inside `async` functions
Ok
(())
};
foo
()
...
...
tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr
浏览文件 @
83756d97
...
...
@@ -59,61 +59,61 @@ LL | let _ = await bar();
| ^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`
error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:5
7
:13
--> $DIR/incorrect-syntax-suggestions.rs:5
6
:13
|
LL | let _ = await? bar();
| ^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await?`
error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:6
2
:13
--> $DIR/incorrect-syntax-suggestions.rs:6
0
:13
|
LL | let _ = await bar()?;
| ^^^^^^^^^^^^ help: `await` is a postfix operation: `bar()?.await`
error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:6
6
:14
--> $DIR/incorrect-syntax-suggestions.rs:6
4
:14
|
LL | let _ = (await bar())?;
| ^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`
error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:
71
:24
--> $DIR/incorrect-syntax-suggestions.rs:
68
:24
|
LL | let _ = bar().await();
| ^^ help: `await` is not a method call, remove the parentheses
error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:7
6
:24
--> $DIR/incorrect-syntax-suggestions.rs:7
3
:24
|
LL | let _ = bar().await()?;
| ^^ help: `await` is not a method call, remove the parentheses
error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:10
4
:13
--> $DIR/incorrect-syntax-suggestions.rs:10
1
:13
|
LL | let _ = await!(bar());
| ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`
error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:10
8
:13
--> $DIR/incorrect-syntax-suggestions.rs:10
5
:13
|
LL | let _ = await!(bar())?;
| ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`
error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:11
3
:17
--> $DIR/incorrect-syntax-suggestions.rs:11
0
:17
|
LL | let _ = await!(bar())?;
| ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`
error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:1
21
:17
--> $DIR/incorrect-syntax-suggestions.rs:1
17
:17
|
LL | let _ = await!(bar())?;
| ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`
error: expected expression, found `=>`
--> $DIR/incorrect-syntax-suggestions.rs:12
9
:25
--> $DIR/incorrect-syntax-suggestions.rs:12
4
:25
|
LL | match await { await => () }
| ----- ^^ expected expression
...
...
@@ -121,13 +121,13 @@ LL | match await { await => () }
| while parsing this incorrect await expression
error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:12
9
:11
--> $DIR/incorrect-syntax-suggestions.rs:12
4
:11
|
LL | match await { await => () }
| ^^^^^^^^^^^^^^^^^^^^^ help: `await` is a postfix operation: `{ await => () }.await`
error: expected one of `.`, `?`, `{`, or an operator, found `}`
--> $DIR/incorrect-syntax-suggestions.rs:1
32
:1
--> $DIR/incorrect-syntax-suggestions.rs:1
27
:1
|
LL | match await { await => () }
| ----- - expected one of `.`, `?`, `{`, or an operator
...
...
@@ -138,31 +138,7 @@ LL | }
| ^ unexpected token
error[E0728]: `await` is only allowed inside `async` functions and blocks
--> $DIR/incorrect-syntax-suggestions.rs:52:13
|
LL | fn foo9() -> Result<(), ()> {
| ---- this is not `async`
LL | let _ = await bar();
| ^^^^^ only allowed inside `async` functions and blocks
error[E0728]: `await` is only allowed inside `async` functions and blocks
--> $DIR/incorrect-syntax-suggestions.rs:57:13
|
LL | fn foo10() -> Result<(), ()> {
| ----- this is not `async`
LL | let _ = await? bar();
| ^^^^^ only allowed inside `async` functions and blocks
error[E0728]: `await` is only allowed inside `async` functions and blocks
--> $DIR/incorrect-syntax-suggestions.rs:66:14
|
LL | fn foo12() -> Result<(), ()> {
| ----- this is not `async`
LL | let _ = (await bar())?;
| ^^^^^ only allowed inside `async` functions and blocks
error[E0728]: `await` is only allowed inside `async` functions and blocks
--> $DIR/incorrect-syntax-suggestions.rs:71:19
--> $DIR/incorrect-syntax-suggestions.rs:68:19
|
LL | fn foo13() -> Result<(), ()> {
| ----- this is not `async`
...
...
@@ -170,7 +146,7 @@ LL | let _ = bar().await();
| ^^^^^ only allowed inside `async` functions and blocks
error[E0728]: `await` is only allowed inside `async` functions and blocks
--> $DIR/incorrect-syntax-suggestions.rs:7
6
:19
--> $DIR/incorrect-syntax-suggestions.rs:7
3
:19
|
LL | fn foo14() -> Result<(), ()> {
| ----- this is not `async`
...
...
@@ -178,7 +154,7 @@ LL | let _ = bar().await()?;
| ^^^^^ only allowed inside `async` functions and blocks
error[E0728]: `await` is only allowed inside `async` functions and blocks
--> $DIR/incorrect-syntax-suggestions.rs:
81
:19
--> $DIR/incorrect-syntax-suggestions.rs:
78
:19
|
LL | fn foo15() -> Result<(), ()> {
| ----- this is not `async`
...
...
@@ -186,7 +162,7 @@ LL | let _ = bar().await;
| ^^^^^ only allowed inside `async` functions and blocks
error[E0728]: `await` is only allowed inside `async` functions and blocks
--> $DIR/incorrect-syntax-suggestions.rs:8
5
:19
--> $DIR/incorrect-syntax-suggestions.rs:8
2
:19
|
LL | fn foo16() -> Result<(), ()> {
| ----- this is not `async`
...
...
@@ -194,7 +170,7 @@ LL | let _ = bar().await?;
| ^^^^^ only allowed inside `async` functions and blocks
error[E0728]: `await` is only allowed inside `async` functions and blocks
--> $DIR/incorrect-syntax-suggestions.rs:
90
:23
--> $DIR/incorrect-syntax-suggestions.rs:
87
:23
|
LL | fn foo() -> Result<(), ()> {
| --- this is not `async`
...
...
@@ -202,29 +178,13 @@ LL | let _ = bar().await?;
| ^^^^^ only allowed inside `async` functions and blocks
error[E0728]: `await` is only allowed inside `async` functions and blocks
--> $DIR/incorrect-syntax-suggestions.rs:9
7
:23
--> $DIR/incorrect-syntax-suggestions.rs:9
4
:23
|
LL | let foo = || {
| -- this is not `async`
LL | let _ = bar().await?;
| ^^^^^ only allowed inside `async` functions and blocks
error[E0728]: `await` is only allowed inside `async` functions and blocks
--> $DIR/incorrect-syntax-suggestions.rs:113:17
|
LL | fn foo() -> Result<(), ()> {
| --- this is not `async`
LL | let _ = await!(bar())?;
| ^^^^^ only allowed inside `async` functions and blocks
error[E0728]: `await` is only allowed inside `async` functions and blocks
--> $DIR/incorrect-syntax-suggestions.rs:121:17
|
LL | let foo = || {
| -- this is not `async`
LL | let _ = await!(bar())?;
| ^^^^^ only allowed inside `async` functions and blocks
error: aborting due to 33 previous errors
error: aborting due to 28 previous errors
For more information about this error, try `rustc --explain E0728`.
tests/ui/parser/issues/issue-113203.rs
0 → 100644
浏览文件 @
83756d97
// Checks what happens when we attempt to use the await keyword as a prefix. Span
// incorrectly emitted an `.await` in E0277 which does not exist
// edition:2018
fn
main
()
{
await
{}()
//~^ ERROR incorrect use of `await`
}
tests/ui/parser/issues/issue-113203.stderr
0 → 100644
浏览文件 @
83756d97
error: incorrect use of `await`
--> $DIR/issue-113203.rs:5:5
|
LL | await {}()
| ^^^^^^^^ help: `await` is a postfix operation: `{}.await`
error: aborting due to previous error
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录