forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#87483 - oli-obk:tait_ice, r=lqd
Mir borrowck does not generate lifetime variables for 'static lifetimes during opaque type resolution Fixes rust-lang#87455 This situation was unreachable before rust-lang#87287 as we used to just grab the resolved opaque type from typeck and replaced all regions with new inference vars. After rust-lang#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).
- Loading branch information
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/test/ui/type-alias-impl-trait/issue-87455-static-lifetime-ice.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// check-pass | ||
|
||
use std::error::Error as StdError; | ||
use std::pin::Pin; | ||
use std::task::{Context, Poll}; | ||
|
||
pub trait Stream { | ||
type Item; | ||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>; | ||
fn size_hint(&self) -> (usize, Option<usize>) { | ||
(0, None) | ||
} | ||
} | ||
|
||
pub trait TryStream: Stream { | ||
type Ok; | ||
type Error; | ||
|
||
fn try_poll_next( | ||
self: Pin<&mut Self>, | ||
cx: &mut Context<'_>, | ||
) -> Poll<Option<Result<Self::Ok, Self::Error>>>; | ||
} | ||
|
||
impl<S, T, E> TryStream for S | ||
where | ||
S: ?Sized + Stream<Item = Result<T, E>>, | ||
{ | ||
type Ok = T; | ||
type Error = E; | ||
|
||
fn try_poll_next( | ||
self: Pin<&mut Self>, | ||
cx: &mut Context<'_>, | ||
) -> Poll<Option<Result<Self::Ok, Self::Error>>> { | ||
self.poll_next(cx) | ||
} | ||
} | ||
|
||
pub trait ServerSentEvent: Sized + Send + Sync + 'static {} | ||
|
||
impl<T: Send + Sync + 'static> ServerSentEvent for T {} | ||
|
||
struct SseKeepAlive<S> { | ||
event_stream: S, | ||
} | ||
|
||
struct SseComment<T>(T); | ||
|
||
impl<S> Stream for SseKeepAlive<S> | ||
where | ||
S: TryStream + Send + 'static, | ||
S::Ok: ServerSentEvent, | ||
S::Error: StdError + Send + Sync + 'static, | ||
{ | ||
type Item = Result<SseComment<&'static str>, ()>; | ||
fn poll_next(self: Pin<&mut Self>, _cx: &mut Context) -> Poll<Option<Self::Item>> { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
pub fn keep<S>( | ||
event_stream: S, | ||
) -> impl TryStream<Ok = impl ServerSentEvent + Send + 'static, Error = ()> + Send + 'static | ||
where | ||
S: TryStream + Send + 'static, | ||
S::Ok: ServerSentEvent + Send, | ||
S::Error: StdError + Send + Sync + 'static, | ||
{ | ||
SseKeepAlive { event_stream } | ||
} | ||
|
||
fn main() {} |