Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
4ebc16c1
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,发现更多精彩内容 >>
提交
4ebc16c1
编写于
4月 12, 2015
作者:
M
Manish Goregaokar
浏览文件
操作
浏览文件
下载
差异文件
Rollup merge of #24072 - ebfull:explain_closure_type_err, r=pnkfelix
Also fixed bug calling .note() instead of .help() See #24036
上级
a1e3c25a
3308c06e
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
48 addition
and
7 deletion
+48
-7
src/librustc/middle/infer/error_reporting.rs
src/librustc/middle/infer/error_reporting.rs
+3
-2
src/librustc/middle/infer/mod.rs
src/librustc/middle/infer/mod.rs
+1
-1
src/librustc/middle/ty.rs
src/librustc/middle/ty.rs
+11
-1
src/librustc/session/mod.rs
src/librustc/session/mod.rs
+1
-1
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+1
-1
src/librustc_typeck/lib.rs
src/librustc_typeck/lib.rs
+1
-1
src/test/compile-fail/issue-24036.rs
src/test/compile-fail/issue-24036.rs
+30
-0
未找到文件。
src/librustc/middle/infer/error_reporting.rs
浏览文件 @
4ebc16c1
...
...
@@ -373,8 +373,9 @@ fn report_type_error(&self, trace: TypeTrace<'tcx>, terr: &ty::type_err<'tcx>) {
fn
report_and_explain_type_error
(
&
self
,
trace
:
TypeTrace
<
'tcx
>
,
terr
:
&
ty
::
type_err
<
'tcx
>
)
{
let
span
=
trace
.origin
.span
();
self
.report_type_error
(
trace
,
terr
);
ty
::
note_and_explain_type_err
(
self
.tcx
,
terr
);
ty
::
note_and_explain_type_err
(
self
.tcx
,
terr
,
span
);
}
/// Returns a string of the form "expected `{}`, found `{}`", or None if this is a derived
...
...
@@ -812,7 +813,7 @@ fn report_processed_errors(&self,
}
self
.give_suggestion
(
same_regions
);
for
&
(
ref
trace
,
terr
)
in
trace_origins
{
self
.report_type_error
(
trace
.clone
(),
&
terr
);
self
.report_
and_explain_
type_error
(
trace
.clone
(),
&
terr
);
}
}
...
...
src/librustc/middle/infer/mod.rs
浏览文件 @
4ebc16c1
...
...
@@ -987,7 +987,7 @@ pub fn type_error_message_str_with_expected<M>(&self,
error_str
));
if
let
Some
(
err
)
=
err
{
ty
::
note_and_explain_type_err
(
self
.tcx
,
err
)
ty
::
note_and_explain_type_err
(
self
.tcx
,
err
,
sp
)
}
}
}
...
...
src/librustc/middle/ty.rs
浏览文件 @
4ebc16c1
...
...
@@ -5103,7 +5103,7 @@ pub fn type_err_to_str<'tcx>(cx: &ctxt<'tcx>, err: &type_err<'tcx>) -> String {
}
}
pub
fn
note_and_explain_type_err
(
cx
:
&
ctxt
,
err
:
&
type_err
)
{
pub
fn
note_and_explain_type_err
<
'tcx
>
(
cx
:
&
ctxt
<
'tcx
>
,
err
:
&
type_err
<
'tcx
>
,
sp
:
Span
)
{
match
*
err
{
terr_regions_does_not_outlive
(
subregion
,
superregion
)
=>
{
note_and_explain_region
(
cx
,
""
,
subregion
,
"..."
);
...
...
@@ -5134,6 +5134,16 @@ pub fn note_and_explain_type_err(cx: &ctxt, err: &type_err) {
"expected concrete lifetime is "
,
conc_region
,
""
);
}
terr_sorts
(
values
)
=>
{
let
expected_str
=
ty_sort_string
(
cx
,
values
.expected
);
let
found_str
=
ty_sort_string
(
cx
,
values
.found
);
if
expected_str
==
found_str
&&
expected_str
==
"closure"
{
cx
.sess
.span_note
(
sp
,
&
format!
(
"no two closures, even if identical, have the same
\
type"
));
cx
.sess
.span_help
(
sp
,
&
format!
(
"consider boxing your closure and/or
\
using it as a trait object"
));
}
}
_
=>
{}
}
}
...
...
src/librustc/session/mod.rs
浏览文件 @
4ebc16c1
...
...
@@ -163,7 +163,7 @@ pub fn note(&self, msg: &str) {
self
.diagnostic
()
.handler
()
.note
(
msg
)
}
pub
fn
help
(
&
self
,
msg
:
&
str
)
{
self
.diagnostic
()
.handler
()
.
note
(
msg
)
self
.diagnostic
()
.handler
()
.
help
(
msg
)
}
pub
fn
opt_span_bug
(
&
self
,
opt_sp
:
Option
<
Span
>
,
msg
:
&
str
)
->
!
{
match
opt_sp
{
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
4ebc16c1
...
...
@@ -3575,7 +3575,7 @@ fn check_struct_fields_on_error<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
.ty_to_string
(
actual_structure_type
),
type_error_description
);
ty
::
note_and_explain_type_err
(
tcx
,
&
type_error
);
ty
::
note_and_explain_type_err
(
tcx
,
&
type_error
,
path
.span
);
}
}
}
...
...
src/librustc_typeck/lib.rs
浏览文件 @
4ebc16c1
...
...
@@ -200,7 +200,7 @@ fn require_same_types<'a, 'tcx, M>(tcx: &ty::ctxt<'tcx>,
msg
(),
ty
::
type_err_to_str
(
tcx
,
terr
));
ty
::
note_and_explain_type_err
(
tcx
,
terr
);
ty
::
note_and_explain_type_err
(
tcx
,
terr
,
span
);
false
}
}
...
...
src/test/compile-fail/issue-24036.rs
0 → 100644
浏览文件 @
4ebc16c1
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
closure_to_loc
()
{
let
mut
x
=
|
c
|
c
+
1
;
x
=
|
c
|
c
+
1
;
//~^ ERROR mismatched types
//~| NOTE no two closures, even if identical, have the same type
//~| HELP consider boxing your closure and/or using it as a trait object
}
fn
closure_from_match
()
{
let
x
=
match
1u
size
{
1
=>
|
c
|
c
+
1
,
2
=>
|
c
|
c
-
1
,
_
=>
|
c
|
c
-
1
};
//~^^^^^ ERROR match arms have incompatible types
//~| NOTE no two closures, even if identical, have the same type
//~| HELP consider boxing your closure and/or using it as a trait object
}
fn
main
()
{
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录