1562: Continue support for .await r=matklad a=unrealhoang

- add await expr to ast and HIR Expr
- infer type for `.await`

Co-authored-by: Unreal Hoang <unrealhoang@gmail.com>
This commit is contained in:
bors[bot]
2019-07-20 11:27:50 +00:00
6 changed files with 121 additions and 1 deletions

View File

@@ -20,6 +20,41 @@ use crate::{
// against snapshots of the expected results using insta. Use cargo-insta to
// update the snapshots.
#[test]
fn infer_await() {
let (mut db, pos) = MockDatabase::with_position(
r#"
//- /main.rs
struct IntFuture;
impl Future for IntFuture {
type Output = u64;
}
fn test() {
let r = IntFuture;
let v = r.await;
v<|>;
}
//- /std.rs
#[prelude_import] use future::*;
mod future {
trait Future {
type Output;
}
}
"#,
);
db.set_crate_graph_from_fixture(crate_graph! {
"main": ("/main.rs", ["std"]),
"std": ("/std.rs", []),
});
assert_eq!("u64", type_at_pos(&db, pos));
}
#[test]
fn infer_try() {
let (mut db, pos) = MockDatabase::with_position(