Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
f29fb479
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,发现更多精彩内容 >>
提交
f29fb479
编写于
12月 13, 2021
作者:
M
Michael Goulet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make TyS::is_suggestable more structual
上级
8f117a77
变更
30
隐藏空白更改
内联
并排
Showing
30 changed file
with
112 addition
and
99 deletion
+112
-99
compiler/rustc_middle/src/ty/diagnostics.rs
compiler/rustc_middle/src/ty/diagnostics.rs
+54
-10
src/test/ui/associated-types/defaults-in-other-trait-items.rs
...test/ui/associated-types/defaults-in-other-trait-items.rs
+1
-0
src/test/ui/associated-types/defaults-in-other-trait-items.stderr
.../ui/associated-types/defaults-in-other-trait-items.stderr
+4
-2
src/test/ui/destructuring-assignment/default-match-bindings-forbidden.stderr
...turing-assignment/default-match-bindings-forbidden.stderr
+1
-3
src/test/ui/destructuring-assignment/tuple_destructure_fail.stderr
...ui/destructuring-assignment/tuple_destructure_fail.stderr
+2
-6
src/test/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision.stderr
...-patterns/exclusive_range_pattern_syntax_collision.stderr
+0
-2
src/test/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision2.stderr
...patterns/exclusive_range_pattern_syntax_collision2.stderr
+0
-2
src/test/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision3.stderr
...patterns/exclusive_range_pattern_syntax_collision3.stderr
+0
-6
src/test/ui/half-open-range-patterns/pat-tuple-5.stderr
src/test/ui/half-open-range-patterns/pat-tuple-5.stderr
+0
-2
src/test/ui/issues/issue-11844.stderr
src/test/ui/issues/issue-11844.stderr
+0
-2
src/test/ui/issues/issue-12552.stderr
src/test/ui/issues/issue-12552.stderr
+0
-5
src/test/ui/issues/issue-13466.stderr
src/test/ui/issues/issue-13466.stderr
+0
-5
src/test/ui/issues/issue-3680.stderr
src/test/ui/issues/issue-3680.stderr
+0
-2
src/test/ui/issues/issue-66706.stderr
src/test/ui/issues/issue-66706.stderr
+3
-3
src/test/ui/issues/issue-72574-1.stderr
src/test/ui/issues/issue-72574-1.stderr
+0
-2
src/test/ui/mismatched_types/E0409.stderr
src/test/ui/mismatched_types/E0409.stderr
+0
-2
src/test/ui/mut/mut-pattern-mismatched.stderr
src/test/ui/mut/mut-pattern-mismatched.stderr
+0
-6
src/test/ui/never_type/diverging-tuple-parts-39485.stderr
src/test/ui/never_type/diverging-tuple-parts-39485.stderr
+2
-4
src/test/ui/or-patterns/already-bound-name.stderr
src/test/ui/or-patterns/already-bound-name.stderr
+2
-3
src/test/ui/or-patterns/inconsistent-modes.stderr
src/test/ui/or-patterns/inconsistent-modes.stderr
+2
-3
src/test/ui/pattern/issue-74702.stderr
src/test/ui/pattern/issue-74702.stderr
+1
-3
src/test/ui/pattern/pat-tuple-overfield.stderr
src/test/ui/pattern/pat-tuple-overfield.stderr
+0
-5
src/test/ui/return/return-type.stderr
src/test/ui/return/return-type.stderr
+5
-9
src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr
...est/ui/rfc-2497-if-let-chains/disallowed-positions.stderr
+6
-2
src/test/ui/slightly-nice-generic-literal-messages.stderr
src/test/ui/slightly-nice-generic-literal-messages.stderr
+0
-2
src/test/ui/structs/structure-constructor-type-mismatch.stderr
...est/ui/structs/structure-constructor-type-mismatch.stderr
+0
-6
src/test/ui/typeck/issue-57673-ice-on-deref-of-boxed-trait.stderr
.../ui/typeck/issue-57673-ice-on-deref-of-boxed-trait.stderr
+1
-1
src/test/ui/typeck/issue-91334.stderr
src/test/ui/typeck/issue-91334.stderr
+1
-1
src/test/ui/typeck/return_type_containing_closure.rs
src/test/ui/typeck/return_type_containing_closure.rs
+10
-0
src/test/ui/typeck/return_type_containing_closure.stderr
src/test/ui/typeck/return_type_containing_closure.stderr
+17
-0
未找到文件。
compiler/rustc_middle/src/ty/diagnostics.rs
浏览文件 @
f29fb479
//! Diagnostics related methods for `TyS`.
use
crate
::
ty
::
subst
::{
GenericArg
,
GenericArgKind
};
use
crate
::
ty
::
TyKind
::
*
;
use
crate
::
ty
::{
InferTy
,
TyCtxt
,
TyS
};
use
crate
::
ty
::{
ConstKind
,
ExistentialPredicate
,
ExistentialProjection
,
ExistentialTraitRef
,
InferTy
,
ProjectionTy
,
TyCtxt
,
TyS
,
TypeAndMut
,
};
use
rustc_errors
::{
Applicability
,
DiagnosticBuilder
};
use
rustc_hir
as
hir
;
use
rustc_hir
::
def_id
::
DefId
;
...
...
@@ -63,16 +68,55 @@ pub fn is_simple_text(&self) -> bool {
/// Whether the type can be safely suggested during error recovery.
pub
fn
is_suggestable
(
&
self
)
->
bool
{
!
matches!
(
self
.kind
(),
fn
generic_arg_is_suggestible
(
arg
:
GenericArg
<
'_
>
)
->
bool
{
match
arg
.unpack
()
{
GenericArgKind
::
Type
(
ty
)
=>
ty
.is_suggestable
(),
GenericArgKind
::
Const
(
c
)
=>
const_is_suggestable
(
c
.val
),
_
=>
true
,
}
}
fn
const_is_suggestable
(
kind
:
ConstKind
<
'_
>
)
->
bool
{
match
kind
{
ConstKind
::
Infer
(
..
)
|
ConstKind
::
Bound
(
..
)
|
ConstKind
::
Placeholder
(
..
)
|
ConstKind
::
Error
(
..
)
=>
false
,
_
=>
true
,
}
}
// FIXME(compiler-errors): Some types are still not good to suggest,
// specifically references with lifetimes within the function. Not
//sure we have enough information to resolve whether a region is
// temporary, so I'll leave this as a fixme.
match
self
.kind
()
{
Opaque
(
..
)
|
FnDef
(
..
)
|
FnPtr
(
..
)
|
Dynamic
(
..
)
|
Closure
(
..
)
|
Infer
(
..
)
|
Projection
(
..
)
)
|
FnDef
(
..
)
|
Closure
(
..
)
|
Infer
(
..
)
|
Generator
(
..
)
|
GeneratorWitness
(
..
)
|
Bound
(
_
,
_
)
|
Placeholder
(
_
)
|
Error
(
_
)
=>
false
,
Dynamic
(
dty
,
_
)
=>
dty
.iter
()
.all
(|
pred
|
match
pred
.skip_binder
()
{
ExistentialPredicate
::
Trait
(
ExistentialTraitRef
{
substs
,
..
})
=>
{
substs
.iter
()
.all
(
generic_arg_is_suggestible
)
}
ExistentialPredicate
::
Projection
(
ExistentialProjection
{
substs
,
ty
,
..
})
=>
{
ty
.is_suggestable
()
&&
substs
.iter
()
.all
(
generic_arg_is_suggestible
)
}
_
=>
true
,
}),
Projection
(
ProjectionTy
{
substs
:
args
,
..
})
|
Adt
(
_
,
args
)
|
Tuple
(
args
)
=>
{
args
.iter
()
.all
(
generic_arg_is_suggestible
)
}
Slice
(
ty
)
|
RawPtr
(
TypeAndMut
{
ty
,
..
})
|
Ref
(
_
,
ty
,
_
)
=>
ty
.is_suggestable
(),
Array
(
ty
,
c
)
=>
ty
.is_suggestable
()
&&
const_is_suggestable
(
c
.val
),
_
=>
true
,
}
}
}
...
...
src/test/ui/associated-types/defaults-in-other-trait-items.rs
浏览文件 @
f29fb479
...
...
@@ -10,6 +10,7 @@ fn f(p: Self::A) {
//~^ ERROR mismatched types
//~| NOTE expected associated type, found `()`
//~| NOTE expected associated type `<Self as Tr>::A`
//~| NOTE this expression has type `<Self as Tr>::A`
}
}
...
...
src/test/ui/associated-types/defaults-in-other-trait-items.stderr
浏览文件 @
f29fb479
...
...
@@ -5,13 +5,15 @@ LL | type A = ();
| ------------ associated type defaults can't be assumed inside the trait defining them
...
LL | let () = p;
| ^^ expected associated type, found `()`
| ^^ - this expression has type `<Self as Tr>::A`
| |
| expected associated type, found `()`
|
= note: expected associated type `<Self as Tr>::A`
found unit type `()`
error[E0308]: mismatched types
--> $DIR/defaults-in-other-trait-items.rs:3
5
:25
--> $DIR/defaults-in-other-trait-items.rs:3
6
:25
|
LL | type Ty = u8;
| ------------- associated type defaults can't be assumed inside the trait defining them
...
...
src/test/ui/destructuring-assignment/default-match-bindings-forbidden.stderr
浏览文件 @
f29fb479
...
...
@@ -2,9 +2,7 @@ error[E0308]: mismatched types
--> $DIR/default-match-bindings-forbidden.rs:6:5
|
LL | (x, y) = &(1, 2);
| ^^^^^^ ------- this expression has type `&({integer}, {integer})`
| |
| expected reference, found tuple
| ^^^^^^ expected reference, found tuple
|
= note: expected type `&({integer}, {integer})`
found tuple `(_, _)`
...
...
src/test/ui/destructuring-assignment/tuple_destructure_fail.stderr
浏览文件 @
f29fb479
...
...
@@ -10,9 +10,7 @@ error[E0308]: mismatched types
--> $DIR/tuple_destructure_fail.rs:8:5
|
LL | (a, a, b) = (1, 2);
| ^^^^^^^^^ ------ this expression has type `({integer}, {integer})`
| |
| expected a tuple with 2 elements, found one with 3 elements
| ^^^^^^^^^ expected a tuple with 2 elements, found one with 3 elements
|
= note: expected type `({integer}, {integer})`
found tuple `(_, _, _)`
...
...
@@ -29,9 +27,7 @@ error[E0308]: mismatched types
--> $DIR/tuple_destructure_fail.rs:10:5
|
LL | (_,) = (1, 2);
| ^^^^ ------ this expression has type `({integer}, {integer})`
| |
| expected a tuple with 2 elements, found one with 1 element
| ^^^^ expected a tuple with 2 elements, found one with 1 element
|
= note: expected type `({integer}, {integer})`
found tuple `(_,)`
...
...
src/test/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision.stderr
浏览文件 @
f29fb479
error[E0308]: mismatched types
--> $DIR/exclusive_range_pattern_syntax_collision.rs:6:13
|
LL | match [5..4, 99..105, 43..44] {
| ----------------------- this expression has type `[std::ops::Range<{integer}>; 3]`
LL | [_, 99.., _] => {},
| ^^ expected struct `std::ops::Range`, found integer
|
...
...
src/test/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision2.stderr
浏览文件 @
f29fb479
...
...
@@ -7,8 +7,6 @@ LL | [_, 99..] => {},
error[E0308]: mismatched types
--> $DIR/exclusive_range_pattern_syntax_collision2.rs:6:13
|
LL | match [5..4, 99..105, 43..44] {
| ----------------------- this expression has type `[std::ops::Range<{integer}>; 3]`
LL | [_, 99..] => {},
| ^^ expected struct `std::ops::Range`, found integer
|
...
...
src/test/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision3.stderr
浏览文件 @
f29fb479
error[E0308]: mismatched types
--> $DIR/exclusive_range_pattern_syntax_collision3.rs:6:12
|
LL | match [5..4, 99..105, 43..44] {
| ----------------------- this expression has type `[std::ops::Range<{integer}>; 3]`
LL | [..9, 99..100, _] => {},
| ^ expected struct `std::ops::Range`, found integer
|
...
...
@@ -12,8 +10,6 @@ LL | [..9, 99..100, _] => {},
error[E0308]: mismatched types
--> $DIR/exclusive_range_pattern_syntax_collision3.rs:6:15
|
LL | match [5..4, 99..105, 43..44] {
| ----------------------- this expression has type `[std::ops::Range<{integer}>; 3]`
LL | [..9, 99..100, _] => {},
| ^^ --- this is of type `{integer}`
| |
...
...
@@ -25,8 +21,6 @@ LL | [..9, 99..100, _] => {},
error[E0308]: mismatched types
--> $DIR/exclusive_range_pattern_syntax_collision3.rs:6:19
|
LL | match [5..4, 99..105, 43..44] {
| ----------------------- this expression has type `[std::ops::Range<{integer}>; 3]`
LL | [..9, 99..100, _] => {},
| -- ^^^ expected struct `std::ops::Range`, found integer
| |
...
...
src/test/ui/half-open-range-patterns/pat-tuple-5.stderr
浏览文件 @
f29fb479
error[E0308]: mismatched types
--> $DIR/pat-tuple-5.rs:8:10
|
LL | match (0, 1) {
| ------ this expression has type `({integer}, {integer})`
LL | (PAT ..) => {}
| ^^^ expected tuple, found `u8`
|
...
...
src/test/ui/issues/issue-11844.stderr
浏览文件 @
f29fb479
error[E0308]: mismatched types
--> $DIR/issue-11844.rs:6:9
|
LL | match a {
| - this expression has type `Option<Box<{integer}>>`
LL | Ok(a) =>
| ^^^^^ expected enum `Option`, found enum `Result`
|
...
...
src/test/ui/issues/issue-12552.stderr
浏览文件 @
f29fb479
error[E0308]: mismatched types
--> $DIR/issue-12552.rs:6:5
|
LL | match t {
| - this expression has type `Result<_, {integer}>`
LL | Some(k) => match k {
| ^^^^^^^ expected enum `Result`, found enum `Option`
|
...
...
@@ -12,9 +10,6 @@ LL | Some(k) => match k {
error[E0308]: mismatched types
--> $DIR/issue-12552.rs:9:5
|
LL | match t {
| - this expression has type `Result<_, {integer}>`
...
LL | None => ()
| ^^^^ expected enum `Result`, found enum `Option`
|
...
...
src/test/ui/issues/issue-13466.stderr
浏览文件 @
f29fb479
error[E0308]: mismatched types
--> $DIR/issue-13466.rs:8:9
|
LL | let _x: usize = match Some(1) {
| ------- this expression has type `Option<{integer}>`
LL | Ok(u) => u,
| ^^^^^ expected enum `Option`, found enum `Result`
|
...
...
@@ -12,9 +10,6 @@ LL | Ok(u) => u,
error[E0308]: mismatched types
--> $DIR/issue-13466.rs:14:9
|
LL | let _x: usize = match Some(1) {
| ------- this expression has type `Option<{integer}>`
...
LL | Err(e) => panic!(e)
| ^^^^^^ expected enum `Option`, found enum `Result`
|
...
...
src/test/ui/issues/issue-3680.stderr
浏览文件 @
f29fb479
error[E0308]: mismatched types
--> $DIR/issue-3680.rs:3:9
|
LL | match None {
| ---- this expression has type `Option<_>`
LL | Err(_) => ()
| ^^^^^^ expected enum `Option`, found enum `Result`
|
...
...
src/test/ui/issues/issue-66706.stderr
浏览文件 @
f29fb479
...
...
@@ -36,7 +36,7 @@ error[E0308]: mismatched types
--> $DIR/issue-66706.rs:2:5
|
LL | fn a() {
| -
help: try adding a return type: `-> [{integer}; _]`
| -
possibly return type missing here?
LL | [0; [|_: _ &_| ()].len()]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found array `[{integer}; _]`
...
...
@@ -44,7 +44,7 @@ error[E0308]: mismatched types
--> $DIR/issue-66706.rs:14:5
|
LL | fn c() {
| -
help: try adding a return type: `-> [{integer}; _]`
| -
possibly return type missing here?
LL | [0; [|&_: _ &_| {}; 0 ].len()]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found array `[{integer}; _]`
...
...
@@ -52,7 +52,7 @@ error[E0308]: mismatched types
--> $DIR/issue-66706.rs:20:5
|
LL | fn d() {
| -
help: try adding a return type: `-> [{integer}; _]`
| -
possibly return type missing here?
LL | [0; match [|f @ &ref _| () ] {} ]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found array `[{integer}; _]`
...
...
src/test/ui/issues/issue-72574-1.stderr
浏览文件 @
f29fb479
...
...
@@ -21,8 +21,6 @@ LL | (_a, _x @ ..) => {}
error[E0308]: mismatched types
--> $DIR/issue-72574-1.rs:4:9
|
LL | match x {
| - this expression has type `({integer}, {integer}, {integer})`
LL | (_a, _x @ ..) => {}
| ^^^^^^^^^^^^^ expected a tuple with 3 elements, found one with 2 elements
|
...
...
src/test/ui/mismatched_types/E0409.stderr
浏览文件 @
f29fb479
...
...
@@ -9,8 +9,6 @@ LL | (0, ref y) | (y, 0) => {}
error[E0308]: mismatched types
--> $DIR/E0409.rs:5:23
|
LL | match x {
| - this expression has type `({integer}, {integer})`
LL | (0, ref y) | (y, 0) => {}
| ----- ^ expected `&{integer}`, found integer
| |
...
...
src/test/ui/mut/mut-pattern-mismatched.stderr
浏览文件 @
f29fb479
...
...
@@ -3,9 +3,6 @@ error[E0308]: mismatched types
|
LL | let &_
| ^^ types differ in mutability
...
LL | = foo;
| --- this expression has type `&mut {integer}`
|
= note: expected mutable reference `&mut {integer}`
found reference `&_`
...
...
@@ -15,9 +12,6 @@ error[E0308]: mismatched types
|
LL | let &mut _
| ^^^^^^ types differ in mutability
...
LL | = bar;
| --- this expression has type `&{integer}`
|
= note: expected reference `&{integer}`
found mutable reference `&mut _`
...
...
src/test/ui/never_type/diverging-tuple-parts-39485.stderr
浏览文件 @
f29fb479
error[E0308]: mismatched types
--> $DIR/diverging-tuple-parts-39485.rs:8:5
|
LL | fn g() {
| - possibly return type missing here?
LL | &panic!()
| ^^^^^^^^^ expected `()`, found reference
|
= note: expected unit type `()`
found reference `&_`
help: try adding a return type
|
LL | fn g() -> &_ {
| +++++
help: consider removing the borrow
|
LL - &panic!()
...
...
src/test/ui/or-patterns/already-bound-name.stderr
浏览文件 @
f29fb479
...
...
@@ -86,9 +86,8 @@ error[E0308]: mismatched types
--> $DIR/already-bound-name.rs:30:32
|
LL | let (B(A(a, _) | B(a)) | A(a, A(a, _) | B(a))) = B(B(1));
| - ^ ------- this expression has type `E<E<{integer}>>`
| | |
| | expected integer, found enum `E`
| - ^ expected integer, found enum `E`
| |
| first introduced with type `{integer}` here
|
= note: expected type `{integer}`
...
...
src/test/ui/or-patterns/inconsistent-modes.stderr
浏览文件 @
f29fb479
...
...
@@ -65,9 +65,8 @@ error[E0308]: mismatched types
--> $DIR/inconsistent-modes.rs:13:32
|
LL | let (Ok((ref a, b)) | Err((ref mut a, ref b))) = Ok((0, &0));
| ----- ^^^^^^^^^ ----------- this expression has type `Result<({integer}, &{integer}), (_, _)>`
| | |
| | types differ in mutability
| ----- ^^^^^^^^^ types differ in mutability
| |
| first introduced with type `&{integer}` here
|
= note: expected type `&{integer}`
...
...
src/test/ui/pattern/issue-74702.stderr
浏览文件 @
f29fb479
...
...
@@ -22,9 +22,7 @@ error[E0308]: mismatched types
--> $DIR/issue-74702.rs:2:9
|
LL | let (foo @ ..,) = (0, 0);
| ^^^^^^^^^^^ ------ this expression has type `({integer}, {integer})`
| |
| expected a tuple with 2 elements, found one with 1 element
| ^^^^^^^^^^^ expected a tuple with 2 elements, found one with 1 element
|
= note: expected tuple `({integer}, {integer})`
found tuple `(_,)`
...
...
src/test/ui/pattern/pat-tuple-overfield.stderr
浏览文件 @
f29fb479
...
...
@@ -150,8 +150,6 @@ LL | E1::Z0 => {}
error[E0308]: mismatched types
--> $DIR/pat-tuple-overfield.rs:19:9
|
LL | match (1, 2, 3) {
| --------- this expression has type `({integer}, {integer}, {integer})`
LL | (1, 2, 3, 4) => {}
| ^^^^^^^^^^^^ expected a tuple with 3 elements, found one with 4 elements
|
...
...
@@ -161,9 +159,6 @@ LL | (1, 2, 3, 4) => {}
error[E0308]: mismatched types
--> $DIR/pat-tuple-overfield.rs:20:9
|
LL | match (1, 2, 3) {
| --------- this expression has type `({integer}, {integer}, {integer})`
LL | (1, 2, 3, 4) => {}
LL | (1, 2, .., 3, 4) => {}
| ^^^^^^^^^^^^^^^^ expected a tuple with 3 elements, found one with 4 elements
|
...
...
src/test/ui/return/return-type.stderr
浏览文件 @
f29fb479
error[E0308]: mismatched types
--> $DIR/return-type.rs:10:5
|
LL | fn bar() {
| - possibly return type missing here?
LL | foo(4 as usize)
| ^^^^^^^^^^^^^^^ expected `()`, found struct `S`
| ^^^^^^^^^^^^^^^- help: consider using a semicolon here: `;`
| |
| expected `()`, found struct `S`
|
= note: expected unit type `()`
found struct `S<usize>`
help: consider using a semicolon here
|
LL | foo(4 as usize);
| +
help: try adding a return type
|
LL | fn bar() -> S<usize> {
| +++++++++++
error: aborting due to previous error
...
...
src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr
浏览文件 @
f29fb479
...
...
@@ -644,7 +644,9 @@ error[E0308]: mismatched types
--> $DIR/disallowed-positions.rs:76:12
|
LL | if let Range { start: F, end } = F..|| true {}
| ^^^^^^^^^^^^^^^^^^^^^^^ expected fn pointer, found struct `std::ops::Range`
| ^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `fn() -> bool`
| |
| expected fn pointer, found struct `std::ops::Range`
|
= note: expected fn pointer `fn() -> bool`
found struct `std::ops::Range<_>`
...
...
@@ -832,7 +834,9 @@ error[E0308]: mismatched types
--> $DIR/disallowed-positions.rs:140:15
|
LL | while let Range { start: F, end } = F..|| true {}
| ^^^^^^^^^^^^^^^^^^^^^^^ expected fn pointer, found struct `std::ops::Range`
| ^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `fn() -> bool`
| |
| expected fn pointer, found struct `std::ops::Range`
|
= note: expected fn pointer `fn() -> bool`
found struct `std::ops::Range<_>`
...
...
src/test/ui/slightly-nice-generic-literal-messages.stderr
浏览文件 @
f29fb479
error[E0308]: mismatched types
--> $DIR/slightly-nice-generic-literal-messages.rs:7:9
|
LL | match Foo(1.1, marker::PhantomData) {
| ----------------------------- this expression has type `Foo<{float}, _>`
LL | 1 => {}
| ^ expected struct `Foo`, found integer
|
...
...
src/test/ui/structs/structure-constructor-type-mismatch.stderr
浏览文件 @
f29fb479
...
...
@@ -101,8 +101,6 @@ LL | type PointF = Point<f32>;
error[E0308]: mismatched types
--> $DIR/structure-constructor-type-mismatch.rs:54:9
|
LL | match (Point { x: 1, y: 2 }) {
| ---------------------- this expression has type `Point<{integer}>`
LL | PointF::<u32> { .. } => {}
| ^^^^^^^^^^^^^^^^^^^^ expected integer, found `f32`
|
...
...
@@ -112,8 +110,6 @@ LL | PointF::<u32> { .. } => {}
error[E0308]: mismatched types
--> $DIR/structure-constructor-type-mismatch.rs:59:9
|
LL | match (Point { x: 1, y: 2 }) {
| ---------------------- this expression has type `Point<{integer}>`
LL | PointF { .. } => {}
| ^^^^^^^^^^^^^ expected integer, found `f32`
|
...
...
@@ -123,8 +119,6 @@ LL | PointF { .. } => {}
error[E0308]: mismatched types
--> $DIR/structure-constructor-type-mismatch.rs:67:9
|
LL | match (Pair { x: 1, y: 2 }) {
| --------------------- this expression has type `Pair<{integer}, {integer}>`
LL | PairF::<u32> { .. } => {}
| ^^^^^^^^^^^^^^^^^^^ expected integer, found `f32`
|
...
...
src/test/ui/typeck/issue-57673-ice-on-deref-of-boxed-trait.stderr
浏览文件 @
f29fb479
...
...
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/issue-57673-ice-on-deref-of-boxed-trait.rs:5:5
|
LL | fn ice(x: Box<dyn Iterator<Item=()>>) {
| -
possibly return type missing here?
| -
help: try adding a return type: `-> (dyn Iterator<Item = ()> + 'static)`
LL | *x
| ^^ expected `()`, found trait object `dyn Iterator`
|
...
...
src/test/ui/typeck/issue-91334.stderr
浏览文件 @
f29fb479
...
...
@@ -40,7 +40,7 @@ error[E0308]: mismatched types
LL | fn f(){||yield(((){),
| -^^^^^^^^^^^^^^^ expected `()`, found generator
| |
|
help: try adding a return type: `-> [generator@$DIR/issue-91334.rs:10:8: 10:23]`
|
possibly return type missing here?
|
= note: expected unit type `()`
found generator `[generator@$DIR/issue-91334.rs:10:8: 10:23]`
...
...
src/test/ui/typeck/return_type_containing_closure.rs
0 → 100644
浏览文件 @
f29fb479
#[allow(unused)]
fn
foo
()
{
//~^ NOTE possibly return type missing here?
vec!
[
'a'
]
.iter
()
.map
(|
c
|
c
)
//~^ ERROR mismatched types [E0308]
//~| NOTE expected `()`, found struct `Map`
//~| NOTE expected unit type `()`
}
fn
main
()
{}
src/test/ui/typeck/return_type_containing_closure.stderr
0 → 100644
浏览文件 @
f29fb479
error[E0308]: mismatched types
--> $DIR/return_type_containing_closure.rs:4:5
|
LL | fn foo() {
| - possibly return type missing here?
LL |
LL | vec!['a'].iter().map(|c| c)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^- help: consider using a semicolon here: `;`
| |
| expected `()`, found struct `Map`
|
= note: expected unit type `()`
found struct `Map<std::slice::Iter<'_, char>, [closure@$DIR/return_type_containing_closure.rs:4:26: 4:31]>`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录