Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
1bb3694b
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,发现更多精彩内容 >>
提交
1bb3694b
编写于
3月 26, 2019
作者:
E
Esteban Küber
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reword invalid suffixe errors
上级
c7ddb839
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
36 addition
and
37 deletion
+36
-37
src/libsyntax/parse/parser.rs
src/libsyntax/parse/parser.rs
+6
-7
src/test/ui/parser/bad-lit-suffixes.rs
src/test/ui/parser/bad-lit-suffixes.rs
+8
-8
src/test/ui/parser/bad-lit-suffixes.stderr
src/test/ui/parser/bad-lit-suffixes.stderr
+16
-16
src/test/ui/parser/issue-59418.rs
src/test/ui/parser/issue-59418.rs
+2
-2
src/test/ui/parser/issue-59418.stderr
src/test/ui/parser/issue-59418.stderr
+4
-4
未找到文件。
src/libsyntax/parse/parser.rs
浏览文件 @
1bb3694b
...
...
@@ -1119,9 +1119,8 @@ fn expect_no_suffix(&self, sp: Span, kind: &str, suffix: Option<ast::Name>) {
if
text
.is_empty
()
{
self
.span_bug
(
sp
,
"found empty literal suffix in Some"
)
}
let
msg
=
format!
(
"{} with a suffix is invalid"
,
kind
);
self
.struct_span_err
(
sp
,
&
msg
)
.span_label
(
sp
,
msg
)
self
.struct_span_err
(
sp
,
&
format!
(
"suffixes on {} are invalid"
,
kind
))
.span_label
(
sp
,
format!
(
"invalid suffix `{}`"
,
text
))
.emit
();
}
}
...
...
@@ -2150,7 +2149,7 @@ fn parse_lit_token(&mut self) -> PResult<'a, LitKind> {
if
suffix_illegal
{
let
sp
=
self
.span
;
self
.expect_no_suffix
(
sp
,
lit
.literal_name
(
),
suf
)
self
.expect_no_suffix
(
sp
,
&
format!
(
"a {}"
,
lit
.literal_name
()
),
suf
)
}
result
.unwrap
()
...
...
@@ -3205,7 +3204,7 @@ fn parse_dot_or_call_expr_with_(&mut self, e0: P<Expr>, lo: Span) -> PResult<'a,
let
field
=
ExprKind
::
Field
(
e
,
Ident
::
new
(
name
,
span
));
e
=
self
.mk_expr
(
lo
.to
(
span
),
field
,
ThinVec
::
new
());
self
.expect_no_suffix
(
span
,
"tuple index"
,
suffix
);
self
.expect_no_suffix
(
span
,
"
a
tuple index"
,
suffix
);
}
token
::
Literal
(
token
::
Float
(
n
),
_
suf
)
=>
{
self
.bump
();
...
...
@@ -7791,7 +7790,7 @@ fn parse_opt_abi(&mut self) -> PResult<'a, Option<Abi>> {
match
self
.token
{
token
::
Literal
(
token
::
Str_
(
s
),
suf
)
|
token
::
Literal
(
token
::
StrRaw
(
s
,
_
),
suf
)
=>
{
let
sp
=
self
.span
;
self
.expect_no_suffix
(
sp
,
"ABI spec"
,
suf
);
self
.expect_no_suffix
(
sp
,
"
an
ABI spec"
,
suf
);
self
.bump
();
match
abi
::
lookup
(
&
s
.as_str
())
{
Some
(
abi
)
=>
Ok
(
Some
(
abi
)),
...
...
@@ -8612,7 +8611,7 @@ pub fn parse_str(&mut self) -> PResult<'a, (Symbol, StrStyle)> {
match
self
.parse_optional_str
()
{
Some
((
s
,
style
,
suf
))
=>
{
let
sp
=
self
.prev_span
;
self
.expect_no_suffix
(
sp
,
"string literal"
,
suf
);
self
.expect_no_suffix
(
sp
,
"
a
string literal"
,
suf
);
Ok
((
s
,
style
))
}
_
=>
{
...
...
src/test/ui/parser/bad-lit-suffixes.rs
浏览文件 @
1bb3694b
...
...
@@ -2,20 +2,20 @@
extern
"C"
suffix
//~ ERROR
ABI spec with a suffix is
invalid
"C"
suffix
//~ ERROR
suffixes on an ABI spec are
invalid
fn
foo
()
{}
extern
"C"
suffix
//~ ERROR
ABI spec with a suffix is
invalid
"C"
suffix
//~ ERROR
suffixes on an ABI spec are
invalid
{}
fn
main
()
{
""
suffix
;
//~ ERROR s
tring literal with a suffix is
invalid
b
""
suffix
;
//~ ERROR
byte string literal with a suffix is
invalid
r#""#
suffix
;
//~ ERROR s
tring literal with a suffix is
invalid
br
#
""
#
suffix
;
//~ ERROR
byte string literal with a suffix is
invalid
'a'
suffix
;
//~ ERROR
char literal with a suffix is
invalid
b
'a'
suffix
;
//~ ERROR
byte literal with a suffix is
invalid
""
suffix
;
//~ ERROR s
uffixes on a string literal are
invalid
b
""
suffix
;
//~ ERROR
suffixes on a byte string literal are
invalid
r#""#
suffix
;
//~ ERROR s
uffixes on a string literal are
invalid
br
#
""
#
suffix
;
//~ ERROR
suffixes on a byte string literal are
invalid
'a'
suffix
;
//~ ERROR
suffixes on a char literal are
invalid
b
'a'
suffix
;
//~ ERROR
suffixes on a byte literal are
invalid
1234u1024
;
//~ ERROR invalid width `1024` for integer literal
1234
i1024
;
//~ ERROR invalid width `1024` for integer literal
...
...
src/test/ui/parser/bad-lit-suffixes.stderr
浏览文件 @
1bb3694b
error:
ABI spec with a suffix is
invalid
error:
suffixes on an ABI spec are
invalid
--> $DIR/bad-lit-suffixes.rs:5:5
|
LL | "C"suffix
| ^^^^^^^^^
ABI spec with a suffix is invalid
| ^^^^^^^^^
invalid suffix `suffix`
error:
ABI spec with a suffix is
invalid
error:
suffixes on an ABI spec are
invalid
--> $DIR/bad-lit-suffixes.rs:9:5
|
LL | "C"suffix
| ^^^^^^^^^
ABI spec with a suffix is invalid
| ^^^^^^^^^
invalid suffix `suffix`
error: s
tring literal with a suffix is
invalid
error: s
uffixes on a string literal are
invalid
--> $DIR/bad-lit-suffixes.rs:13:5
|
LL | ""suffix;
| ^^^^^^^^
string literal with a suffix is invalid
| ^^^^^^^^
invalid suffix `suffix`
error:
byte string literal with a suffix is
invalid
error:
suffixes on a byte string literal are
invalid
--> $DIR/bad-lit-suffixes.rs:14:5
|
LL | b""suffix;
| ^^^^^^^^^
byte string literal with a suffix is invalid
| ^^^^^^^^^
invalid suffix `suffix`
error: s
tring literal with a suffix is
invalid
error: s
uffixes on a string literal are
invalid
--> $DIR/bad-lit-suffixes.rs:15:5
|
LL | r#""#suffix;
| ^^^^^^^^^^^
string literal with a suffix is invalid
| ^^^^^^^^^^^
invalid suffix `suffix`
error:
byte string literal with a suffix is
invalid
error:
suffixes on a byte string literal are
invalid
--> $DIR/bad-lit-suffixes.rs:16:5
|
LL | br#""#suffix;
| ^^^^^^^^^^^^
byte string literal with a suffix is invalid
| ^^^^^^^^^^^^
invalid suffix `suffix`
error:
char literal with a suffix is
invalid
error:
suffixes on a char literal are
invalid
--> $DIR/bad-lit-suffixes.rs:17:5
|
LL | 'a'suffix;
| ^^^^^^^^^
char literal with a suffix is invalid
| ^^^^^^^^^
invalid suffix `suffix`
error:
byte literal with a suffix is
invalid
error:
suffixes on a byte literal are
invalid
--> $DIR/bad-lit-suffixes.rs:18:5
|
LL | b'a'suffix;
| ^^^^^^^^^^
byte literal with a suffix is invalid
| ^^^^^^^^^^
invalid suffix `suffix`
error: invalid width `1024` for integer literal
--> $DIR/bad-lit-suffixes.rs:20:5
...
...
src/test/ui/parser/issue-59418.rs
浏览文件 @
1bb3694b
...
...
@@ -3,10 +3,10 @@
fn
main
()
{
let
a
=
X
(
1
,
2
,
3
);
let
b
=
a
.1
suffix
;
//~^ ERROR
tuple index with a suffix is
invalid
//~^ ERROR
suffixes on a tuple index are
invalid
println!
(
"{}"
,
b
);
let
c
=
(
1
,
2
,
3
);
let
d
=
c
.1
suffix
;
//~^ ERROR
tuple index with a suffix is
invalid
//~^ ERROR
suffixes on a tuple index are
invalid
println!
(
"{}"
,
d
);
}
src/test/ui/parser/issue-59418.stderr
浏览文件 @
1bb3694b
error:
tuple index with a suffix is
invalid
error:
suffixes on a tuple index are
invalid
--> $DIR/issue-59418.rs:5:15
|
LL | let b = a.1suffix;
| ^^^^^^^
tuple index with a suffix is invalid
| ^^^^^^^
invalid suffix `suffix`
error:
tuple index with a suffix is
invalid
error:
suffixes on a tuple index are
invalid
--> $DIR/issue-59418.rs:9:15
|
LL | let d = c.1suffix;
| ^^^^^^^
tuple index with a suffix is invalid
| ^^^^^^^
invalid suffix `suffix`
error: aborting due to 2 previous errors
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录