mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 22:12:15 +00:00
fix: evaluate with wrong obligation stack
This commit is contained in:
parent
38b9655311
commit
204ba3224e
@ -1083,7 +1083,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
let mut nested_result = EvaluationResult::EvaluatedToOk;
|
||||
for obligation in nested_obligations {
|
||||
nested_result = cmp::max(
|
||||
this.evaluate_predicate_recursively(stack.list(), obligation)?,
|
||||
this.evaluate_predicate_recursively(previous_stack, obligation)?,
|
||||
nested_result,
|
||||
);
|
||||
}
|
||||
@ -1092,7 +1092,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
let obligation = obligation.with(this.tcx(), predicate);
|
||||
result = cmp::max(
|
||||
nested_result,
|
||||
this.evaluate_trait_predicate_recursively(stack.list(), obligation)?,
|
||||
this.evaluate_trait_predicate_recursively(previous_stack, obligation)?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
21
tests/ui/traits/unsend-future.rs
Normal file
21
tests/ui/traits/unsend-future.rs
Normal file
@ -0,0 +1,21 @@
|
||||
// edition:2021
|
||||
|
||||
// issue 108897
|
||||
trait Handler {}
|
||||
impl<F, Fut> Handler for F
|
||||
where
|
||||
Fut: Send,
|
||||
F: FnOnce() -> Fut,
|
||||
{}
|
||||
|
||||
fn require_handler<H: Handler>(h: H) {}
|
||||
|
||||
async fn handler() {
|
||||
let a = &1 as *const i32;
|
||||
async {}.await;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
require_handler(handler)
|
||||
//~^ ERROR future cannot be sent between threads safely
|
||||
}
|
24
tests/ui/traits/unsend-future.stderr
Normal file
24
tests/ui/traits/unsend-future.stderr
Normal file
@ -0,0 +1,24 @@
|
||||
error: future cannot be sent between threads safely
|
||||
--> $DIR/unsend-future.rs:19:21
|
||||
|
|
||||
LL | require_handler(handler)
|
||||
| ^^^^^^^ future returned by `handler` is not `Send`
|
||||
|
|
||||
= help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `*const i32`
|
||||
note: future is not `Send` as this value is used across an await
|
||||
--> $DIR/unsend-future.rs:15:13
|
||||
|
|
||||
LL | let a = &1 as *const i32;
|
||||
| - has type `*const i32` which is not `Send`
|
||||
LL | async {}.await;
|
||||
| ^^^^^^ await occurs here, with `a` maybe used later
|
||||
LL | }
|
||||
| - `a` is later dropped here
|
||||
note: required by a bound in `require_handler`
|
||||
--> $DIR/unsend-future.rs:11:23
|
||||
|
|
||||
LL | fn require_handler<H: Handler>(h: H) {}
|
||||
| ^^^^^^^ required by this bound in `require_handler`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
Loading…
Reference in New Issue
Block a user