Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
9ff0f337
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,发现更多精彩内容 >>
提交
9ff0f337
编写于
10月 15, 2018
作者:
L
ljedrz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Pass suggestions as impl Iterator instead of Vec
上级
0db7abe5
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
10 addition
and
10 deletion
+10
-10
src/librustc_errors/diagnostic.rs
src/librustc_errors/diagnostic.rs
+3
-3
src/librustc_errors/diagnostic_builder.rs
src/librustc_errors/diagnostic_builder.rs
+1
-1
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+1
-1
src/librustc_typeck/check/demand.rs
src/librustc_typeck/check/demand.rs
+1
-1
src/librustc_typeck/check/method/suggest.rs
src/librustc_typeck/check/method/suggest.rs
+1
-1
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+3
-3
未找到文件。
src/librustc_errors/diagnostic.rs
浏览文件 @
9ff0f337
...
@@ -350,10 +350,10 @@ pub fn span_suggestion_with_applicability(&mut self, sp: Span, msg: &str,
...
@@ -350,10 +350,10 @@ pub fn span_suggestion_with_applicability(&mut self, sp: Span, msg: &str,
}
}
pub
fn
span_suggestions_with_applicability
(
&
mut
self
,
sp
:
Span
,
msg
:
&
str
,
pub
fn
span_suggestions_with_applicability
(
&
mut
self
,
sp
:
Span
,
msg
:
&
str
,
suggestions
:
Vec
<
String
>
,
suggestions
:
impl
Iterator
<
Item
=
String
>
,
applicability
:
Applicability
)
->
&
mut
Self
applicability
:
Applicability
)
->
&
mut
Self
{
{
self
.suggestions
.push
(
CodeSuggestion
{
self
.suggestions
.push
(
CodeSuggestion
{
substitutions
:
suggestions
.
into_iter
()
.
map
(|
snippet
|
Substitution
{
substitutions
:
suggestions
.map
(|
snippet
|
Substitution
{
parts
:
vec!
[
SubstitutionPart
{
parts
:
vec!
[
SubstitutionPart
{
snippet
,
snippet
,
span
:
sp
,
span
:
sp
,
...
...
src/librustc_errors/diagnostic_builder.rs
浏览文件 @
9ff0f337
...
@@ -253,7 +253,7 @@ pub fn span_suggestion_with_applicability(&mut self,
...
@@ -253,7 +253,7 @@ pub fn span_suggestion_with_applicability(&mut self,
pub
fn
span_suggestions_with_applicability
(
&
mut
self
,
pub
fn
span_suggestions_with_applicability
(
&
mut
self
,
sp
:
Span
,
sp
:
Span
,
msg
:
&
str
,
msg
:
&
str
,
suggestions
:
Vec
<
String
>
,
suggestions
:
impl
Iterator
<
Item
=
String
>
,
applicability
:
Applicability
)
applicability
:
Applicability
)
->
&
mut
Self
{
->
&
mut
Self
{
if
!
self
.allow_suggestions
{
if
!
self
.allow_suggestions
{
...
...
src/librustc_resolve/lib.rs
浏览文件 @
9ff0f337
...
@@ -4944,7 +4944,7 @@ fn show_candidates(err: &mut DiagnosticBuilder,
...
@@ -4944,7 +4944,7 @@ fn show_candidates(err: &mut DiagnosticBuilder,
err
.span_suggestions_with_applicability
(
err
.span_suggestions_with_applicability
(
span
,
span
,
&
msg
,
&
msg
,
path_strings
,
path_strings
.into_iter
()
,
Applicability
::
Unspecified
,
Applicability
::
Unspecified
,
);
);
}
else
{
}
else
{
...
...
src/librustc_typeck/check/demand.rs
浏览文件 @
9ff0f337
...
@@ -132,7 +132,7 @@ pub fn demand_coerce_diag(&self,
...
@@ -132,7 +132,7 @@ pub fn demand_coerce_diag(&self,
if
compatible_variants
.peek
()
.is_some
()
{
if
compatible_variants
.peek
()
.is_some
()
{
let
expr_text
=
print
::
to_string
(
print
::
NO_ANN
,
|
s
|
s
.print_expr
(
expr
));
let
expr_text
=
print
::
to_string
(
print
::
NO_ANN
,
|
s
|
s
.print_expr
(
expr
));
let
suggestions
=
compatible_variants
let
suggestions
=
compatible_variants
.map
(|
v
|
format!
(
"{}({})"
,
v
,
expr_text
))
.collect
::
<
Vec
<
_
>>
()
;
.map
(|
v
|
format!
(
"{}({})"
,
v
,
expr_text
));
err
.span_suggestions_with_applicability
(
err
.span_suggestions_with_applicability
(
expr
.span
,
expr
.span
,
"try using a variant of the expected type"
,
"try using a variant of the expected type"
,
...
...
src/librustc_typeck/check/method/suggest.rs
浏览文件 @
9ff0f337
...
@@ -521,7 +521,7 @@ fn suggest_use_candidates(&self,
...
@@ -521,7 +521,7 @@ fn suggest_use_candidates(&self,
with_crate_prefix
(||
self
.tcx
.item_path_str
(
*
did
)),
with_crate_prefix
(||
self
.tcx
.item_path_str
(
*
did
)),
additional_newline
additional_newline
)
)
})
.collect
()
;
});
err
.span_suggestions_with_applicability
(
err
.span_suggestions_with_applicability
(
span
,
span
,
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
9ff0f337
...
@@ -4744,7 +4744,7 @@ pub fn suggest_ref_or_into(
...
@@ -4744,7 +4744,7 @@ pub fn suggest_ref_or_into(
}
else
if
!
self
.check_for_cast
(
err
,
expr
,
found
,
expected
)
{
}
else
if
!
self
.check_for_cast
(
err
,
expr
,
found
,
expected
)
{
let
methods
=
self
.get_conversion_methods
(
expr
.span
,
expected
,
found
);
let
methods
=
self
.get_conversion_methods
(
expr
.span
,
expected
,
found
);
if
let
Ok
(
expr_text
)
=
self
.sess
()
.source_map
()
.span_to_snippet
(
expr
.span
)
{
if
let
Ok
(
expr_text
)
=
self
.sess
()
.source_map
()
.span_to_snippet
(
expr
.span
)
{
let
suggestions
=
iter
::
repeat
(
&
expr_text
)
.zip
(
methods
.iter
())
let
mut
suggestions
=
iter
::
repeat
(
&
expr_text
)
.zip
(
methods
.iter
())
.filter_map
(|(
receiver
,
method
)|
{
.filter_map
(|(
receiver
,
method
)|
{
let
method_call
=
format!
(
".{}()"
,
method
.ident
);
let
method_call
=
format!
(
".{}()"
,
method
.ident
);
if
receiver
.ends_with
(
&
method_call
)
{
if
receiver
.ends_with
(
&
method_call
)
{
...
@@ -4760,8 +4760,8 @@ pub fn suggest_ref_or_into(
...
@@ -4760,8 +4760,8 @@ pub fn suggest_ref_or_into(
Some
(
format!
(
"{}{}"
,
receiver
,
method_call
))
Some
(
format!
(
"{}{}"
,
receiver
,
method_call
))
}
}
}
}
})
.
collect
::
<
Vec
<
_
>>
();
})
.
peekable
();
if
!
suggestions
.is_empty
()
{
if
suggestions
.peek
()
.is_some
()
{
err
.span_suggestions_with_applicability
(
err
.span_suggestions_with_applicability
(
expr
.span
,
expr
.span
,
"try using a conversion method"
,
"try using a conversion method"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录