Resolve partially resolved paths in struct patterns/expressions

Treat Def::Err correctly in struct patterns
Make instantiate_path and instantiate_type a bit closer to each other
This commit is contained in:
Vadim Petrochenkov 2016-06-11 18:47:47 +03:00
parent 49ea3d48a2
commit a397b60ebb
15 changed files with 156 additions and 206 deletions

View file

@ -67,21 +67,6 @@ pub fn pat_is_refutable(dm: &DefMap, pat: &hir::Pat) -> bool {
}
}
pub fn pat_is_variant_or_struct(dm: &DefMap, pat: &hir::Pat) -> bool {
match pat.node {
PatKind::TupleStruct(..) |
PatKind::Path(..) |
PatKind::Struct(..) => {
match dm.get(&pat.id).map(|d| d.full_def()) {
Some(Def::Variant(..)) | Some(Def::Struct(..)) |
Some(Def::TyAlias(..)) | Some(Def::AssociatedTy(..)) => true,
_ => false
}
}
_ => false
}
}
pub fn pat_is_const(dm: &DefMap, pat: &hir::Pat) -> bool {
match pat.node {
PatKind::Path(..) | PatKind::QPath(..) => {