Add more tests, refactor array lengths/consteval work

Fix #2922: add unknown length as a condition for a type having unknown.

Incorporate reviews:

* Extract some of the const evaluation workings into functions
* Add fixmes on the hacks
* Add tests for impls on specific array lengths (these work!!! 😁)
* Add tests for const generics (indeed we don't support it yet)
This commit is contained in:
Jade 2021-05-14 00:59:30 -07:00
parent 32c600664e
commit 78d6b88f21
8 changed files with 223 additions and 35 deletions

View file

@ -52,7 +52,9 @@ use hir_def::{
};
use hir_expand::{diagnostics::DiagnosticSink, name::name, MacroDefKind};
use hir_ty::{
autoderef, could_unify,
autoderef,
consteval::ConstExtension,
could_unify,
method_resolution::{self, def_crates, TyFingerprint},
primitive::UintTy,
subst_prefix,
@ -1910,6 +1912,7 @@ impl Type {
substs.iter(&Interner).filter_map(|a| a.ty(&Interner)).any(go)
}
TyKind::Array(_ty, len) if len.is_unknown() => true,
TyKind::Array(ty, _)
| TyKind::Slice(ty)
| TyKind::Raw(_, ty)