Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
c13a913e
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,发现更多精彩内容 >>
提交
c13a913e
编写于
6月 24, 2017
作者:
E
Esteban Küber
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Don't naively point to return type on type error
上级
27d4b314
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
3 addition
and
67 deletion
+3
-67
src/librustc_typeck/check/coercion.rs
src/librustc_typeck/check/coercion.rs
+0
-6
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+0
-22
src/test/ui/block-result/issue-13624.stderr
src/test/ui/block-result/issue-13624.stderr
+0
-2
src/test/ui/block-result/issue-20862.stderr
src/test/ui/block-result/issue-20862.stderr
+1
-4
src/test/ui/block-result/issue-22645.stderr
src/test/ui/block-result/issue-22645.stderr
+0
-3
src/test/ui/block-result/issue-3563.stderr
src/test/ui/block-result/issue-3563.stderr
+1
-4
src/test/ui/block-result/issue-5500.stderr
src/test/ui/block-result/issue-5500.stderr
+0
-2
src/test/ui/block-result/unexpected-return-on-unit.stderr
src/test/ui/block-result/unexpected-return-on-unit.stderr
+0
-2
src/test/ui/impl-trait/equality.stderr
src/test/ui/impl-trait/equality.stderr
+0
-3
src/test/ui/mismatched_types/abridged.stderr
src/test/ui/mismatched_types/abridged.stderr
+0
-12
src/test/ui/mismatched_types/issue-19109.stderr
src/test/ui/mismatched_types/issue-19109.stderr
+1
-4
src/test/ui/resolve/token-error-correct-3.stderr
src/test/ui/resolve/token-error-correct-3.stderr
+0
-3
未找到文件。
src/librustc_typeck/check/coercion.rs
浏览文件 @
c13a913e
...
...
@@ -1174,12 +1174,6 @@ fn coerce_inner<'a>(&mut self,
expected
,
found
,
cause
.span
,
blk_id
);
}
ObligationCauseCode
::
ReturnType
(
ret_id
)
=>
{
db
=
fcx
.report_mismatched_types
(
cause
,
expected
,
found
,
err
);
if
let
Some
((
fn_decl
,
_
))
=
fcx
.get_fn_decl
(
ret_id
)
{
fcx
.point_to_type_requirement
(
&
mut
db
,
&
fn_decl
,
expected
);
}
}
_
=>
{
db
=
fcx
.report_mismatched_types
(
cause
,
expected
,
found
,
err
);
}
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
c13a913e
...
...
@@ -4261,7 +4261,6 @@ pub fn suggest_mismatched_types_on_tail(&self,
self
.suggest_missing_semicolon
(
err
,
expression
,
expected
,
cause_span
);
if
let
Some
((
fn_decl
,
is_main
))
=
self
.get_fn_decl
(
blk_id
)
{
self
.point_to_type_requirement
(
err
,
&
fn_decl
,
expected
);
// `fn main()` must return `()`, do not suggest changing return type
if
!
is_main
{
self
.suggest_missing_return_type
(
err
,
&
fn_decl
,
found
);
...
...
@@ -4269,27 +4268,6 @@ pub fn suggest_mismatched_types_on_tail(&self,
}
}
pub
fn
point_to_type_requirement
(
&
self
,
err
:
&
mut
DiagnosticBuilder
<
'tcx
>
,
fn_decl
:
&
hir
::
FnDecl
,
ty
:
Ty
<
'tcx
>
)
{
let
msg
=
if
let
&
hir
::
FnDecl
{
output
:
hir
::
FunctionRetTy
::
DefaultReturn
(
_
),
..
}
=
fn_decl
{
"default "
}
else
{
""
};
let
ty
=
self
.resolve_type_vars_if_possible
(
&
ty
);
if
ty
.to_string
()
.len
()
<
10
{
err
.span_label
(
fn_decl
.output
.span
(),
format!
(
"expected `{}` because of this {}return type"
,
ty
,
msg
));
}
else
{
err
.span_label
(
fn_decl
.output
.span
(),
format!
(
"expected because of this {}return type"
,
msg
));
}
}
/// A common error is to forget to add a semicolon at the end of a block:
///
/// ```
...
...
src/test/ui/block-result/issue-13624.stderr
浏览文件 @
c13a913e
error[E0308]: mismatched types
--> $DIR/issue-13624.rs:17:5
|
16 | pub fn get_enum_struct_variant() -> () {
| -- expected `()` because of this return type
17 | Enum::EnumStructVariant { x: 1, y: 2, z: 3 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found enum `a::Enum`
|
...
...
src/test/ui/block-result/issue-20862.stderr
浏览文件 @
c13a913e
...
...
@@ -2,10 +2,7 @@ error[E0308]: mismatched types
--> $DIR/issue-20862.rs:12:5
|
11 | fn foo(x: i32) {
| -
| |
| possibly return type missing here?
| expected `()` because of this default return type
| - possibly return type missing here?
12 | |y| x + y
| ^^^^^^^^^ expected (), found closure
|
...
...
src/test/ui/block-result/issue-22645.stderr
浏览文件 @
c13a913e
...
...
@@ -11,9 +11,6 @@ error[E0277]: the trait bound `{integer}: Scalar` is not satisfied
error[E0308]: mismatched types
--> $DIR/issue-22645.rs:25:3
|
23 | fn main() {
| - expected `()` because of this default return type
24 | let b = Bob + 3.5;
25 | b + 3 //~ ERROR E0277
| ^^^^^ expected (), found struct `Bob`
|
...
...
src/test/ui/block-result/issue-3563.stderr
浏览文件 @
c13a913e
...
...
@@ -8,10 +8,7 @@ error[E0308]: mismatched types
--> $DIR/issue-3563.rs:13:9
|
12 | fn a(&self) {
| -
| |
| possibly return type missing here?
| expected `()` because of this default return type
| - possibly return type missing here?
13 | || self.b()
| ^^^^^^^^^^^ expected (), found closure
|
...
...
src/test/ui/block-result/issue-5500.stderr
浏览文件 @
c13a913e
error[E0308]: mismatched types
--> $DIR/issue-5500.rs:12:5
|
11 | fn main() {
| - expected `()` because of this default return type
12 | &panic!()
| ^^^^^^^^^ expected (), found reference
|
...
...
src/test/ui/block-result/unexpected-return-on-unit.stderr
浏览文件 @
c13a913e
error[E0308]: mismatched types
--> $DIR/unexpected-return-on-unit.rs:19:5
|
18 | fn bar() {
| - expected `()` because of this default return type
19 | foo()
| ^^^^^ expected (), found usize
|
...
...
src/test/ui/impl-trait/equality.stderr
浏览文件 @
c13a913e
error[E0308]: mismatched types
--> $DIR/equality.rs:25:5
|
21 | fn two(x: bool) -> impl Foo {
| -------- expected `i32` because of this return type
...
25 | 0_u32
| ^^^^^ expected i32, found u32
|
...
...
src/test/ui/mismatched_types/abridged.stderr
浏览文件 @
c13a913e
error[E0308]: mismatched types
--> $DIR/abridged.rs:26:5
|
25 | fn a() -> Foo {
| --- expected `Foo` because of this return type
26 | Some(Foo { bar: 1 })
| ^^^^^^^^^^^^^^^^^^^^ expected struct `Foo`, found enum `std::option::Option`
|
...
...
@@ -12,8 +10,6 @@ error[E0308]: mismatched types
error[E0308]: mismatched types
--> $DIR/abridged.rs:30:5
|
29 | fn a2() -> Foo {
| --- expected `Foo` because of this return type
30 | Ok(Foo { bar: 1})
| ^^^^^^^^^^^^^^^^^ expected struct `Foo`, found enum `std::result::Result`
|
...
...
@@ -23,8 +19,6 @@ error[E0308]: mismatched types
error[E0308]: mismatched types
--> $DIR/abridged.rs:34:5
|
33 | fn b() -> Option<Foo> {
| ----------- expected because of this return type
34 | Foo { bar: 1 }
| ^^^^^^^^^^^^^^ expected enum `std::option::Option`, found struct `Foo`
|
...
...
@@ -34,8 +28,6 @@ error[E0308]: mismatched types
error[E0308]: mismatched types
--> $DIR/abridged.rs:38:5
|
37 | fn c() -> Result<Foo, Bar> {
| ---------------- expected because of this return type
38 | Foo { bar: 1 }
| ^^^^^^^^^^^^^^ expected enum `std::result::Result`, found struct `Foo`
|
...
...
@@ -45,8 +37,6 @@ error[E0308]: mismatched types
error[E0308]: mismatched types
--> $DIR/abridged.rs:42:5
|
41 | fn d() -> X<X<String, String>, String> {
| ---------------------------- expected because of this return type
42 | / X {
43 | | x: X {
44 | | x: "".to_string(),
...
...
@@ -62,8 +52,6 @@ error[E0308]: mismatched types
error[E0308]: mismatched types
--> $DIR/abridged.rs:52:5
|
51 | fn e() -> X<X<String, String>, String> {
| ---------------------------- expected because of this return type
52 | / X {
53 | | x: X {
54 | | x: "".to_string(),
...
...
src/test/ui/mismatched_types/issue-19109.stderr
浏览文件 @
c13a913e
...
...
@@ -2,10 +2,7 @@ error[E0308]: mismatched types
--> $DIR/issue-19109.rs:14:5
|
13 | fn function(t: &mut Trait) {
| -
| |
| help: possibly return type missing here? `-> *mut Trait `
| expected `()` because of this default return type
| - help: possibly return type missing here? `-> *mut Trait `
14 | t as *mut Trait
| ^^^^^^^^^^^^^^^ expected (), found *-ptr
|
...
...
src/test/ui/resolve/token-error-correct-3.stderr
浏览文件 @
c13a913e
...
...
@@ -34,9 +34,6 @@ error[E0425]: cannot find function `is_directory` in this scope
error[E0308]: mismatched types
--> $DIR/token-error-correct-3.rs:25:13
|
20 | -> io::Result<bool> {
| ---------------- expected `()` because of this return type
...
25 | fs::create_dir_all(path.as_ref()).map(|()| true) //~ ERROR: mismatched types
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- help: did you mean to add a semicolon here? `;`
| |
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录