mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Infer types of nested RPITs
This commit is contained in:
parent
44cf8ef49a
commit
a584cb998f
5 changed files with 105 additions and 34 deletions
|
@ -232,6 +232,45 @@ fn return_position_impl_trait() {
|
|||
fn foo() -> (impl T, impl T, impl T) { (2i64, 5i32, 7i32) }
|
||||
foo()
|
||||
}
|
||||
size_and_align_expr! {
|
||||
minicore: iterators;
|
||||
stmts: []
|
||||
trait Tr {}
|
||||
impl Tr for i32 {}
|
||||
fn foo() -> impl Iterator<Item = impl Tr> {
|
||||
[1, 2, 3].into_iter()
|
||||
}
|
||||
let mut iter = foo();
|
||||
let item = iter.next();
|
||||
(iter, item)
|
||||
}
|
||||
size_and_align_expr! {
|
||||
minicore: future;
|
||||
stmts: []
|
||||
use core::{future::Future, task::{Poll, Context}, pin::pin};
|
||||
use std::{task::Wake, sync::Arc};
|
||||
trait Tr {}
|
||||
impl Tr for i32 {}
|
||||
async fn f() -> impl Tr {
|
||||
2
|
||||
}
|
||||
fn unwrap_fut<T>(inp: impl Future<Output = T>) -> Poll<T> {
|
||||
// In a normal test we could use `loop {}` or `panic!()` here,
|
||||
// but rustc actually runs this code.
|
||||
let pinned = pin!(inp);
|
||||
struct EmptyWaker;
|
||||
impl Wake for EmptyWaker {
|
||||
fn wake(self: Arc<Self>) {
|
||||
}
|
||||
}
|
||||
let waker = Arc::new(EmptyWaker).into();
|
||||
let mut context = Context::from_waker(&waker);
|
||||
let x = pinned.poll(&mut context);
|
||||
x
|
||||
}
|
||||
let x = unwrap_fut(f());
|
||||
x
|
||||
}
|
||||
size_and_align_expr! {
|
||||
struct Foo<T>(T, T, (T, T));
|
||||
trait T {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue