Skip to content

Commit

Permalink
most things fail because too many types
Browse files Browse the repository at this point in the history
  • Loading branch information
mohe2015 committed Dec 23, 2023
1 parent a00308a commit cfaf0dd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 57 deletions.
2 changes: 1 addition & 1 deletion crates/hir-ty/src/chalk_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use chalk_solve::rust_ir::{self, OpaqueTyDatumBound, WellKnownTrait};

use base_db::CrateId;
use hir_def::{
hir::{Movability, CoroutineKind},
hir::Movability,
lang_item::{LangItem, LangItemTarget},
AssocItemId, BlockId, GenericDefId, HasModule, ItemContainerId, Lookup, TypeAliasId,
};
Expand Down
6 changes: 3 additions & 3 deletions crates/hir-ty/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ impl HirDisplay for Ty {
}
ImplTraitId::AsyncGenBlockTypeImplTrait(body, ..) => {
let future_trait = db
.lang_item(body.module(db.upcast()).krate(), LangItem::Future)
.lang_item(body.module(db.upcast()).krate(), LangItem::AsyncIterator)
.and_then(LangItemTarget::as_trait);
let output = future_trait.and_then(|t| {
db.trait_data(t).associated_type_by_name(&hir_expand::name!(Output))
Expand All @@ -1091,15 +1091,15 @@ impl HirDisplay for Ty {
if let Some(t) = future_trait {
f.start_location_link(t.into());
}
write!(f, "FIXME")?;
write!(f, "AsyncIterator")?;
if let Some(_) = future_trait {
f.end_location_link();
}
write!(f, "<")?;
if let Some(t) = output {
f.start_location_link(t.into());
}
write!(f, "Output")?;
write!(f, "Item")?;
if let Some(_) = output {
f.end_location_link();
}
Expand Down
1 change: 0 additions & 1 deletion crates/hir-ty/src/infer/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,6 @@ impl InferenceContext<'_> {
Expr::Closure { .. } => {
let ty = self.expr_ty(tgt_expr);
let TyKind::Closure(id, _) = ty.kind(Interner) else {
never!("closure type is always closure");
return;
};
let (captures, _) =
Expand Down
48 changes: 0 additions & 48 deletions crates/hir-ty/src/infer/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -963,54 +963,6 @@ impl InferenceContext<'_> {
ty
}

fn infer_async_block(
&mut self,
tgt_expr: ExprId,
id: &Option<BlockId>,
statements: &[Statement],
tail: &Option<ExprId>,
) -> Ty {
let ret_ty = self.table.new_type_var();
let prev_diverges = mem::replace(&mut self.diverges, Diverges::Maybe);
let prev_ret_ty = mem::replace(&mut self.return_ty, ret_ty.clone());
let prev_ret_coercion =
mem::replace(&mut self.return_coercion, Some(CoerceMany::new(ret_ty.clone())));

let (_, inner_ty) = self.with_breakable_ctx(BreakableKind::Border, None, None, |this| {
this.infer_block(tgt_expr, *id, statements, *tail, None, &Expectation::has_type(ret_ty))
});

self.diverges = prev_diverges;
self.return_ty = prev_ret_ty;
self.return_coercion = prev_ret_coercion;

self.lower_async_block_type_impl_trait(inner_ty, tgt_expr)
}

fn infer_async_gen_block(
&mut self,
tgt_expr: ExprId,
id: &Option<BlockId>,
statements: &[Statement],
tail: &Option<ExprId>,
) -> Ty {
let ret_ty = self.table.new_type_var();
let prev_diverges = mem::replace(&mut self.diverges, Diverges::Maybe);
let prev_ret_ty = mem::replace(&mut self.return_ty, ret_ty.clone());
let prev_ret_coercion =
mem::replace(&mut self.return_coercion, Some(CoerceMany::new(ret_ty.clone())));

let (_, inner_ty) = self.with_breakable_ctx(BreakableKind::Border, None, None, |this| {
this.infer_block(tgt_expr, *id, statements, *tail, None, &Expectation::has_type(ret_ty))
});

self.diverges = prev_diverges;
self.return_ty = prev_ret_ty;
self.return_coercion = prev_ret_coercion;

self.lower_async_gen_block_type_impl_trait(inner_ty, tgt_expr)
}

pub(crate) fn lower_async_block_type_impl_trait(
&mut self,
inner_ty: Ty,
Expand Down
8 changes: 4 additions & 4 deletions crates/hir-ty/src/tests/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2087,8 +2087,8 @@ fn test() {
32..33 'v': i64
40..42 '{}': ()
53..236 '{ ... } }': ()
63..68 'mut g': impl Iterator<Item = i64>
71..157 'gen { ... }': impl Iterator<Item = i64>
63..68 'mut g': impl AsyncIterator<Item = i64>
71..157 'gen { ... }': impl AsyncIterator<Item = i64>
89..90 'a': ()
93..100 'yield 0': ()
99..100 '0': i64
Expand All @@ -2099,7 +2099,7 @@ fn test() {
143..150 'yield 2': ()
149..150 '2': i64
164..234 'match ... }': ()
170..171 'g': impl Iterator<Item = i64>
170..171 'g': impl AsyncIterator<Item = i64>
170..178 'g.next()': Option<i64>
189..196 'Some(y)': Option<i64>
194..195 'y': i64
Expand Down Expand Up @@ -2185,7 +2185,7 @@ fn async_gen_yield_return_unit() {
};
match g.poll_next(&mut context) {
Poll::Ready(1) => {} // wrong
Poll::Ready(()) => {} // FIXME test with 1 there I think this infers stuff it should not
Poll::Pending => {}
}
g
Expand Down

0 comments on commit cfaf0dd

Please sign in to comment.