-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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 #104753 - compiler-errors:drop-tracking-var-ice, r=ol…
…i-obk Pass `InferCtxt` to `DropRangeVisitor` so we can resolve vars The types that we encounter in the `TypeckResults` that we pass to the `DropRangeVisitor` are not yet fully resolved, since that only happens in writeback after type checking is complete. Instead, pass down the whole `InferCtxt` so that we can resolve any inference vars that have been constrained since they were written into the results. This is similar to how the `MemCategorizationContext` in the `ExprUseVisitor` also needs to pass down both typeck results _and_ the inference context. Fixes an ICE mentioned in this comment: #104382 (comment)
- Loading branch information
Showing
4 changed files
with
211 additions
and
24 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
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
106 changes: 106 additions & 0 deletions
106
src/test/ui/async-await/drop-tracking-unresolved-typeck-results.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,106 @@ | ||
// compile-flags: -Zdrop-tracking | ||
// incremental | ||
// edition: 2021 | ||
|
||
use std::future::*; | ||
use std::marker::PhantomData; | ||
use std::pin::Pin; | ||
use std::task::*; | ||
|
||
fn send<T: Send>(_: T) {} | ||
|
||
pub trait Stream { | ||
type Item; | ||
|
||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>; | ||
} | ||
|
||
struct Empty<T>(PhantomData<fn() -> T>); | ||
|
||
impl<T> Stream for Empty<T> { | ||
type Item = T; | ||
|
||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { | ||
todo!() | ||
} | ||
} | ||
|
||
pub trait FnOnce1<A> { | ||
type Output; | ||
fn call_once(self, arg: A) -> Self::Output; | ||
} | ||
|
||
impl<T, A, R> FnOnce1<A> for T | ||
where | ||
T: FnOnce(A) -> R, | ||
{ | ||
type Output = R; | ||
fn call_once(self, arg: A) -> R { | ||
self(arg) | ||
} | ||
} | ||
|
||
pub trait FnMut1<A>: FnOnce1<A> { | ||
fn call_mut(&mut self, arg: A) -> Self::Output; | ||
} | ||
|
||
impl<T, A, R> FnMut1<A> for T | ||
where | ||
T: FnMut(A) -> R, | ||
{ | ||
fn call_mut(&mut self, arg: A) -> R { | ||
self(arg) | ||
} | ||
} | ||
|
||
struct Map<St, F>(St, F); | ||
|
||
impl<St, F> Stream for Map<St, F> | ||
where | ||
St: Stream, | ||
F: FnMut1<St::Item>, | ||
{ | ||
type Item = F::Output; | ||
|
||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { | ||
todo!() | ||
} | ||
} | ||
|
||
struct FuturesOrdered<T: Future>(PhantomData<fn() -> T::Output>); | ||
|
||
pub struct Buffered<St: Stream>(St, FuturesOrdered<St::Item>, usize) | ||
where | ||
St::Item: Future; | ||
|
||
impl<St> Stream for Buffered<St> | ||
where | ||
St: Stream, | ||
St::Item: Future, | ||
{ | ||
type Item = <St::Item as Future>::Output; | ||
|
||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { | ||
todo!() | ||
} | ||
} | ||
|
||
struct Next<'a, T: ?Sized>(&'a T); | ||
|
||
impl<St: ?Sized + Stream + Unpin> Future for Next<'_, St> { | ||
type Output = Option<St::Item>; | ||
|
||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { | ||
todo!() | ||
} | ||
} | ||
|
||
fn main() { | ||
send(async { | ||
//~^ ERROR implementation of `FnOnce` is not general enough | ||
//~| ERROR implementation of `FnOnce` is not general enough | ||
//~| ERROR implementation of `FnOnce` is not general enough | ||
//~| ERROR implementation of `FnOnce` is not general enough | ||
Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await | ||
}); | ||
} |
62 changes: 62 additions & 0 deletions
62
src/test/ui/async-await/drop-tracking-unresolved-typeck-results.stderr
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,62 @@ | ||
error: implementation of `FnOnce` is not general enough | ||
--> $DIR/drop-tracking-unresolved-typeck-results.rs:99:5 | ||
| | ||
LL | / send(async { | ||
LL | | | ||
LL | | | ||
LL | | | ||
LL | | | ||
LL | | Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await | ||
LL | | }); | ||
| |______^ implementation of `FnOnce` is not general enough | ||
| | ||
= note: `fn(&'0 ()) -> std::future::Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... | ||
= note: ...but it actually implements `FnOnce<(&(),)>` | ||
|
||
error: implementation of `FnOnce` is not general enough | ||
--> $DIR/drop-tracking-unresolved-typeck-results.rs:99:5 | ||
| | ||
LL | / send(async { | ||
LL | | | ||
LL | | | ||
LL | | | ||
LL | | | ||
LL | | Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await | ||
LL | | }); | ||
| |______^ implementation of `FnOnce` is not general enough | ||
| | ||
= note: `fn(&'0 ()) -> std::future::Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... | ||
= note: ...but it actually implements `FnOnce<(&(),)>` | ||
|
||
error: implementation of `FnOnce` is not general enough | ||
--> $DIR/drop-tracking-unresolved-typeck-results.rs:99:5 | ||
| | ||
LL | / send(async { | ||
LL | | | ||
LL | | | ||
LL | | | ||
LL | | | ||
LL | | Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await | ||
LL | | }); | ||
| |______^ implementation of `FnOnce` is not general enough | ||
| | ||
= note: `fn(&'0 ()) -> std::future::Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... | ||
= note: ...but it actually implements `FnOnce<(&(),)>` | ||
|
||
error: implementation of `FnOnce` is not general enough | ||
--> $DIR/drop-tracking-unresolved-typeck-results.rs:99:5 | ||
| | ||
LL | / send(async { | ||
LL | | | ||
LL | | | ||
LL | | | ||
LL | | | ||
LL | | Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await | ||
LL | | }); | ||
| |______^ implementation of `FnOnce` is not general enough | ||
| | ||
= note: `fn(&'0 ()) -> std::future::Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... | ||
= note: ...but it actually implements `FnOnce<(&(),)>` | ||
|
||
error: aborting due to 4 previous errors | ||
|