You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Switch #[track_caller] back to a no-op unless feature gate is enabled
This patch fixes a regression, in which `#[track_caller]`, which was
previously a no-op, was changed to actually turn on the behavior. This
should instead only happen behind the `closure_track_caller` feature
gate.
Also, add a warning for the user to understand how their code will
compile depending on the feature gate being turned on or not.
Fixes#104588
/// A waker that wakes up the current thread when called.
13
+
structThreadWaker(Thread);
14
+
15
+
implWakeforThreadWaker{
16
+
fnwake(self:Arc<Self>){
17
+
self.0.unpark();
18
+
}
19
+
}
20
+
21
+
/// Run a future to completion on the current thread.
22
+
fnblock_on<T>(fut:implFuture<Output = T>) -> T{
23
+
// Pin the future so it can be polled.
24
+
letmut fut = Box::pin(fut);
25
+
26
+
// Create a new context to be passed to the future.
27
+
let t = thread::current();
28
+
let waker = Arc::new(ThreadWaker(t)).into();
29
+
letmut cx = Context::from_waker(&waker);
30
+
31
+
// Run the future to completion.
32
+
loop{
33
+
match fut.as_mut().poll(&mut cx){
34
+
Poll::Ready(res) => return res,
35
+
Poll::Pending => thread::park(),
36
+
}
37
+
}
38
+
}
39
+
40
+
asyncfnbar(){
41
+
panic!()
42
+
}
43
+
44
+
asyncfnfoo(){
45
+
bar().await
46
+
}
47
+
48
+
#[track_caller]//~ WARN `#[track_caller]` on async functions is a no-op, unless the `closure_track_caller` feature is enabled [ungated_async_fn_track_caller]
0 commit comments