Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
7c84ba11
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,发现更多精彩内容 >>
提交
7c84ba11
编写于
2月 26, 2020
作者:
M
Matthias Krüger
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use char instead of &str for single char patterns
上级
a8437cf2
变更
30
隐藏空白更改
内联
并排
Showing
30 changed file
with
44 addition
and
44 deletion
+44
-44
src/librustc_builtin_macros/asm.rs
src/librustc_builtin_macros/asm.rs
+4
-4
src/librustc_builtin_macros/format.rs
src/librustc_builtin_macros/format.rs
+1
-1
src/librustc_codegen_llvm/back/lto.rs
src/librustc_codegen_llvm/back/lto.rs
+1
-1
src/librustc_codegen_utils/link.rs
src/librustc_codegen_utils/link.rs
+1
-1
src/librustc_driver/args.rs
src/librustc_driver/args.rs
+1
-1
src/librustc_driver/lib.rs
src/librustc_driver/lib.rs
+1
-1
src/librustc_expand/proc_macro_server.rs
src/librustc_expand/proc_macro_server.rs
+2
-2
src/librustc_hir/hir.rs
src/librustc_hir/hir.rs
+1
-1
src/librustc_incremental/assert_module_sources.rs
src/librustc_incremental/assert_module_sources.rs
+1
-1
src/librustc_incremental/persist/fs.rs
src/librustc_incremental/persist/fs.rs
+3
-3
src/librustc_interface/util.rs
src/librustc_interface/util.rs
+1
-1
src/librustc_llvm/build.rs
src/librustc_llvm/build.rs
+1
-1
src/librustc_mir/borrow_check/diagnostics/region_errors.rs
src/librustc_mir/borrow_check/diagnostics/region_errors.rs
+1
-1
src/librustc_mir/borrow_check/mod.rs
src/librustc_mir/borrow_check/mod.rs
+1
-1
src/librustc_mir/transform/mod.rs
src/librustc_mir/transform/mod.rs
+1
-1
src/librustc_parse/parser/expr.rs
src/librustc_parse/parser/expr.rs
+1
-1
src/librustc_passes/dead.rs
src/librustc_passes/dead.rs
+1
-1
src/librustc_resolve/build_reduced_graph.rs
src/librustc_resolve/build_reduced_graph.rs
+1
-1
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+1
-1
src/librustc_target/abi/mod.rs
src/librustc_target/abi/mod.rs
+3
-3
src/librustc_typeck/astconv.rs
src/librustc_typeck/astconv.rs
+1
-1
src/librustc_typeck/check/demand.rs
src/librustc_typeck/check/demand.rs
+2
-2
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+1
-1
src/librustc_typeck/check/op.rs
src/librustc_typeck/check/op.rs
+3
-3
src/librustc_typeck/collect.rs
src/librustc_typeck/collect.rs
+2
-2
src/librustdoc/html/markdown.rs
src/librustdoc/html/markdown.rs
+1
-1
src/librustdoc/html/render.rs
src/librustdoc/html/render.rs
+1
-1
src/librustdoc/html/render/cache.rs
src/librustdoc/html/render/cache.rs
+2
-2
src/librustdoc/markdown.rs
src/librustdoc/markdown.rs
+1
-1
src/libstd/io/mod.rs
src/libstd/io/mod.rs
+2
-2
未找到文件。
src/librustc_builtin_macros/asm.rs
浏览文件 @
7c84ba11
...
...
@@ -182,7 +182,7 @@ fn parse_inline_asm<'a>(
};
let
is_rw
=
output
.is_some
();
let
is_indirect
=
constraint_str
.contains
(
"*"
);
let
is_indirect
=
constraint_str
.contains
(
'*'
);
outputs
.push
(
ast
::
InlineAsmOutput
{
constraint
:
output
.unwrap_or
(
constraint
),
expr
,
...
...
@@ -199,7 +199,7 @@ fn parse_inline_asm<'a>(
let
constraint
=
parse_asm_str
(
&
mut
p
)
?
;
if
constraint
.as_str
()
.starts_with
(
"="
)
{
if
constraint
.as_str
()
.starts_with
(
'='
)
{
struct_span_err!
(
cx
.parse_sess.span_diagnostic
,
p
.prev_span
,
...
...
@@ -207,7 +207,7 @@ fn parse_inline_asm<'a>(
"input operand constraint contains '='"
)
.emit
();
}
else
if
constraint
.as_str
()
.starts_with
(
"+"
)
{
}
else
if
constraint
.as_str
()
.starts_with
(
'+'
)
{
struct_span_err!
(
cx
.parse_sess.span_diagnostic
,
p
.prev_span
,
...
...
@@ -234,7 +234,7 @@ fn parse_inline_asm<'a>(
if
OPTIONS
.iter
()
.any
(|
&
opt
|
s
==
opt
)
{
cx
.span_warn
(
p
.prev_span
,
"expected a clobber, found an option"
);
}
else
if
s
.as_str
()
.starts_with
(
"{"
)
||
s
.as_str
()
.ends_with
(
"}"
)
{
}
else
if
s
.as_str
()
.starts_with
(
'{'
)
||
s
.as_str
()
.ends_with
(
'}'
)
{
struct_span_err!
(
cx
.parse_sess.span_diagnostic
,
p
.prev_span
,
...
...
src/librustc_builtin_macros/format.rs
浏览文件 @
7c84ba11
...
...
@@ -894,7 +894,7 @@ pub fn expand_preparsed_format_args(
};
let
(
is_literal
,
fmt_snippet
)
=
match
ecx
.source_map
()
.span_to_snippet
(
fmt_sp
)
{
Ok
(
s
)
=>
(
s
.starts_with
(
"
\"
"
)
||
s
.starts_with
(
"r#"
),
Some
(
s
)),
Ok
(
s
)
=>
(
s
.starts_with
(
'"'
)
||
s
.starts_with
(
"r#"
),
Some
(
s
)),
_
=>
(
false
,
None
),
};
...
...
src/librustc_codegen_llvm/back/lto.rs
浏览文件 @
7c84ba11
...
...
@@ -917,7 +917,7 @@ fn load_from_file(path: &Path) -> io::Result<ThinLTOImports> {
if
line
.is_empty
()
{
let
importing_module
=
current_module
.take
()
.expect
(
"Importing module not set"
);
imports
.insert
(
importing_module
,
mem
::
replace
(
&
mut
current_imports
,
vec!
[]));
}
else
if
line
.starts_with
(
" "
)
{
}
else
if
line
.starts_with
(
' '
)
{
// Space marks an imported module
assert_ne!
(
current_module
,
None
);
current_imports
.push
(
line
.trim
()
.to_string
());
...
...
src/librustc_codegen_utils/link.rs
浏览文件 @
7c84ba11
...
...
@@ -78,7 +78,7 @@ pub fn find_crate_name(sess: Option<&Session>, attrs: &[ast::Attribute], input:
}
if
let
Input
::
File
(
ref
path
)
=
*
input
{
if
let
Some
(
s
)
=
path
.file_stem
()
.and_then
(|
s
|
s
.to_str
())
{
if
s
.starts_with
(
"-"
)
{
if
s
.starts_with
(
'-'
)
{
let
msg
=
format!
(
"crate names cannot start with a `-`, but
\
`{}` has a leading hyphen"
,
...
...
src/librustc_driver/args.rs
浏览文件 @
7c84ba11
...
...
@@ -4,7 +4,7 @@
use
std
::
io
;
pub
fn
arg_expand
(
arg
:
String
)
->
Result
<
Vec
<
String
>
,
Error
>
{
if
arg
.starts_with
(
"@"
)
{
if
arg
.starts_with
(
'@'
)
{
let
path
=
&
arg
[
1
..
];
let
file
=
match
fs
::
read_to_string
(
path
)
{
Ok
(
file
)
=>
file
,
...
...
src/librustc_driver/lib.rs
浏览文件 @
7c84ba11
...
...
@@ -521,7 +521,7 @@ fn stdout_isatty() -> bool {
fn
handle_explain
(
registry
:
Registry
,
code
:
&
str
,
output
:
ErrorOutputType
)
{
let
normalised
=
if
code
.starts_with
(
"E"
)
{
code
.to_string
()
}
else
{
format!
(
"E{0:0>4}"
,
code
)
};
if
code
.starts_with
(
'E'
)
{
code
.to_string
()
}
else
{
format!
(
"E{0:0>4}"
,
code
)
};
match
registry
.find_description
(
&
normalised
)
{
Some
(
ref
description
)
=>
{
let
mut
is_in_code_block
=
false
;
...
...
src/librustc_expand/proc_macro_server.rs
浏览文件 @
7c84ba11
...
...
@@ -209,7 +209,7 @@ fn to_internal(self) -> TokenStream {
TokenTree
::
Literal
(
self
::
Literal
{
lit
:
token
::
Lit
{
kind
:
token
::
Integer
,
symbol
,
suffix
},
span
,
})
if
symbol
.as_str
()
.starts_with
(
"-"
)
=>
{
})
if
symbol
.as_str
()
.starts_with
(
'-'
)
=>
{
let
minus
=
BinOp
(
BinOpToken
::
Minus
);
let
symbol
=
Symbol
::
intern
(
&
symbol
.as_str
()[
1
..
]);
let
integer
=
TokenKind
::
lit
(
token
::
Integer
,
symbol
,
suffix
);
...
...
@@ -220,7 +220,7 @@ fn to_internal(self) -> TokenStream {
TokenTree
::
Literal
(
self
::
Literal
{
lit
:
token
::
Lit
{
kind
:
token
::
Float
,
symbol
,
suffix
},
span
,
})
if
symbol
.as_str
()
.starts_with
(
"-"
)
=>
{
})
if
symbol
.as_str
()
.starts_with
(
'-'
)
=>
{
let
minus
=
BinOp
(
BinOpToken
::
Minus
);
let
symbol
=
Symbol
::
intern
(
&
symbol
.as_str
()[
1
..
]);
let
float
=
TokenKind
::
lit
(
token
::
Float
,
symbol
,
suffix
);
...
...
src/librustc_hir/hir.rs
浏览文件 @
7c84ba11
...
...
@@ -1496,7 +1496,7 @@ fn is_lit(sm: &SourceMap, span: &Span) -> bool {
let
end_point
=
sm
.end_point
(
*
span
);
if
let
Ok
(
end_string
)
=
sm
.span_to_snippet
(
end_point
)
{
!
(
end_string
.ends_with
(
"}"
)
||
end_string
.ends_with
(
")"
))
!
(
end_string
.ends_with
(
'}'
)
||
end_string
.ends_with
(
')'
))
}
else
{
false
}
...
...
src/librustc_incremental/assert_module_sources.rs
浏览文件 @
7c84ba11
...
...
@@ -107,7 +107,7 @@ fn check_attr(&self, attr: &ast::Attribute) {
}
// Split of the "special suffix" if there is one.
let
(
user_path
,
cgu_special_suffix
)
=
if
let
Some
(
index
)
=
user_path
.rfind
(
"."
)
{
let
(
user_path
,
cgu_special_suffix
)
=
if
let
Some
(
index
)
=
user_path
.rfind
(
'.'
)
{
(
&
user_path
[
..
index
],
Some
(
&
user_path
[
index
+
1
..
]))
}
else
{
(
&
user_path
[
..
],
None
)
...
...
src/librustc_incremental/persist/fs.rs
浏览文件 @
7c84ba11
...
...
@@ -152,7 +152,7 @@ pub fn lock_file_path(session_dir: &Path) -> PathBuf {
let
directory_name
=
session_dir
.file_name
()
.unwrap
()
.to_string_lossy
();
assert_no_characters_lost
(
&
directory_name
);
let
dash_indices
:
Vec
<
_
>
=
directory_name
.match_indices
(
"-"
)
.map
(|(
idx
,
_
)|
idx
)
.collect
();
let
dash_indices
:
Vec
<
_
>
=
directory_name
.match_indices
(
'-'
)
.map
(|(
idx
,
_
)|
idx
)
.collect
();
if
dash_indices
.len
()
!=
3
{
bug!
(
"Encountered incremental compilation session directory with
\
...
...
@@ -342,7 +342,7 @@ pub fn finalize_session_directory(sess: &Session, svh: Svh) {
// Keep the 's-{timestamp}-{random-number}' prefix, but replace the
// '-working' part with the SVH of the crate
let
dash_indices
:
Vec
<
_
>
=
old_sub_dir_name
.match_indices
(
"-"
)
.map
(|(
idx
,
_
)|
idx
)
.collect
();
let
dash_indices
:
Vec
<
_
>
=
old_sub_dir_name
.match_indices
(
'-'
)
.map
(|(
idx
,
_
)|
idx
)
.collect
();
if
dash_indices
.len
()
!=
3
{
bug!
(
"Encountered incremental compilation session directory with
\
...
...
@@ -594,7 +594,7 @@ fn extract_timestamp_from_session_dir(directory_name: &str) -> Result<SystemTime
return
Err
(());
}
let
dash_indices
:
Vec
<
_
>
=
directory_name
.match_indices
(
"-"
)
.map
(|(
idx
,
_
)|
idx
)
.collect
();
let
dash_indices
:
Vec
<
_
>
=
directory_name
.match_indices
(
'-'
)
.map
(|(
idx
,
_
)|
idx
)
.collect
();
if
dash_indices
.len
()
!=
3
{
return
Err
(());
}
...
...
src/librustc_interface/util.rs
浏览文件 @
7c84ba11
...
...
@@ -244,7 +244,7 @@ pub fn get_codegen_backend(sess: &Session) -> Box<dyn CodegenBackend> {
.as_ref
()
.unwrap_or
(
&
sess
.target.target.options.codegen_backend
);
let
backend
=
match
&
codegen_name
[
..
]
{
filename
if
filename
.contains
(
"."
)
=>
load_backend_from_dylib
(
filename
.as_ref
()),
filename
if
filename
.contains
(
'.'
)
=>
load_backend_from_dylib
(
filename
.as_ref
()),
codegen_name
=>
get_builtin_codegen_backend
(
codegen_name
),
};
...
...
src/librustc_llvm/build.rs
浏览文件 @
7c84ba11
...
...
@@ -178,7 +178,7 @@ fn main() {
for
lib
in
output
(
&
mut
cmd
)
.split_whitespace
()
{
let
name
=
if
lib
.starts_with
(
"-l"
)
{
&
lib
[
2
..
]
}
else
if
lib
.starts_with
(
"-"
)
{
}
else
if
lib
.starts_with
(
'-'
)
{
&
lib
[
1
..
]
}
else
if
Path
::
new
(
lib
)
.exists
()
{
// On MSVC llvm-config will print the full name to libraries, but
...
...
src/librustc_mir/borrow_check/diagnostics/region_errors.rs
浏览文件 @
7c84ba11
...
...
@@ -612,7 +612,7 @@ fn add_static_impl_trait_suggestion(
}
else
{
"'_"
.to_string
()
};
let
suggestion
=
if
snippet
.ends_with
(
";"
)
{
let
suggestion
=
if
snippet
.ends_with
(
';'
)
{
// `type X = impl Trait;`
format!
(
"{} + {};"
,
&
snippet
[
..
snippet
.len
()
-
1
],
suggestable_fr_name
)
}
else
{
...
...
src/librustc_mir/borrow_check/mod.rs
浏览文件 @
7c84ba11
...
...
@@ -365,7 +365,7 @@ fn do_mir_borrowck<'a, 'tcx>(
// Skip over locals that begin with an underscore or have no name
match
mbcx
.local_names
[
local
]
{
Some
(
name
)
=>
{
if
name
.as_str
()
.starts_with
(
"_"
)
{
if
name
.as_str
()
.starts_with
(
'_'
)
{
continue
;
}
}
...
...
src/librustc_mir/transform/mod.rs
浏览文件 @
7c84ba11
...
...
@@ -122,7 +122,7 @@ pub fn def_id(&self) -> DefId {
/// type `T`.
pub
fn
default_name
<
T
:
?
Sized
>
()
->
Cow
<
'static
,
str
>
{
let
name
=
::
std
::
any
::
type_name
::
<
T
>
();
if
let
Some
(
tail
)
=
name
.rfind
(
":"
)
{
Cow
::
from
(
&
name
[
tail
+
1
..
])
}
else
{
Cow
::
from
(
name
)
}
if
let
Some
(
tail
)
=
name
.rfind
(
':'
)
{
Cow
::
from
(
&
name
[
tail
+
1
..
])
}
else
{
Cow
::
from
(
name
)
}
}
/// A streamlined trait that you can implement to create a pass; the
...
...
src/librustc_parse/parser/expr.rs
浏览文件 @
7c84ba11
...
...
@@ -758,7 +758,7 @@ fn recover_field_access_by_float_lit(
s
.print_usize
(
float
.trunc
()
as
usize
);
s
.pclose
();
s
.s
.word
(
"."
);
s
.s
.word
(
fstr
.splitn
(
2
,
"."
)
.last
()
.unwrap
()
.to_string
())
s
.s
.word
(
fstr
.splitn
(
2
,
'.'
)
.last
()
.unwrap
()
.to_string
())
});
err
.span_suggestion
(
lo
.to
(
self
.prev_span
),
...
...
src/librustc_passes/dead.rs
浏览文件 @
7c84ba11
...
...
@@ -553,7 +553,7 @@ fn warn_dead_code(
node_type
:
&
str
,
participle
:
&
str
,
)
{
if
!
name
.as_str
()
.starts_with
(
"_"
)
{
if
!
name
.as_str
()
.starts_with
(
'_'
)
{
self
.tcx
.struct_span_lint_hir
(
lint
::
builtin
::
DEAD_CODE
,
id
,
span
,
|
lint
|
{
lint
.build
(
&
format!
(
"{} is never {}: `{}`"
,
node_type
,
participle
,
name
))
.emit
()
});
...
...
src/librustc_resolve/build_reduced_graph.rs
浏览文件 @
7c84ba11
...
...
@@ -1103,7 +1103,7 @@ fn proc_macro_stub(item: &ast::Item) -> Option<(MacroKind, Ident, Span)> {
// Macro uses will remove items from this set, and the remaining
// items will be reported as `unused_macros`.
fn
insert_unused_macro
(
&
mut
self
,
ident
:
Ident
,
node_id
:
NodeId
,
span
:
Span
)
{
if
!
ident
.as_str
()
.starts_with
(
"_"
)
{
if
!
ident
.as_str
()
.starts_with
(
'_'
)
{
self
.r.unused_macros
.insert
(
node_id
,
span
);
}
}
...
...
src/librustc_resolve/lib.rs
浏览文件 @
7c84ba11
...
...
@@ -2663,7 +2663,7 @@ fn add_suggestion_for_rename_of_use(
"{} as {}{}"
,
&
snippet
[
..
pos
],
suggested_name
,
if
snippet
.ends_with
(
";"
)
{
";"
}
else
{
""
}
if
snippet
.ends_with
(
';'
)
{
";"
}
else
{
""
}
))
}
}
...
...
src/librustc_target/abi/mod.rs
浏览文件 @
7c84ba11
...
...
@@ -101,7 +101,7 @@ pub fn parse(target: &Target) -> Result<TargetDataLayout, String> {
match
&*
spec_parts
{
[
"e"
]
=>
dl
.endian
=
Endian
::
Little
,
[
"E"
]
=>
dl
.endian
=
Endian
::
Big
,
[
p
]
if
p
.starts_with
(
"P"
)
=>
{
[
p
]
if
p
.starts_with
(
'P'
)
=>
{
dl
.instruction_address_space
=
parse_address_space
(
&
p
[
1
..
],
"P"
)
?
}
[
"a"
,
ref
a
@
..
]
=>
dl
.aggregate_align
=
align
(
a
,
"a"
)
?
,
...
...
@@ -111,7 +111,7 @@ pub fn parse(target: &Target) -> Result<TargetDataLayout, String> {
dl
.pointer_size
=
size
(
s
,
p
)
?
;
dl
.pointer_align
=
align
(
a
,
p
)
?
;
}
[
s
,
ref
a
@
..
]
if
s
.starts_with
(
"i"
)
=>
{
[
s
,
ref
a
@
..
]
if
s
.starts_with
(
'i'
)
=>
{
let
bits
=
match
s
[
1
..
]
.parse
::
<
u64
>
()
{
Ok
(
bits
)
=>
bits
,
Err
(
_
)
=>
{
...
...
@@ -135,7 +135,7 @@ pub fn parse(target: &Target) -> Result<TargetDataLayout, String> {
dl
.i128_align
=
a
;
}
}
[
s
,
ref
a
@
..
]
if
s
.starts_with
(
"v"
)
=>
{
[
s
,
ref
a
@
..
]
if
s
.starts_with
(
'v'
)
=>
{
let
v_size
=
size
(
&
s
[
1
..
],
"v"
)
?
;
let
a
=
align
(
a
,
s
)
?
;
if
let
Some
(
v
)
=
dl
.vector_align
.iter_mut
()
.find
(|
v
|
v
.0
==
v_size
)
{
...
...
src/librustc_typeck/astconv.rs
浏览文件 @
7c84ba11
...
...
@@ -1777,7 +1777,7 @@ fn complain_about_missing_associated_types(
{
let
types
:
Vec
<
_
>
=
assoc_items
.iter
()
.map
(|
item
|
format!
(
"{} = Type"
,
item
.ident
))
.collect
();
let
code
=
if
snippet
.ends_with
(
">"
)
{
let
code
=
if
snippet
.ends_with
(
'>'
)
{
// The user wrote `Trait<'a>` or similar and we don't have a type we can
// suggest, but at least we can clue them to the correct syntax
// `Trait<'a, Item = Type>` while accounting for the `<'a>` in the
...
...
src/librustc_typeck/check/demand.rs
浏览文件 @
7c84ba11
...
...
@@ -404,7 +404,7 @@ pub fn check_ref(
{
if
let
hir
::
ExprKind
::
Lit
(
_
)
=
expr
.kind
{
if
let
Ok
(
src
)
=
sm
.span_to_snippet
(
sp
)
{
if
src
.starts_with
(
"
\"
"
)
{
if
src
.starts_with
(
'"'
)
{
return
Some
((
sp
,
"consider adding a leading `b`"
,
...
...
@@ -701,7 +701,7 @@ pub fn check_for_cast(
{
// Remove fractional part from literal, for example `42.0f32` into `42`
let
src
=
src
.trim_end_matches
(
&
checked_ty
.to_string
());
src
.split
(
"."
)
.next
()
.unwrap
()
src
.split
(
'.'
)
.next
()
.unwrap
()
}
else
{
src
.trim_end_matches
(
&
checked_ty
.to_string
())
},
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
7c84ba11
...
...
@@ -4996,7 +4996,7 @@ pub fn suggest_ref_or_into(
let
sugg
=
if
receiver
.ends_with
(
".clone()"
)
&&
method_call_list
.contains
(
&
method_call
.as_str
())
{
let
max_len
=
receiver
.rfind
(
"."
)
.unwrap
();
let
max_len
=
receiver
.rfind
(
'.'
)
.unwrap
();
format!
(
"{}{}"
,
&
receiver
[
..
max_len
],
method_call
)
}
else
{
if
expr
.precedence
()
.order
()
<
ExprPrecedence
::
MethodCall
.order
()
{
...
...
src/librustc_typeck/check/op.rs
浏览文件 @
7c84ba11
...
...
@@ -597,12 +597,12 @@ fn check_str_addition(
Ok
(
lstring
)
=>
{
err
.span_suggestion
(
lhs_expr
.span
,
if
lstring
.starts_with
(
"&"
)
{
if
lstring
.starts_with
(
'&'
)
{
remove_borrow_msg
}
else
{
msg
},
if
lstring
.starts_with
(
"&"
)
{
if
lstring
.starts_with
(
'&'
)
{
// let a = String::new();
// let _ = &a + "bar";
format!
(
"{}"
,
&
lstring
[
1
..
])
...
...
@@ -630,7 +630,7 @@ fn check_str_addition(
is_assign
,
)
{
(
Ok
(
l
),
Ok
(
r
),
false
)
=>
{
let
to_string
=
if
l
.starts_with
(
"&"
)
{
let
to_string
=
if
l
.starts_with
(
'&'
)
{
// let a = String::new(); let b = String::new();
// let _ = &a + b;
format!
(
"{}"
,
&
l
[
1
..
])
...
...
src/librustc_typeck/collect.rs
浏览文件 @
7c84ba11
...
...
@@ -2206,7 +2206,7 @@ fn from_target_feature(
item
.span
(),
format!
(
"`{}` is not valid for this target"
,
feature
),
);
if
feature
.starts_with
(
"+"
)
{
if
feature
.starts_with
(
'+'
)
{
let
valid
=
whitelist
.contains_key
(
&
feature
[
1
..
]);
if
valid
{
err
.help
(
"consider removing the leading `+` in the feature name"
);
...
...
@@ -2337,7 +2337,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
codegen_fn_attrs
.flags
|
=
CodegenFnAttrFlags
::
TRACK_CALLER
;
}
else
if
attr
.check_name
(
sym
::
export_name
)
{
if
let
Some
(
s
)
=
attr
.value_str
()
{
if
s
.as_str
()
.contains
(
"
\0
"
)
{
if
s
.as_str
()
.contains
(
'\0'
)
{
// `#[export_name = ...]` will be converted to a null-terminated string,
// so it may not contain any null characters.
struct_span_err!
(
...
...
src/librustdoc/html/markdown.rs
浏览文件 @
7c84ba11
...
...
@@ -707,7 +707,7 @@ fn parse(
x
if
x
.starts_with
(
"edition"
)
=>
{
data
.edition
=
x
[
7
..
]
.parse
::
<
Edition
>
()
.ok
();
}
x
if
allow_error_code_check
&&
x
.starts_with
(
"E"
)
&&
x
.len
()
==
5
=>
{
x
if
allow_error_code_check
&&
x
.starts_with
(
'E'
)
&&
x
.len
()
==
5
=>
{
if
x
[
1
..
]
.parse
::
<
u32
>
()
.is_ok
()
{
data
.error_codes
.push
(
x
.to_owned
());
seen_rust_tags
=
!
seen_other_tags
||
seen_rust_tags
;
...
...
src/librustdoc/html/render.rs
浏览文件 @
7c84ba11
...
...
@@ -86,7 +86,7 @@
crate
fn
ensure_trailing_slash
(
v
:
&
str
)
->
impl
fmt
::
Display
+
'_
{
crate
::
html
::
format
::
display_fn
(
move
|
f
|
{
if
!
v
.ends_with
(
"/"
)
&&
!
v
.is_empty
()
{
write!
(
f
,
"{}/"
,
v
)
}
else
{
write!
(
f
,
"{}"
,
v
)
}
if
!
v
.ends_with
(
'/'
)
&&
!
v
.is_empty
()
{
write!
(
f
,
"{}/"
,
v
)
}
else
{
write!
(
f
,
"{}"
,
v
)
}
})
}
...
...
src/librustdoc/html/render/cache.rs
浏览文件 @
7c84ba11
...
...
@@ -534,7 +534,7 @@ fn extern_location(
if
let
Some
(
url
)
=
extern_url
{
let
mut
url
=
url
.to_string
();
if
!
url
.ends_with
(
"/"
)
{
if
!
url
.ends_with
(
'/'
)
{
url
.push
(
'/'
);
}
return
Remote
(
url
);
...
...
@@ -548,7 +548,7 @@ fn extern_location(
.filter_map
(|
a
|
a
.value_str
())
.map
(|
url
|
{
let
mut
url
=
url
.to_string
();
if
!
url
.ends_with
(
"/"
)
{
if
!
url
.ends_with
(
'/'
)
{
url
.push
(
'/'
)
}
Remote
(
url
)
...
...
src/librustdoc/markdown.rs
浏览文件 @
7c84ba11
...
...
@@ -19,7 +19,7 @@ fn extract_leading_metadata(s: &str) -> (Vec<&str>, &str) {
let
mut
count
=
0
;
for
line
in
s
.lines
()
{
if
line
.starts_with
(
"# "
)
||
line
.starts_with
(
"%"
)
{
if
line
.starts_with
(
"# "
)
||
line
.starts_with
(
'%'
)
{
// trim the whitespace after the symbol
metadata
.push
(
line
[
1
..
]
.trim_start
());
count
+=
line
.len
()
+
1
;
...
...
src/libstd/io/mod.rs
浏览文件 @
7c84ba11
...
...
@@ -2396,9 +2396,9 @@ fn next(&mut self) -> Option<Result<String>> {
match
self
.buf
.read_line
(
&
mut
buf
)
{
Ok
(
0
)
=>
None
,
Ok
(
_
n
)
=>
{
if
buf
.ends_with
(
"
\n
"
)
{
if
buf
.ends_with
(
'\n'
)
{
buf
.pop
();
if
buf
.ends_with
(
"
\r
"
)
{
if
buf
.ends_with
(
'\r'
)
{
buf
.pop
();
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录