mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
removed untyped typabledef
This commit is contained in:
parent
6a5a1f5902
commit
f3a37522a0
1 changed files with 3 additions and 26 deletions
|
@ -24,14 +24,13 @@ use std::ops::Index;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::{fmt, mem};
|
use std::{fmt, mem};
|
||||||
|
|
||||||
use log;
|
|
||||||
use ena::unify::{InPlaceUnificationTable, UnifyKey, UnifyValue, NoError};
|
use ena::unify::{InPlaceUnificationTable, UnifyKey, UnifyValue, NoError};
|
||||||
use ra_arena::map::ArenaMap;
|
use ra_arena::map::ArenaMap;
|
||||||
use join_to_string::join;
|
use join_to_string::join;
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Def, DefId, Module, Function, Struct, StructField, Enum, EnumVariant, Path, Name, ImplBlock,
|
Module, Function, Struct, StructField, Enum, EnumVariant, Path, Name, ImplBlock,
|
||||||
FnSignature, FnScopes, ModuleDef, Crate,
|
FnSignature, FnScopes, ModuleDef, Crate,
|
||||||
db::HirDatabase,
|
db::HirDatabase,
|
||||||
type_ref::{TypeRef, Mutability},
|
type_ref::{TypeRef, Mutability},
|
||||||
|
@ -447,10 +446,6 @@ impl Ty {
|
||||||
};
|
};
|
||||||
(var.parent_enum(db).generic_params(db), segment)
|
(var.parent_enum(db).generic_params(db), segment)
|
||||||
}
|
}
|
||||||
TypableDef::Def(def_id) => match def_id.resolve(db) {
|
|
||||||
Def::Trait(t) => (t.generic_params(db), last),
|
|
||||||
_ => return Substs::empty(),
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
// substs_from_path
|
// substs_from_path
|
||||||
if let Some(generic_args) = &segment.args_and_bindings {
|
if let Some(generic_args) = &segment.args_and_bindings {
|
||||||
|
@ -688,25 +683,17 @@ pub enum TypableDef {
|
||||||
Struct(Struct),
|
Struct(Struct),
|
||||||
Enum(Enum),
|
Enum(Enum),
|
||||||
EnumVariant(EnumVariant),
|
EnumVariant(EnumVariant),
|
||||||
Def(DefId),
|
|
||||||
}
|
}
|
||||||
impl_froms!(TypableDef: Function, Struct, Enum, EnumVariant);
|
impl_froms!(TypableDef: Function, Struct, Enum, EnumVariant);
|
||||||
|
|
||||||
impl From<DefId> for TypableDef {
|
|
||||||
fn from(func: DefId) -> TypableDef {
|
|
||||||
TypableDef::Def(func)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<ModuleDef> for Option<TypableDef> {
|
impl From<ModuleDef> for Option<TypableDef> {
|
||||||
fn from(def: ModuleDef) -> Option<TypableDef> {
|
fn from(def: ModuleDef) -> Option<TypableDef> {
|
||||||
let res = match def {
|
let res = match def {
|
||||||
ModuleDef::Def(r) => r.into(),
|
|
||||||
ModuleDef::Function(f) => f.into(),
|
ModuleDef::Function(f) => f.into(),
|
||||||
ModuleDef::Struct(s) => s.into(),
|
ModuleDef::Struct(s) => s.into(),
|
||||||
ModuleDef::Enum(e) => e.into(),
|
ModuleDef::Enum(e) => e.into(),
|
||||||
ModuleDef::EnumVariant(v) => v.into(),
|
ModuleDef::EnumVariant(v) => v.into(),
|
||||||
ModuleDef::Module(_) => return None,
|
ModuleDef::Def(_) | ModuleDef::Module(_) => return None,
|
||||||
};
|
};
|
||||||
Some(res)
|
Some(res)
|
||||||
}
|
}
|
||||||
|
@ -718,14 +705,6 @@ pub(super) fn type_for_def(db: &impl HirDatabase, def: TypableDef) -> Ty {
|
||||||
TypableDef::Struct(s) => type_for_struct(db, s),
|
TypableDef::Struct(s) => type_for_struct(db, s),
|
||||||
TypableDef::Enum(e) => type_for_enum(db, e),
|
TypableDef::Enum(e) => type_for_enum(db, e),
|
||||||
TypableDef::EnumVariant(v) => type_for_enum_variant(db, v),
|
TypableDef::EnumVariant(v) => type_for_enum_variant(db, v),
|
||||||
TypableDef::Def(def_id) => {
|
|
||||||
log::debug!(
|
|
||||||
"trying to get type for item of unknown type {:?} {:?}",
|
|
||||||
def_id,
|
|
||||||
def
|
|
||||||
);
|
|
||||||
Ty::Unknown
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1152,9 +1131,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
||||||
let ty = self.insert_type_vars(ty.apply_substs(substs));
|
let ty = self.insert_type_vars(ty.apply_substs(substs));
|
||||||
(ty, Some(var.into()))
|
(ty, Some(var.into()))
|
||||||
}
|
}
|
||||||
TypableDef::Def(_) | TypableDef::Enum(_) | TypableDef::Function(_) => {
|
TypableDef::Enum(_) | TypableDef::Function(_) => (Ty::Unknown, None),
|
||||||
(Ty::Unknown, None)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue