Skip to content

Commit f739552

Browse files
committed
Auto merge of #87483 - oli-obk:tait_ice, r=lqd
Mir borrowck does not generate lifetime variables for 'static lifetimes during opaque type resolution Fixes #87455 This situation was unreachable before #87287 as we used to just grab the resolved opaque type from typeck and replaced all regions with new inference vars. After #87287 we let the `InferCx` in mir borrowck figure out the opaque type all by itself (which it already did before, but it only used the result to sanity check with the typeck result).
2 parents fe1c942 + 2953a2f commit f739552

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

compiler/rustc_mir/src/borrow_check/region_infer/opaque_types.rs

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
8383
.and_then(|ur_vid| self.definitions[*ur_vid].external_name)
8484
.unwrap_or(infcx.tcx.lifetimes.re_root_empty),
8585
ty::ReLateBound(..) => region,
86+
ty::ReStatic => region,
8687
_ => {
8788
infcx.tcx.sess.delay_span_bug(
8889
span,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// check-pass
2+
3+
use std::error::Error as StdError;
4+
use std::pin::Pin;
5+
use std::task::{Context, Poll};
6+
7+
pub trait Stream {
8+
type Item;
9+
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>;
10+
fn size_hint(&self) -> (usize, Option<usize>) {
11+
(0, None)
12+
}
13+
}
14+
15+
pub trait TryStream: Stream {
16+
type Ok;
17+
type Error;
18+
19+
fn try_poll_next(
20+
self: Pin<&mut Self>,
21+
cx: &mut Context<'_>,
22+
) -> Poll<Option<Result<Self::Ok, Self::Error>>>;
23+
}
24+
25+
impl<S, T, E> TryStream for S
26+
where
27+
S: ?Sized + Stream<Item = Result<T, E>>,
28+
{
29+
type Ok = T;
30+
type Error = E;
31+
32+
fn try_poll_next(
33+
self: Pin<&mut Self>,
34+
cx: &mut Context<'_>,
35+
) -> Poll<Option<Result<Self::Ok, Self::Error>>> {
36+
self.poll_next(cx)
37+
}
38+
}
39+
40+
pub trait ServerSentEvent: Sized + Send + Sync + 'static {}
41+
42+
impl<T: Send + Sync + 'static> ServerSentEvent for T {}
43+
44+
struct SseKeepAlive<S> {
45+
event_stream: S,
46+
}
47+
48+
struct SseComment<T>(T);
49+
50+
impl<S> Stream for SseKeepAlive<S>
51+
where
52+
S: TryStream + Send + 'static,
53+
S::Ok: ServerSentEvent,
54+
S::Error: StdError + Send + Sync + 'static,
55+
{
56+
type Item = Result<SseComment<&'static str>, ()>;
57+
fn poll_next(self: Pin<&mut Self>, _cx: &mut Context) -> Poll<Option<Self::Item>> {
58+
unimplemented!()
59+
}
60+
}
61+
62+
pub fn keep<S>(
63+
event_stream: S,
64+
) -> impl TryStream<Ok = impl ServerSentEvent + Send + 'static, Error = ()> + Send + 'static
65+
where
66+
S: TryStream + Send + 'static,
67+
S::Ok: ServerSentEvent + Send,
68+
S::Error: StdError + Send + Sync + 'static,
69+
{
70+
SseKeepAlive { event_stream }
71+
}
72+
73+
fn main() {}

0 commit comments

Comments
 (0)