Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
630d5f35
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,发现更多精彩内容 >>
提交
630d5f35
编写于
6月 10, 2019
作者:
I
Igor Matuszewski
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Don't suggest using \r in raw strings
上级
63dc7da7
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
11 addition
and
5 deletion
+11
-5
src/libsyntax/parse/unescape.rs
src/libsyntax/parse/unescape.rs
+2
-1
src/libsyntax/parse/unescape_error_reporting.rs
src/libsyntax/parse/unescape_error_reporting.rs
+5
-0
src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.rs
src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.rs
+1
-1
src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr
...t/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr
+1
-1
src/test/ui/parser/raw-byte-string-literals.rs
src/test/ui/parser/raw-byte-string-literals.rs
+1
-1
src/test/ui/parser/raw-byte-string-literals.stderr
src/test/ui/parser/raw-byte-string-literals.stderr
+1
-1
未找到文件。
src/libsyntax/parse/unescape.rs
浏览文件 @
630d5f35
...
...
@@ -12,6 +12,7 @@ pub(crate) enum EscapeError {
LoneSlash
,
InvalidEscape
,
BareCarriageReturn
,
BareCarriageReturnInRawString
,
EscapeOnlyChar
,
TooShortHexEscape
,
...
...
@@ -299,7 +300,7 @@ fn unescape_raw_str_or_byte_str<F>(literal_text: &str, mode: Mode, callback: &mu
chars
.next
();
Ok
(
'\n'
)
},
(
'\r'
,
_
)
=>
Err
(
EscapeError
::
BareCarriageReturn
),
(
'\r'
,
_
)
=>
Err
(
EscapeError
::
BareCarriageReturn
InRawString
),
(
c
,
_
)
if
mode
.is_bytes
()
&&
!
c
.is_ascii
()
=>
Err
(
EscapeError
::
NonAsciiCharInByteString
),
(
c
,
_
)
=>
Ok
(
c
),
...
...
src/libsyntax/parse/unescape_error_reporting.rs
浏览文件 @
630d5f35
...
...
@@ -80,6 +80,11 @@ pub(crate) fn emit_unescape_error(
};
handler
.span_err
(
span
,
msg
);
}
EscapeError
::
BareCarriageReturnInRawString
=>
{
assert
!
(
mode
.in_double_quotes
());
let
msg
=
"bare CR not allowed in raw string"
;
handler
.span_err
(
span
,
msg
);
}
EscapeError
::
InvalidEscape
=>
{
let
(
c
,
span
)
=
last_char
();
...
...
src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.rs
浏览文件 @
630d5f35
...
...
@@ -21,7 +21,7 @@ fn main() {
let
_
s
=
"foo bar"
;
//~ ERROR: bare CR not allowed in string
// the following string literal has a bare CR in it
let
_
s
=
r"bar foo"
;
//~ ERROR: bare CR not allowed in string
let
_
s
=
r"bar foo"
;
//~ ERROR: bare CR not allowed in
raw
string
// the following string literal has a bare CR in it
let
_
s
=
"foo
\
bar"
;
//~ ERROR: unknown character escape: \r
...
...
src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr
浏览文件 @
630d5f35
...
...
@@ -28,7 +28,7 @@ error: bare CR not allowed in string, use \r instead
LL | let _s = "foo bar";
| ^
error: bare CR not allowed in
string, use \r instead
error: bare CR not allowed in
raw string
--> $DIR/lex-bare-cr-string-literal-doc-comment.rs:24:19
|
LL | let _s = r"bar foo";
...
...
src/test/ui/parser/raw-byte-string-literals.rs
浏览文件 @
630d5f35
// ignore-tidy-cr
// compile-flags: -Z continue-parse-after-error
pub
fn
main
()
{
br
"a "
;
//~ ERROR bare CR not allowed in string
br
"a "
;
//~ ERROR bare CR not allowed in
raw
string
br
"é"
;
//~ ERROR raw byte string must be ASCII
br
##
~
"a"
~
##
;
//~ ERROR only `#` is allowed in raw string delimitation
}
...
...
src/test/ui/parser/raw-byte-string-literals.stderr
浏览文件 @
630d5f35
error: bare CR not allowed in
string, use \r instead
error: bare CR not allowed in
raw string
--> $DIR/raw-byte-string-literals.rs:4:9
|
LL | br"a ";
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录