Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
19d913bf
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,发现更多精彩内容 >>
提交
19d913bf
编写于
3月 22, 2014
作者:
K
Kiet Tran
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Prefer lifetime suggestion over generic error
上级
6f430c44
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
3 deletion
+29
-3
src/librustc/middle/typeck/infer/error_reporting.rs
src/librustc/middle/typeck/infer/error_reporting.rs
+11
-1
src/librustc/middle/typeck/infer/region_inference/mod.rs
src/librustc/middle/typeck/infer/region_inference/mod.rs
+18
-2
未找到文件。
src/librustc/middle/typeck/infer/error_reporting.rs
浏览文件 @
19d913bf
...
...
@@ -195,6 +195,7 @@ fn report_region_errors(&self,
// failed (so the return value of this method should not be used)
fn
process_errors
(
&
self
,
errors
:
&
Vec
<
RegionResolutionError
>
)
->
Vec
<
RegionResolutionError
>
{
debug!
(
"process_errors()"
);
let
mut
var_origins
=
Vec
::
new
();
let
mut
trace_origins
=
Vec
::
new
();
let
mut
same_regions
=
Vec
::
new
();
...
...
@@ -202,6 +203,7 @@ fn process_errors(&self, errors: &Vec<RegionResolutionError>)
for
error
in
errors
.iter
()
{
match
*
error
{
ConcreteFailure
(
origin
,
sub
,
sup
)
=>
{
debug!
(
"processing ConcreteFailure"
)
let
trace
=
match
origin
{
infer
::
Subtype
(
trace
)
=>
Some
(
trace
),
_
=>
None
,
...
...
@@ -218,6 +220,7 @@ fn process_errors(&self, errors: &Vec<RegionResolutionError>)
}
}
SubSupConflict
(
var_origin
,
_
,
sub_r
,
_
,
sup_r
)
=>
{
debug!
(
"processing SubSupConflict"
)
match
free_regions_from_same_fn
(
self
.tcx
,
sub_r
,
sup_r
)
{
Some
(
ref
same_frs
)
=>
{
var_origins
.push
(
var_origin
);
...
...
@@ -237,10 +240,13 @@ fn process_errors(&self, errors: &Vec<RegionResolutionError>)
// declaration, we want to make sure that they are, in fact,
// from the same scope
if
sr
.scope_id
!=
common_scope_id
{
debug!
(
"returning empty result from process_errors because
{} != {}"
,
sr
.scope_id
,
common_scope_id
);
return
vec!
();
}
}
let
pe
=
ProcessedErrors
(
var_origins
,
trace_origins
,
same_regions
);
debug!
(
"errors processed: {:?}"
,
pe
);
processed_errors
.push
(
pe
);
}
return
processed_errors
;
...
...
@@ -256,6 +262,7 @@ fn free_regions_from_same_fn(tcx: &ty::ctxt,
sub
:
Region
,
sup
:
Region
)
->
Option
<
FreeRegionsFromSameFn
>
{
debug!
(
"free_regions_from_same_fn(sub={:?}, sup={:?})"
,
sub
,
sup
);
let
(
scope_id
,
fr1
,
fr2
)
=
match
(
sub
,
sup
)
{
(
ReFree
(
fr1
),
ReFree
(
fr2
))
=>
{
if
fr1
.scope_id
!=
fr2
.scope_id
{
...
...
@@ -284,7 +291,10 @@ fn free_regions_from_same_fn(tcx: &ty::ctxt,
},
_
=>
None
},
None
=>
None
None
=>
{
debug!
(
"no parent node of scope_id {}"
,
scope_id
)
None
}
}
}
...
...
src/librustc/middle/typeck/infer/region_inference/mod.rs
浏览文件 @
19d913bf
...
...
@@ -1117,10 +1117,10 @@ fn collect_error_for_expanding_node(
{
// Errors in expanding nodes result from a lower-bound that is
// not contained by an upper-bound.
let
(
lower_bounds
,
lower_dup
)
=
let
(
mut
lower_bounds
,
lower_dup
)
=
self
.collect_concrete_regions
(
graph
,
var_data
,
node_idx
,
graph
::
Incoming
,
dup_vec
);
let
(
upper_bounds
,
upper_dup
)
=
let
(
mut
upper_bounds
,
upper_dup
)
=
self
.collect_concrete_regions
(
graph
,
var_data
,
node_idx
,
graph
::
Outgoing
,
dup_vec
);
...
...
@@ -1128,6 +1128,22 @@ fn collect_error_for_expanding_node(
return
;
}
// We place free regions first because we are special casing
// SubSupConflict(ReFree, ReFree) when reporting error, and so
// the user will more likely get a specific suggestion.
fn
free_regions_first
(
a
:
&
RegionAndOrigin
,
b
:
&
RegionAndOrigin
)
->
Ordering
{
match
(
a
.region
,
b
.region
)
{
(
ReFree
(
..
),
ReFree
(
..
))
=>
Equal
,
(
ReFree
(
..
),
_
)
=>
Less
,
(
_
,
ReFree
(
..
))
=>
Greater
,
(
_
,
_
)
=>
Equal
,
}
}
lower_bounds
.sort_by
(|
a
,
b
|
{
free_regions_first
(
a
,
b
)
});
upper_bounds
.sort_by
(|
a
,
b
|
{
free_regions_first
(
a
,
b
)
});
for
lower_bound
in
lower_bounds
.iter
()
{
for
upper_bound
in
upper_bounds
.iter
()
{
if
!
self
.is_subregion_of
(
lower_bound
.region
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录