mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 02:03:53 +00:00
Note closure kind mismatch cause
This commit is contained in:
parent
52e2065ed4
commit
70b29f7c2d
@ -860,8 +860,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err.emit();
|
err
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::PredicateKind::WellFormed(ty) => {
|
ty::PredicateKind::WellFormed(ty) => {
|
||||||
|
@ -8,6 +8,8 @@ LL | num += 1;
|
|||||||
...
|
...
|
||||||
LL | Box::new(closure)
|
LL | Box::new(closure)
|
||||||
| ----------------- the requirement to implement `Fn` derives from here
|
| ----------------- the requirement to implement `Fn` derives from here
|
||||||
|
|
|
||||||
|
= note: required for the cast from `[closure@$DIR/issue-26046-fn-mut.rs:4:19: 4:21]` to the object type `dyn Fn()`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@ LL | vec
|
|||||||
...
|
...
|
||||||
LL | Box::new(closure)
|
LL | Box::new(closure)
|
||||||
| ----------------- the requirement to implement `Fn` derives from here
|
| ----------------- the requirement to implement `Fn` derives from here
|
||||||
|
|
|
||||||
|
= note: required for the cast from `[closure@$DIR/issue-26046-fn-once.rs:4:19: 4:26]` to the object type `dyn Fn() -> Vec<u8>`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -7,7 +7,15 @@ LL | let [_, _s] = s;
|
|||||||
| - closure is `FnOnce` because it moves the variable `s` out of its environment
|
| - closure is `FnOnce` because it moves the variable `s` out of its environment
|
||||||
LL | };
|
LL | };
|
||||||
LL | expect_fn(c);
|
LL | expect_fn(c);
|
||||||
| - the requirement to implement `Fn` derives from here
|
| --------- - the requirement to implement `Fn` derives from here
|
||||||
|
| |
|
||||||
|
| required by a bound introduced by this call
|
||||||
|
|
|
||||||
|
note: required by a bound in `expect_fn`
|
||||||
|
--> $DIR/closure-origin-array-diagnostics.rs:5:17
|
||||||
|
|
|
||||||
|
LL | fn expect_fn<F: Fn()>(_f: F) {}
|
||||||
|
| ^^^^ required by this bound in `expect_fn`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -7,7 +7,15 @@ LL | let s = s.1;
|
|||||||
| --- closure is `FnOnce` because it moves the variable `s.1` out of its environment
|
| --- closure is `FnOnce` because it moves the variable `s.1` out of its environment
|
||||||
LL | };
|
LL | };
|
||||||
LL | expect_fn(c);
|
LL | expect_fn(c);
|
||||||
| - the requirement to implement `Fn` derives from here
|
| --------- - the requirement to implement `Fn` derives from here
|
||||||
|
| |
|
||||||
|
| required by a bound introduced by this call
|
||||||
|
|
|
||||||
|
note: required by a bound in `expect_fn`
|
||||||
|
--> $DIR/closure-origin-tuple-diagnostics.rs:5:17
|
||||||
|
|
|
||||||
|
LL | fn expect_fn<F: Fn()>(_f: F) {}
|
||||||
|
| ^^^^ required by this bound in `expect_fn`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -6,7 +6,15 @@ LL | let closure = |_| foo(x);
|
|||||||
| |
|
| |
|
||||||
| this closure implements `FnOnce`, not `Fn`
|
| this closure implements `FnOnce`, not `Fn`
|
||||||
LL | bar(closure);
|
LL | bar(closure);
|
||||||
| ------- the requirement to implement `Fn` derives from here
|
| --- ------- the requirement to implement `Fn` derives from here
|
||||||
|
| |
|
||||||
|
| required by a bound introduced by this call
|
||||||
|
|
|
||||||
|
note: required by a bound in `bar`
|
||||||
|
--> $DIR/closure-wrong-kind.rs:6:11
|
||||||
|
|
|
||||||
|
LL | fn bar<T: Fn(u32)>(_: T) {}
|
||||||
|
| ^^^^^^^ required by this bound in `bar`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -7,7 +7,15 @@ LL | farewell.push_str("!!!");
|
|||||||
| -------- closure is `FnMut` because it mutates the variable `farewell` here
|
| -------- closure is `FnMut` because it mutates the variable `farewell` here
|
||||||
...
|
...
|
||||||
LL | apply(diary);
|
LL | apply(diary);
|
||||||
| ----- the requirement to implement `Fn` derives from here
|
| ----- ----- the requirement to implement `Fn` derives from here
|
||||||
|
| |
|
||||||
|
| required by a bound introduced by this call
|
||||||
|
|
|
||||||
|
note: required by a bound in `apply`
|
||||||
|
--> $DIR/issue-34349.rs:11:32
|
||||||
|
|
|
||||||
|
LL | fn apply<F>(f: F) where F: Fn() {
|
||||||
|
| ^^^^ required by this bound in `apply`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -8,7 +8,15 @@ LL | drop::<U>(_x1);
|
|||||||
| --- closure is `FnOnce` because it moves the variable `_x1` out of its environment
|
| --- closure is `FnOnce` because it moves the variable `_x1` out of its environment
|
||||||
...
|
...
|
||||||
LL | accept_fn_mut(&c1);
|
LL | accept_fn_mut(&c1);
|
||||||
| --- the requirement to implement `FnMut` derives from here
|
| ------------- --- the requirement to implement `FnMut` derives from here
|
||||||
|
| |
|
||||||
|
| required by a bound introduced by this call
|
||||||
|
|
|
||||||
|
note: required by a bound in `accept_fn_mut`
|
||||||
|
--> $DIR/move-ref-patterns-closure-captures.rs:4:31
|
||||||
|
|
|
||||||
|
LL | fn accept_fn_mut(_: &impl FnMut()) {}
|
||||||
|
| ^^^^^^^ required by this bound in `accept_fn_mut`
|
||||||
|
|
||||||
error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnOnce`
|
error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnOnce`
|
||||||
--> $DIR/move-ref-patterns-closure-captures.rs:9:14
|
--> $DIR/move-ref-patterns-closure-captures.rs:9:14
|
||||||
@ -20,7 +28,15 @@ LL | drop::<U>(_x1);
|
|||||||
| --- closure is `FnOnce` because it moves the variable `_x1` out of its environment
|
| --- closure is `FnOnce` because it moves the variable `_x1` out of its environment
|
||||||
...
|
...
|
||||||
LL | accept_fn(&c1);
|
LL | accept_fn(&c1);
|
||||||
| --- the requirement to implement `Fn` derives from here
|
| --------- --- the requirement to implement `Fn` derives from here
|
||||||
|
| |
|
||||||
|
| required by a bound introduced by this call
|
||||||
|
|
|
||||||
|
note: required by a bound in `accept_fn`
|
||||||
|
--> $DIR/move-ref-patterns-closure-captures.rs:5:27
|
||||||
|
|
|
||||||
|
LL | fn accept_fn(_: &impl Fn()) {}
|
||||||
|
| ^^^^ required by this bound in `accept_fn`
|
||||||
|
|
||||||
error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnMut`
|
error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnMut`
|
||||||
--> $DIR/move-ref-patterns-closure-captures.rs:20:14
|
--> $DIR/move-ref-patterns-closure-captures.rs:20:14
|
||||||
@ -32,7 +48,15 @@ LL | drop::<&mut U>(_x2);
|
|||||||
| --- closure is `FnMut` because it mutates the variable `_x2` here
|
| --- closure is `FnMut` because it mutates the variable `_x2` here
|
||||||
...
|
...
|
||||||
LL | accept_fn(&c2);
|
LL | accept_fn(&c2);
|
||||||
| --- the requirement to implement `Fn` derives from here
|
| --------- --- the requirement to implement `Fn` derives from here
|
||||||
|
| |
|
||||||
|
| required by a bound introduced by this call
|
||||||
|
|
|
||||||
|
note: required by a bound in `accept_fn`
|
||||||
|
--> $DIR/move-ref-patterns-closure-captures.rs:5:27
|
||||||
|
|
|
||||||
|
LL | fn accept_fn(_: &impl Fn()) {}
|
||||||
|
| ^^^^ required by this bound in `accept_fn`
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
@ -6,7 +6,17 @@ LL | let c = || drop(y.0);
|
|||||||
| |
|
| |
|
||||||
| this closure implements `FnOnce`, not `Fn`
|
| this closure implements `FnOnce`, not `Fn`
|
||||||
LL | foo(c);
|
LL | foo(c);
|
||||||
| - the requirement to implement `Fn` derives from here
|
| --- - the requirement to implement `Fn` derives from here
|
||||||
|
| |
|
||||||
|
| required by a bound introduced by this call
|
||||||
|
|
|
||||||
|
note: required by a bound in `foo`
|
||||||
|
--> $DIR/unboxed-closures-infer-fn-once-move-from-projection.rs:4:14
|
||||||
|
|
|
||||||
|
LL | fn foo<F>(f: F)
|
||||||
|
| --- required by a bound in this
|
||||||
|
LL | where F: Fn()
|
||||||
|
| ^^^^ required by this bound in `foo`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user