Skip to content
Permalink
Browse files

review comments

  • Loading branch information
estebank committed Dec 15, 2019
1 parent 9c0000c commit c55615155d161c8abb307db0019ab58545cd246b
@@ -1339,16 +1339,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
err.span_label(
*sp,
format!(
"{}this is {}the {} {}{}",
"{}the {} {}{}{}",
if count > 1 { "one of " } else { "" },
target,
key,
pluralize!(count),
if sp.is_desugaring(DesugaringKind::Async) {
"in the desugared `async fn`, "
" in the `Output` of this `async fn`"
} else {
""
},
if count > 1 { "one of" } else { "" },
target,
key,
pluralize!(count),
),
);
}
@@ -1364,18 +1364,24 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
ty::Opaque(..) => "opaque type",
_ => "",
};
match t.kind {
ty::Closure(def_id, _) | ty::Opaque(def_id, _) => {
let span = self.tcx.def_span(def_id);
debug!("note_type_err visit_ty {:?}", span.macro_backtrace());
if !self.ignore_span.overlaps(span)
&& !self.expected.values().any(|exp| exp.iter().any(|sp| *sp == span))
{
let entry = self.types.entry(kind).or_default();
entry.insert(span);
}
if let ty::Closure(def_id, _) | ty::Opaque(def_id, _) = t.kind {
let span = self.tcx.def_span(def_id);
// Avoid cluttering the output when the "found" and error span overlap:
//
// error[E0308]: mismatched types
// --> $DIR/issue-20862.rs:2:5
// |
// LL | |y| x + y
// | ^^^^^^^^^
// | |
// | the found closure
// | expected `()`, found closure
// |
// = note: expected unit type `()`
// found closure `[closure@$DIR/issue-20862.rs:2:5: 2:14 x:_]`
if !self.ignore_span.overlaps(span) {
self.types.entry(kind).or_default().insert(span);
}
_ => {}
}
t.super_visit_with(self)
}
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/dont-suggest-missing-await.rs:14:18
|
LL | async fn make_u32() -> u32 {
| --- in the desugared `async fn`, this is the found opaque type
| --- the found opaque type in the `Output` of this `async fn`
...
LL | take_u32(x)
| ^ expected `u32`, found opaque type
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/suggest-missing-await-closure.rs:16:18
|
LL | async fn make_u32() -> u32 {
| --- in the desugared `async fn`, this is the found opaque type
| --- the found opaque type in the `Output` of this `async fn`
...
LL | take_u32(x)
| ^
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/suggest-missing-await.rs:13:14
|
LL | async fn make_u32() -> u32 {
| --- in the desugared `async fn`, this is the found opaque type
| --- the found opaque type in the `Output` of this `async fn`
...
LL | take_u32(x)
| ^
@@ -16,6 +16,9 @@ LL | take_u32(x)
error[E0308]: mismatched types
--> $DIR/suggest-missing-await.rs:23:5
|
LL | async fn dummy() {}
| - the found opaque type in the `Output` of this `async fn`
...
LL | dummy()
| ^^^^^^^ expected `()`, found opaque type
|
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/closure-reform-bad.rs:11:15
|
LL | let f = |s: &str| println!("{}{}", s, string);
| ------------------------------------- this is the found closure
| ------------------------------------- the found closure
LL | call_bare(f)
| ^ expected fn pointer, found closure
|
@@ -1,6 +1,11 @@
error[E0308]: mismatched types
--> $DIR/extern-types-distinct-types.rs:9:5
|
LL | type A;
| ------- the found foreign type
LL | type B;
| ------- the expected foreign type
...
LL | r
| ^ expected extern type `B`, found extern type `A`
|
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/equality2.rs:25:18
|
LL | fn hide<T: Foo>(x: T) -> impl Foo {
| -------- this is the found opaque type
| -------- the found opaque type
...
LL | let _: u32 = hide(0_u32);
| --- ^^^^^^^^^^^ expected `u32`, found opaque type
@@ -16,7 +16,7 @@ error[E0308]: mismatched types
--> $DIR/equality2.rs:31:18
|
LL | fn hide<T: Foo>(x: T) -> impl Foo {
| -------- this is the found opaque type
| -------- the found opaque type
...
LL | let _: i32 = Leak::leak(hide(0_i32));
| --- ^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found associated type
@@ -32,7 +32,10 @@ error[E0308]: mismatched types
--> $DIR/equality2.rs:38:10
|
LL | fn hide<T: Foo>(x: T) -> impl Foo {
| -------- this is the expected opaque type
| --------
| |
| the expected opaque type
| the found opaque type
...
LL | x = (x.1,
| ^^^ expected `u32`, found `i32`
@@ -44,7 +47,10 @@ error[E0308]: mismatched types
--> $DIR/equality2.rs:41:10
|
LL | fn hide<T: Foo>(x: T) -> impl Foo {
| -------- this is the expected opaque type
| --------
| |
| the expected opaque type
| the found opaque type
...
LL | x.0);
| ^^^ expected `i32`, found `u32`
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/issue-24036.rs:3:9
|
LL | let mut x = |c| c + 1;
| --------- this is the expected closure
| --------- the expected closure
LL | x = |c| c + 1;
| ^^^^^^^^^ expected closure, found a different closure
|
@@ -236,7 +236,7 @@ error[E0308]: mismatched types
--> $DIR/fn-or-tuple-struct-without-args.rs:46:20
|
LL | let closure = || 42;
| ----- this is the found closure
| ----- the found closure
LL | let _: usize = closure;
| ----- ^^^^^^^
| | |
@@ -2,7 +2,7 @@ error[E0308]: `if` and `else` have incompatible types
--> $DIR/opaque-type-error.rs:20:9
|
LL | fn thing_two() -> impl Future<Output = Result<(), ()>> {
| ------------------------------------ this is the found opaque type
| ------------------------------------ the found opaque type
...
LL | / if true {
LL | | thing_one()
@@ -13,7 +13,7 @@ LL | let z: i32 = x;
| expected due to this
...
LL | type WrongGeneric<T> = impl 'static;
| ------------------------------------ this is the found opaque type
| ------------------------------------ the found opaque type
|
= note: expected type `i32`
found opaque type `WrongGeneric::<&{integer}>`
@@ -13,7 +13,7 @@ LL | let z: i32 = x;
| expected due to this
...
LL | type WrongGeneric<T> = impl 'static;
| ------------------------------------ this is the found opaque type
| ------------------------------------ the found opaque type
|
= note: expected type `i32`
found opaque type `WrongGeneric::<&{integer}>`
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/never_reveal_concrete_type.rs:13:27
|
LL | type NoReveal = impl std::fmt::Debug;
| ------------------------------------- this is the found opaque type
| ------------------------------------- the found opaque type
...
LL | let _: &'static str = x;
| ------------ ^ expected `&str`, found opaque type
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/no_revealing_outside_defining_module.rs:15:19
|
LL | pub type Boo = impl ::std::fmt::Debug;
| -------------------------------------- this is the found opaque type
| -------------------------------------- the found opaque type
...
LL | let _: &str = bomp();
| ---- ^^^^^^ expected `&str`, found opaque type
@@ -16,7 +16,7 @@ error[E0308]: mismatched types
--> $DIR/no_revealing_outside_defining_module.rs:19:5
|
LL | pub type Boo = impl ::std::fmt::Debug;
| -------------------------------------- this is the expected opaque type
| -------------------------------------- the expected opaque type
...
LL | fn bomp() -> boo::Boo {
| -------- expected `Boo` because of return type

0 comments on commit c556151

Please sign in to comment.
You can’t perform that action at this time.