mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-15 22:54:00 +00:00
hir_def::expr -> hir_def::hir, hir_def::type_ref -> hir_def::hir::type_ref
This commit is contained in:
parent
8e7c104b3a
commit
99b69525f4
33 changed files with 96 additions and 94 deletions
|
@ -25,7 +25,7 @@ use syntax::{ast, AstPtr, SyntaxNode, SyntaxNodePtr};
|
||||||
use crate::{
|
use crate::{
|
||||||
attr::Attrs,
|
attr::Attrs,
|
||||||
db::DefDatabase,
|
db::DefDatabase,
|
||||||
expr::{
|
hir::{
|
||||||
dummy_expr_id, Binding, BindingId, Expr, ExprId, Label, LabelId, Pat, PatId, RecordFieldPat,
|
dummy_expr_id, Binding, BindingId, Expr, ExprId, Label, LabelId, Pat, PatId, RecordFieldPat,
|
||||||
},
|
},
|
||||||
item_scope::BuiltinShadowMode,
|
item_scope::BuiltinShadowMode,
|
||||||
|
|
|
@ -33,7 +33,7 @@ use crate::{
|
||||||
builtin_type::{BuiltinFloat, BuiltinInt, BuiltinUint},
|
builtin_type::{BuiltinFloat, BuiltinInt, BuiltinUint},
|
||||||
data::adt::StructKind,
|
data::adt::StructKind,
|
||||||
db::DefDatabase,
|
db::DefDatabase,
|
||||||
expr::{
|
hir::{
|
||||||
dummy_expr_id, Array, Binding, BindingAnnotation, BindingId, ClosureKind, Expr, ExprId,
|
dummy_expr_id, Array, Binding, BindingAnnotation, BindingId, ClosureKind, Expr, ExprId,
|
||||||
FloatTypeWrapper, Label, LabelId, Literal, MatchArm, Movability, Pat, PatId,
|
FloatTypeWrapper, Label, LabelId, Literal, MatchArm, Movability, Pat, PatId,
|
||||||
RecordFieldPat, RecordLitField, Statement,
|
RecordFieldPat, RecordLitField, Statement,
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::fmt::{self, Write};
|
||||||
use syntax::ast::HasName;
|
use syntax::ast::HasName;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
expr::{Array, BindingAnnotation, BindingId, ClosureKind, Literal, Movability, Statement},
|
hir::{Array, BindingAnnotation, BindingId, ClosureKind, Literal, Movability, Statement},
|
||||||
pretty::{print_generic_args, print_path, print_type_ref},
|
pretty::{print_generic_args, print_path, print_type_ref},
|
||||||
type_ref::TypeRef,
|
type_ref::TypeRef,
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,7 +8,7 @@ use rustc_hash::FxHashMap;
|
||||||
use crate::{
|
use crate::{
|
||||||
body::Body,
|
body::Body,
|
||||||
db::DefDatabase,
|
db::DefDatabase,
|
||||||
expr::{Binding, BindingId, Expr, ExprId, LabelId, Pat, PatId, Statement},
|
hir::{Binding, BindingId, Expr, ExprId, LabelId, Pat, PatId, Statement},
|
||||||
BlockId, DefWithBodyId,
|
BlockId, DefWithBodyId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
//!
|
//!
|
||||||
//! See also a neighboring `body` module.
|
//! See also a neighboring `body` module.
|
||||||
|
|
||||||
|
pub mod type_ref;
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use hir_expand::name::Name;
|
use hir_expand::name::Name;
|
||||||
|
@ -28,10 +30,10 @@ use crate::{
|
||||||
|
|
||||||
pub use syntax::ast::{ArithOp, BinaryOp, CmpOp, LogicOp, Ordering, RangeOp, UnaryOp};
|
pub use syntax::ast::{ArithOp, BinaryOp, CmpOp, LogicOp, Ordering, RangeOp, UnaryOp};
|
||||||
|
|
||||||
pub type ExprId = Idx<Expr>;
|
|
||||||
|
|
||||||
pub type BindingId = Idx<Binding>;
|
pub type BindingId = Idx<Binding>;
|
||||||
|
|
||||||
|
pub type ExprId = Idx<Expr>;
|
||||||
|
|
||||||
/// FIXME: this is a hacky function which should be removed
|
/// FIXME: this is a hacky function which should be removed
|
||||||
pub(crate) fn dummy_expr_id() -> ExprId {
|
pub(crate) fn dummy_expr_id() -> ExprId {
|
||||||
ExprId::from_raw(RawIdx::from(u32::MAX))
|
ExprId::from_raw(RawIdx::from(u32::MAX))
|
|
@ -13,7 +13,7 @@ use syntax::ast::{self, HasName};
|
||||||
use crate::{
|
use crate::{
|
||||||
body::LowerCtx,
|
body::LowerCtx,
|
||||||
builtin_type::{BuiltinInt, BuiltinType, BuiltinUint},
|
builtin_type::{BuiltinInt, BuiltinType, BuiltinUint},
|
||||||
expr::Literal,
|
hir::Literal,
|
||||||
path::Path,
|
path::Path,
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,7 +18,6 @@ pub mod db;
|
||||||
|
|
||||||
pub mod attr;
|
pub mod attr;
|
||||||
pub mod path;
|
pub mod path;
|
||||||
pub mod type_ref;
|
|
||||||
pub mod builtin_type;
|
pub mod builtin_type;
|
||||||
pub mod builtin_attr;
|
pub mod builtin_attr;
|
||||||
pub mod per_ns;
|
pub mod per_ns;
|
||||||
|
@ -34,7 +33,8 @@ pub mod generics;
|
||||||
pub mod lang_item;
|
pub mod lang_item;
|
||||||
pub mod layout;
|
pub mod layout;
|
||||||
|
|
||||||
pub mod expr;
|
pub mod hir;
|
||||||
|
pub use self::hir::type_ref;
|
||||||
pub mod body;
|
pub mod body;
|
||||||
pub mod resolver;
|
pub mod resolver;
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@ use crate::{
|
||||||
body::scope::{ExprScopes, ScopeId},
|
body::scope::{ExprScopes, ScopeId},
|
||||||
builtin_type::BuiltinType,
|
builtin_type::BuiltinType,
|
||||||
db::DefDatabase,
|
db::DefDatabase,
|
||||||
expr::{BindingId, ExprId, LabelId},
|
|
||||||
generics::{GenericParams, TypeOrConstParamData},
|
generics::{GenericParams, TypeOrConstParamData},
|
||||||
|
hir::{BindingId, ExprId, LabelId},
|
||||||
item_scope::{BuiltinShadowMode, BUILTIN_SCOPE},
|
item_scope::{BuiltinShadowMode, BUILTIN_SCOPE},
|
||||||
lang_item::LangItemTarget,
|
lang_item::LangItemTarget,
|
||||||
nameres::DefMap,
|
nameres::DefMap,
|
||||||
|
|
|
@ -9,7 +9,7 @@ use chalk_solve::rust_ir::{self, OpaqueTyDatumBound, WellKnownTrait};
|
||||||
|
|
||||||
use base_db::CrateId;
|
use base_db::CrateId;
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
expr::Movability,
|
hir::Movability,
|
||||||
lang_item::{lang_attr, LangItem, LangItemTarget},
|
lang_item::{lang_attr, LangItem, LangItemTarget},
|
||||||
AssocItemId, BlockId, GenericDefId, HasModule, ItemContainerId, Lookup, TypeAliasId,
|
AssocItemId, BlockId, GenericDefId, HasModule, ItemContainerId, Lookup, TypeAliasId,
|
||||||
};
|
};
|
||||||
|
@ -415,8 +415,8 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
|
||||||
let input_output = crate::make_type_and_const_binders(it, input_output);
|
let input_output = crate::make_type_and_const_binders(it, input_output);
|
||||||
|
|
||||||
let movability = match self.db.body(parent)[expr] {
|
let movability = match self.db.body(parent)[expr] {
|
||||||
hir_def::expr::Expr::Closure {
|
hir_def::hir::Expr::Closure {
|
||||||
closure_kind: hir_def::expr::ClosureKind::Generator(movability),
|
closure_kind: hir_def::hir::ClosureKind::Generator(movability),
|
||||||
..
|
..
|
||||||
} => movability,
|
} => movability,
|
||||||
_ => unreachable!("non generator expression interned as generator"),
|
_ => unreachable!("non generator expression interned as generator"),
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
use base_db::CrateId;
|
use base_db::CrateId;
|
||||||
use chalk_ir::{BoundVar, DebruijnIndex, GenericArgData};
|
use chalk_ir::{BoundVar, DebruijnIndex, GenericArgData};
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
expr::Expr,
|
hir::Expr,
|
||||||
path::Path,
|
path::Path,
|
||||||
resolver::{Resolver, ValueNs},
|
resolver::{Resolver, ValueNs},
|
||||||
type_ref::ConstRef,
|
type_ref::ConstRef,
|
||||||
|
|
|
@ -6,7 +6,7 @@ use std::sync::Arc;
|
||||||
use base_db::{impl_intern_key, salsa, CrateId, Upcast};
|
use base_db::{impl_intern_key, salsa, CrateId, Upcast};
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
db::DefDatabase,
|
db::DefDatabase,
|
||||||
expr::ExprId,
|
hir::ExprId,
|
||||||
layout::{Layout, LayoutError, TargetDataLayout},
|
layout::{Layout, LayoutError, TargetDataLayout},
|
||||||
AdtId, BlockId, ConstId, ConstParamId, DefWithBodyId, EnumVariantId, FunctionId, GenericDefId,
|
AdtId, BlockId, ConstId, ConstParamId, DefWithBodyId, EnumVariantId, FunctionId, GenericDefId,
|
||||||
ImplId, LifetimeParamId, LocalFieldId, TypeOrConstParamId, VariantId,
|
ImplId, LifetimeParamId, LocalFieldId, TypeOrConstParamId, VariantId,
|
||||||
|
|
|
@ -17,7 +17,7 @@ use std::fmt;
|
||||||
use base_db::CrateId;
|
use base_db::CrateId;
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
data::adt::VariantData,
|
data::adt::VariantData,
|
||||||
expr::{Pat, PatId},
|
hir::{Pat, PatId},
|
||||||
src::HasSource,
|
src::HasSource,
|
||||||
AdtId, AttrDefId, ConstId, EnumId, FunctionId, ItemContainerId, Lookup, ModuleDefId, StaticId,
|
AdtId, AttrDefId, ConstId, EnumId, FunctionId, ItemContainerId, Lookup, ModuleDefId, StaticId,
|
||||||
StructId,
|
StructId,
|
||||||
|
|
|
@ -27,7 +27,7 @@ use crate::{
|
||||||
|
|
||||||
pub(crate) use hir_def::{
|
pub(crate) use hir_def::{
|
||||||
body::Body,
|
body::Body,
|
||||||
expr::{Expr, ExprId, MatchArm, Pat, PatId},
|
hir::{Expr, ExprId, MatchArm, Pat, PatId},
|
||||||
LocalFieldId, VariantId,
|
LocalFieldId, VariantId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//! Validation of matches.
|
//! Validation of matches.
|
||||||
//!
|
//!
|
||||||
//! This module provides lowering from [hir_def::expr::Pat] to [self::Pat] and match
|
//! This module provides lowering from [hir_def::hir::Pat] to [self::Pat] and match
|
||||||
//! checking algorithm.
|
//! checking algorithm.
|
||||||
//!
|
//!
|
||||||
//! It is modeled on the rustc module `rustc_mir_build::thir::pattern`.
|
//! It is modeled on the rustc module `rustc_mir_build::thir::pattern`.
|
||||||
|
@ -12,7 +12,7 @@ pub(crate) mod usefulness;
|
||||||
|
|
||||||
use chalk_ir::Mutability;
|
use chalk_ir::Mutability;
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
body::Body, data::adt::VariantData, expr::PatId, AdtId, EnumVariantId, LocalFieldId, VariantId,
|
body::Body, data::adt::VariantData, hir::PatId, AdtId, EnumVariantId, LocalFieldId, VariantId,
|
||||||
};
|
};
|
||||||
use hir_expand::name::Name;
|
use hir_expand::name::Name;
|
||||||
use stdx::{always, never};
|
use stdx::{always, never};
|
||||||
|
@ -125,15 +125,15 @@ impl<'a> PatCtxt<'a> {
|
||||||
let variant = self.infer.variant_resolution_for_pat(pat);
|
let variant = self.infer.variant_resolution_for_pat(pat);
|
||||||
|
|
||||||
let kind = match self.body[pat] {
|
let kind = match self.body[pat] {
|
||||||
hir_def::expr::Pat::Wild => PatKind::Wild,
|
hir_def::hir::Pat::Wild => PatKind::Wild,
|
||||||
|
|
||||||
hir_def::expr::Pat::Lit(expr) => self.lower_lit(expr),
|
hir_def::hir::Pat::Lit(expr) => self.lower_lit(expr),
|
||||||
|
|
||||||
hir_def::expr::Pat::Path(ref path) => {
|
hir_def::hir::Pat::Path(ref path) => {
|
||||||
return self.lower_path(pat, path);
|
return self.lower_path(pat, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
hir_def::expr::Pat::Tuple { ref args, ellipsis } => {
|
hir_def::hir::Pat::Tuple { ref args, ellipsis } => {
|
||||||
let arity = match *ty.kind(Interner) {
|
let arity = match *ty.kind(Interner) {
|
||||||
TyKind::Tuple(arity, _) => arity,
|
TyKind::Tuple(arity, _) => arity,
|
||||||
_ => {
|
_ => {
|
||||||
|
@ -146,7 +146,7 @@ impl<'a> PatCtxt<'a> {
|
||||||
PatKind::Leaf { subpatterns }
|
PatKind::Leaf { subpatterns }
|
||||||
}
|
}
|
||||||
|
|
||||||
hir_def::expr::Pat::Bind { id, subpat, .. } => {
|
hir_def::hir::Pat::Bind { id, subpat, .. } => {
|
||||||
let bm = self.infer.pat_binding_modes[&pat];
|
let bm = self.infer.pat_binding_modes[&pat];
|
||||||
let name = &self.body.bindings[id].name;
|
let name = &self.body.bindings[id].name;
|
||||||
match (bm, ty.kind(Interner)) {
|
match (bm, ty.kind(Interner)) {
|
||||||
|
@ -161,13 +161,13 @@ impl<'a> PatCtxt<'a> {
|
||||||
PatKind::Binding { name: name.clone(), subpattern: self.lower_opt_pattern(subpat) }
|
PatKind::Binding { name: name.clone(), subpattern: self.lower_opt_pattern(subpat) }
|
||||||
}
|
}
|
||||||
|
|
||||||
hir_def::expr::Pat::TupleStruct { ref args, ellipsis, .. } if variant.is_some() => {
|
hir_def::hir::Pat::TupleStruct { ref args, ellipsis, .. } if variant.is_some() => {
|
||||||
let expected_len = variant.unwrap().variant_data(self.db.upcast()).fields().len();
|
let expected_len = variant.unwrap().variant_data(self.db.upcast()).fields().len();
|
||||||
let subpatterns = self.lower_tuple_subpats(args, expected_len, ellipsis);
|
let subpatterns = self.lower_tuple_subpats(args, expected_len, ellipsis);
|
||||||
self.lower_variant_or_leaf(pat, ty, subpatterns)
|
self.lower_variant_or_leaf(pat, ty, subpatterns)
|
||||||
}
|
}
|
||||||
|
|
||||||
hir_def::expr::Pat::Record { ref args, .. } if variant.is_some() => {
|
hir_def::hir::Pat::Record { ref args, .. } if variant.is_some() => {
|
||||||
let variant_data = variant.unwrap().variant_data(self.db.upcast());
|
let variant_data = variant.unwrap().variant_data(self.db.upcast());
|
||||||
let subpatterns = args
|
let subpatterns = args
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -187,12 +187,12 @@ impl<'a> PatCtxt<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hir_def::expr::Pat::TupleStruct { .. } | hir_def::expr::Pat::Record { .. } => {
|
hir_def::hir::Pat::TupleStruct { .. } | hir_def::hir::Pat::Record { .. } => {
|
||||||
self.errors.push(PatternError::UnresolvedVariant);
|
self.errors.push(PatternError::UnresolvedVariant);
|
||||||
PatKind::Wild
|
PatKind::Wild
|
||||||
}
|
}
|
||||||
|
|
||||||
hir_def::expr::Pat::Or(ref pats) => PatKind::Or { pats: self.lower_patterns(pats) },
|
hir_def::hir::Pat::Or(ref pats) => PatKind::Or { pats: self.lower_patterns(pats) },
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
self.errors.push(PatternError::Unimplemented);
|
self.errors.push(PatternError::Unimplemented);
|
||||||
|
@ -279,8 +279,8 @@ impl<'a> PatCtxt<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lower_lit(&mut self, expr: hir_def::expr::ExprId) -> PatKind {
|
fn lower_lit(&mut self, expr: hir_def::hir::ExprId) -> PatKind {
|
||||||
use hir_def::expr::{Expr, Literal::Bool};
|
use hir_def::hir::{Expr, Literal::Bool};
|
||||||
|
|
||||||
match self.body[expr] {
|
match self.body[expr] {
|
||||||
Expr::Literal(Bool(value)) => PatKind::LiteralBool { value },
|
Expr::Literal(Bool(value)) => PatKind::LiteralBool { value },
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
body::Body,
|
body::Body,
|
||||||
expr::{Expr, ExprId, UnaryOp},
|
hir::{Expr, ExprId, UnaryOp},
|
||||||
resolver::{resolver_for_expr, ResolveValueResult, ValueNs},
|
resolver::{resolver_for_expr, ResolveValueResult, ValueNs},
|
||||||
DefWithBodyId,
|
DefWithBodyId,
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,12 +18,12 @@ use std::{convert::identity, ops::Index};
|
||||||
|
|
||||||
use chalk_ir::{cast::Cast, DebruijnIndex, Mutability, Safety, Scalar, TypeFlags};
|
use chalk_ir::{cast::Cast, DebruijnIndex, Mutability, Safety, Scalar, TypeFlags};
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use hir_def::expr::LabelId;
|
use hir_def::hir::LabelId;
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
body::Body,
|
body::Body,
|
||||||
builtin_type::{BuiltinInt, BuiltinType, BuiltinUint},
|
builtin_type::{BuiltinInt, BuiltinType, BuiltinUint},
|
||||||
data::{ConstData, StaticData},
|
data::{ConstData, StaticData},
|
||||||
expr::{BindingAnnotation, BindingId, ExprId, ExprOrPatId, PatId},
|
hir::{BindingAnnotation, BindingId, ExprId, ExprOrPatId, PatId},
|
||||||
lang_item::{LangItem, LangItemTarget},
|
lang_item::{LangItem, LangItemTarget},
|
||||||
layout::Integer,
|
layout::Integer,
|
||||||
path::{ModPath, Path},
|
path::{ModPath, Path},
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//! Inference of closure parameter types based on the closure's expected type.
|
//! Inference of closure parameter types based on the closure's expected type.
|
||||||
|
|
||||||
use chalk_ir::{cast::Cast, AliasEq, AliasTy, FnSubst, WhereClause};
|
use chalk_ir::{cast::Cast, AliasEq, AliasTy, FnSubst, WhereClause};
|
||||||
use hir_def::{expr::ExprId, HasModule};
|
use hir_def::{hir::ExprId, HasModule};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
|
@ -9,7 +9,7 @@ use std::{iter, sync::Arc};
|
||||||
|
|
||||||
use chalk_ir::{cast::Cast, BoundVar, Goal, Mutability, TyVariableKind};
|
use chalk_ir::{cast::Cast, BoundVar, Goal, Mutability, TyVariableKind};
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
expr::ExprId,
|
hir::ExprId,
|
||||||
lang_item::{LangItem, LangItemTarget},
|
lang_item::{LangItem, LangItemTarget},
|
||||||
};
|
};
|
||||||
use stdx::always;
|
use stdx::always;
|
||||||
|
|
|
@ -10,10 +10,10 @@ use chalk_ir::{
|
||||||
cast::Cast, fold::Shift, DebruijnIndex, GenericArgData, Mutability, TyKind, TyVariableKind,
|
cast::Cast, fold::Shift, DebruijnIndex, GenericArgData, Mutability, TyKind, TyVariableKind,
|
||||||
};
|
};
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
expr::{
|
generics::TypeOrConstParamData,
|
||||||
|
hir::{
|
||||||
ArithOp, Array, BinaryOp, ClosureKind, Expr, ExprId, LabelId, Literal, Statement, UnaryOp,
|
ArithOp, Array, BinaryOp, ClosureKind, Expr, ExprId, LabelId, Literal, Statement, UnaryOp,
|
||||||
},
|
},
|
||||||
generics::TypeOrConstParamData,
|
|
||||||
lang_item::LangItem,
|
lang_item::LangItem,
|
||||||
path::{GenericArg, GenericArgs},
|
path::{GenericArg, GenericArgs},
|
||||||
BlockId, ConstParamId, FieldId, ItemContainerId, Lookup,
|
BlockId, ConstParamId, FieldId, ItemContainerId, Lookup,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
use chalk_ir::Mutability;
|
use chalk_ir::Mutability;
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
expr::{Array, BindingAnnotation, Expr, ExprId, PatId, Statement, UnaryOp},
|
hir::{Array, BindingAnnotation, Expr, ExprId, PatId, Statement, UnaryOp},
|
||||||
lang_item::LangItem,
|
lang_item::LangItem,
|
||||||
};
|
};
|
||||||
use hir_expand::name;
|
use hir_expand::name;
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::iter::repeat_with;
|
||||||
use chalk_ir::Mutability;
|
use chalk_ir::Mutability;
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
body::Body,
|
body::Body,
|
||||||
expr::{Binding, BindingAnnotation, BindingId, Expr, ExprId, ExprOrPatId, Literal, Pat, PatId},
|
hir::{Binding, BindingAnnotation, BindingId, Expr, ExprId, ExprOrPatId, Literal, Pat, PatId},
|
||||||
path::Path,
|
path::Path,
|
||||||
};
|
};
|
||||||
use hir_expand::name::Name;
|
use hir_expand::name::Name;
|
||||||
|
|
|
@ -44,7 +44,7 @@ use chalk_ir::{
|
||||||
NoSolution, TyData,
|
NoSolution, TyData,
|
||||||
};
|
};
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use hir_def::{expr::ExprId, type_ref::Rawness, TypeOrConstParamId};
|
use hir_def::{hir::ExprId, type_ref::Rawness, TypeOrConstParamId};
|
||||||
use hir_expand::name;
|
use hir_expand::name;
|
||||||
use la_arena::{Arena, Idx};
|
use la_arena::{Arena, Idx};
|
||||||
use mir::MirEvalError;
|
use mir::MirEvalError;
|
||||||
|
|
|
@ -7,7 +7,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use chalk_ir::Mutability;
|
use chalk_ir::Mutability;
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
expr::{BindingId, Expr, ExprId, Ordering, PatId},
|
hir::{BindingId, Expr, ExprId, Ordering, PatId},
|
||||||
DefWithBodyId, FieldId, UnionId, VariantId,
|
DefWithBodyId, FieldId, UnionId, VariantId,
|
||||||
};
|
};
|
||||||
use la_arena::{Arena, ArenaMap, Idx, RawIdx};
|
use la_arena::{Arena, ArenaMap, Idx, RawIdx};
|
||||||
|
@ -588,32 +588,32 @@ impl Display for BinOp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<hir_def::expr::ArithOp> for BinOp {
|
impl From<hir_def::hir::ArithOp> for BinOp {
|
||||||
fn from(value: hir_def::expr::ArithOp) -> Self {
|
fn from(value: hir_def::hir::ArithOp) -> Self {
|
||||||
match value {
|
match value {
|
||||||
hir_def::expr::ArithOp::Add => BinOp::Add,
|
hir_def::hir::ArithOp::Add => BinOp::Add,
|
||||||
hir_def::expr::ArithOp::Mul => BinOp::Mul,
|
hir_def::hir::ArithOp::Mul => BinOp::Mul,
|
||||||
hir_def::expr::ArithOp::Sub => BinOp::Sub,
|
hir_def::hir::ArithOp::Sub => BinOp::Sub,
|
||||||
hir_def::expr::ArithOp::Div => BinOp::Div,
|
hir_def::hir::ArithOp::Div => BinOp::Div,
|
||||||
hir_def::expr::ArithOp::Rem => BinOp::Rem,
|
hir_def::hir::ArithOp::Rem => BinOp::Rem,
|
||||||
hir_def::expr::ArithOp::Shl => BinOp::Shl,
|
hir_def::hir::ArithOp::Shl => BinOp::Shl,
|
||||||
hir_def::expr::ArithOp::Shr => BinOp::Shr,
|
hir_def::hir::ArithOp::Shr => BinOp::Shr,
|
||||||
hir_def::expr::ArithOp::BitXor => BinOp::BitXor,
|
hir_def::hir::ArithOp::BitXor => BinOp::BitXor,
|
||||||
hir_def::expr::ArithOp::BitOr => BinOp::BitOr,
|
hir_def::hir::ArithOp::BitOr => BinOp::BitOr,
|
||||||
hir_def::expr::ArithOp::BitAnd => BinOp::BitAnd,
|
hir_def::hir::ArithOp::BitAnd => BinOp::BitAnd,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<hir_def::expr::CmpOp> for BinOp {
|
impl From<hir_def::hir::CmpOp> for BinOp {
|
||||||
fn from(value: hir_def::expr::CmpOp) -> Self {
|
fn from(value: hir_def::hir::CmpOp) -> Self {
|
||||||
match value {
|
match value {
|
||||||
hir_def::expr::CmpOp::Eq { negated: false } => BinOp::Eq,
|
hir_def::hir::CmpOp::Eq { negated: false } => BinOp::Eq,
|
||||||
hir_def::expr::CmpOp::Eq { negated: true } => BinOp::Ne,
|
hir_def::hir::CmpOp::Eq { negated: true } => BinOp::Ne,
|
||||||
hir_def::expr::CmpOp::Ord { ordering: Ordering::Greater, strict: false } => BinOp::Ge,
|
hir_def::hir::CmpOp::Ord { ordering: Ordering::Greater, strict: false } => BinOp::Ge,
|
||||||
hir_def::expr::CmpOp::Ord { ordering: Ordering::Greater, strict: true } => BinOp::Gt,
|
hir_def::hir::CmpOp::Ord { ordering: Ordering::Greater, strict: true } => BinOp::Gt,
|
||||||
hir_def::expr::CmpOp::Ord { ordering: Ordering::Less, strict: false } => BinOp::Le,
|
hir_def::hir::CmpOp::Ord { ordering: Ordering::Less, strict: false } => BinOp::Le,
|
||||||
hir_def::expr::CmpOp::Ord { ordering: Ordering::Less, strict: true } => BinOp::Lt,
|
hir_def::hir::CmpOp::Ord { ordering: Ordering::Less, strict: true } => BinOp::Lt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ use chalk_ir::{BoundVar, ConstData, DebruijnIndex, TyKind};
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
body::Body,
|
body::Body,
|
||||||
data::adt::{StructKind, VariantData},
|
data::adt::{StructKind, VariantData},
|
||||||
expr::{
|
hir::{
|
||||||
Array, BindingAnnotation, BindingId, ExprId, LabelId, Literal, MatchArm, Pat, PatId,
|
Array, BindingAnnotation, BindingId, ExprId, LabelId, Literal, MatchArm, Pat, PatId,
|
||||||
RecordFieldPat, RecordLitField,
|
RecordFieldPat, RecordLitField,
|
||||||
},
|
},
|
||||||
|
@ -713,20 +713,20 @@ impl MirLowerCtx<'_> {
|
||||||
Ok(Some(current))
|
Ok(Some(current))
|
||||||
}
|
}
|
||||||
Expr::Box { .. } => not_supported!("box expression"),
|
Expr::Box { .. } => not_supported!("box expression"),
|
||||||
Expr::Field { .. } | Expr::Index { .. } | Expr::UnaryOp { op: hir_def::expr::UnaryOp::Deref, .. } => {
|
Expr::Field { .. } | Expr::Index { .. } | Expr::UnaryOp { op: hir_def::hir::UnaryOp::Deref, .. } => {
|
||||||
let Some((p, current)) = self.lower_expr_as_place_without_adjust(current, expr_id, true)? else {
|
let Some((p, current)) = self.lower_expr_as_place_without_adjust(current, expr_id, true)? else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
self.push_assignment(current, place, Operand::Copy(p).into(), expr_id.into());
|
self.push_assignment(current, place, Operand::Copy(p).into(), expr_id.into());
|
||||||
Ok(Some(current))
|
Ok(Some(current))
|
||||||
}
|
}
|
||||||
Expr::UnaryOp { expr, op: op @ (hir_def::expr::UnaryOp::Not | hir_def::expr::UnaryOp::Neg) } => {
|
Expr::UnaryOp { expr, op: op @ (hir_def::hir::UnaryOp::Not | hir_def::hir::UnaryOp::Neg) } => {
|
||||||
let Some((operand, current)) = self.lower_expr_to_some_operand(*expr, current)? else {
|
let Some((operand, current)) = self.lower_expr_to_some_operand(*expr, current)? else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
let operation = match op {
|
let operation = match op {
|
||||||
hir_def::expr::UnaryOp::Not => UnOp::Not,
|
hir_def::hir::UnaryOp::Not => UnOp::Not,
|
||||||
hir_def::expr::UnaryOp::Neg => UnOp::Neg,
|
hir_def::hir::UnaryOp::Neg => UnOp::Neg,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
self.push_assignment(
|
self.push_assignment(
|
||||||
|
@ -739,7 +739,7 @@ impl MirLowerCtx<'_> {
|
||||||
},
|
},
|
||||||
Expr::BinaryOp { lhs, rhs, op } => {
|
Expr::BinaryOp { lhs, rhs, op } => {
|
||||||
let op = op.ok_or(MirLowerError::IncompleteExpr)?;
|
let op = op.ok_or(MirLowerError::IncompleteExpr)?;
|
||||||
if let hir_def::expr::BinaryOp::Assignment { op } = op {
|
if let hir_def::hir::BinaryOp::Assignment { op } = op {
|
||||||
if op.is_some() {
|
if op.is_some() {
|
||||||
not_supported!("assignment with arith op (like +=)");
|
not_supported!("assignment with arith op (like +=)");
|
||||||
}
|
}
|
||||||
|
@ -765,13 +765,13 @@ impl MirLowerCtx<'_> {
|
||||||
place,
|
place,
|
||||||
Rvalue::CheckedBinaryOp(
|
Rvalue::CheckedBinaryOp(
|
||||||
match op {
|
match op {
|
||||||
hir_def::expr::BinaryOp::LogicOp(op) => match op {
|
hir_def::hir::BinaryOp::LogicOp(op) => match op {
|
||||||
hir_def::expr::LogicOp::And => BinOp::BitAnd, // FIXME: make these short circuit
|
hir_def::hir::LogicOp::And => BinOp::BitAnd, // FIXME: make these short circuit
|
||||||
hir_def::expr::LogicOp::Or => BinOp::BitOr,
|
hir_def::hir::LogicOp::Or => BinOp::BitOr,
|
||||||
},
|
},
|
||||||
hir_def::expr::BinaryOp::ArithOp(op) => BinOp::from(op),
|
hir_def::hir::BinaryOp::ArithOp(op) => BinOp::from(op),
|
||||||
hir_def::expr::BinaryOp::CmpOp(op) => BinOp::from(op),
|
hir_def::hir::BinaryOp::CmpOp(op) => BinOp::from(op),
|
||||||
hir_def::expr::BinaryOp::Assignment { .. } => unreachable!(), // handled above
|
hir_def::hir::BinaryOp::Assignment { .. } => unreachable!(), // handled above
|
||||||
},
|
},
|
||||||
lhs_op,
|
lhs_op,
|
||||||
rhs_op,
|
rhs_op,
|
||||||
|
@ -910,7 +910,7 @@ impl MirLowerCtx<'_> {
|
||||||
.size
|
.size
|
||||||
.bytes_usize();
|
.bytes_usize();
|
||||||
let bytes = match l {
|
let bytes = match l {
|
||||||
hir_def::expr::Literal::String(b) => {
|
hir_def::hir::Literal::String(b) => {
|
||||||
let b = b.as_bytes();
|
let b = b.as_bytes();
|
||||||
let mut data = vec![];
|
let mut data = vec![];
|
||||||
data.extend(0usize.to_le_bytes());
|
data.extend(0usize.to_le_bytes());
|
||||||
|
@ -919,7 +919,7 @@ impl MirLowerCtx<'_> {
|
||||||
mm.insert(0, b.to_vec());
|
mm.insert(0, b.to_vec());
|
||||||
return Ok(Operand::from_concrete_const(data, mm, ty));
|
return Ok(Operand::from_concrete_const(data, mm, ty));
|
||||||
}
|
}
|
||||||
hir_def::expr::Literal::ByteString(b) => {
|
hir_def::hir::Literal::ByteString(b) => {
|
||||||
let mut data = vec![];
|
let mut data = vec![];
|
||||||
data.extend(0usize.to_le_bytes());
|
data.extend(0usize.to_le_bytes());
|
||||||
data.extend(b.len().to_le_bytes());
|
data.extend(b.len().to_le_bytes());
|
||||||
|
@ -927,11 +927,11 @@ impl MirLowerCtx<'_> {
|
||||||
mm.insert(0, b.to_vec());
|
mm.insert(0, b.to_vec());
|
||||||
return Ok(Operand::from_concrete_const(data, mm, ty));
|
return Ok(Operand::from_concrete_const(data, mm, ty));
|
||||||
}
|
}
|
||||||
hir_def::expr::Literal::Char(c) => u32::from(*c).to_le_bytes().into(),
|
hir_def::hir::Literal::Char(c) => u32::from(*c).to_le_bytes().into(),
|
||||||
hir_def::expr::Literal::Bool(b) => vec![*b as u8],
|
hir_def::hir::Literal::Bool(b) => vec![*b as u8],
|
||||||
hir_def::expr::Literal::Int(x, _) => x.to_le_bytes()[0..size].into(),
|
hir_def::hir::Literal::Int(x, _) => x.to_le_bytes()[0..size].into(),
|
||||||
hir_def::expr::Literal::Uint(x, _) => x.to_le_bytes()[0..size].into(),
|
hir_def::hir::Literal::Uint(x, _) => x.to_le_bytes()[0..size].into(),
|
||||||
hir_def::expr::Literal::Float(f, _) => match size {
|
hir_def::hir::Literal::Float(f, _) => match size {
|
||||||
8 => f.into_f64().to_le_bytes().into(),
|
8 => f.into_f64().to_le_bytes().into(),
|
||||||
4 => f.into_f32().to_le_bytes().into(),
|
4 => f.into_f32().to_le_bytes().into(),
|
||||||
_ => {
|
_ => {
|
||||||
|
@ -1218,14 +1218,14 @@ impl MirLowerCtx<'_> {
|
||||||
|
|
||||||
fn lower_block_to_place(
|
fn lower_block_to_place(
|
||||||
&mut self,
|
&mut self,
|
||||||
statements: &[hir_def::expr::Statement],
|
statements: &[hir_def::hir::Statement],
|
||||||
mut current: BasicBlockId,
|
mut current: BasicBlockId,
|
||||||
tail: Option<ExprId>,
|
tail: Option<ExprId>,
|
||||||
place: Place,
|
place: Place,
|
||||||
) -> Result<Option<Idx<BasicBlock>>> {
|
) -> Result<Option<Idx<BasicBlock>>> {
|
||||||
for statement in statements.iter() {
|
for statement in statements.iter() {
|
||||||
match statement {
|
match statement {
|
||||||
hir_def::expr::Statement::Let { pat, initializer, else_branch, type_ref: _ } => {
|
hir_def::hir::Statement::Let { pat, initializer, else_branch, type_ref: _ } => {
|
||||||
if let Some(expr_id) = initializer {
|
if let Some(expr_id) = initializer {
|
||||||
let else_block;
|
let else_block;
|
||||||
let Some((init_place, c)) =
|
let Some((init_place, c)) =
|
||||||
|
@ -1261,7 +1261,7 @@ impl MirLowerCtx<'_> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hir_def::expr::Statement::Expr { expr, has_semi: _ } => {
|
hir_def::hir::Statement::Expr { expr, has_semi: _ } => {
|
||||||
let Some((_, c)) = self.lower_expr_as_place(current, *expr, true)? else {
|
let Some((_, c)) = self.lower_expr_as_place(current, *expr, true)? else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
|
|
|
@ -141,7 +141,7 @@ impl MirLowerCtx<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Expr::UnaryOp { expr, op } => match op {
|
Expr::UnaryOp { expr, op } => match op {
|
||||||
hir_def::expr::UnaryOp::Deref => {
|
hir_def::hir::UnaryOp::Deref => {
|
||||||
if !matches!(
|
if !matches!(
|
||||||
self.expr_ty(*expr).kind(Interner),
|
self.expr_ty(*expr).kind(Interner),
|
||||||
TyKind::Ref(..) | TyKind::Raw(..)
|
TyKind::Ref(..) | TyKind::Raw(..)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use std::fmt::{Debug, Display, Write};
|
use std::fmt::{Debug, Display, Write};
|
||||||
|
|
||||||
use hir_def::{body::Body, expr::BindingId};
|
use hir_def::{body::Body, hir::BindingId};
|
||||||
use hir_expand::name::Name;
|
use hir_expand::name::Name;
|
||||||
use la_arena::ArenaMap;
|
use la_arena::ArenaMap;
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ use expect_test::Expect;
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
body::{Body, BodySourceMap, SyntheticSyntax},
|
body::{Body, BodySourceMap, SyntheticSyntax},
|
||||||
db::{DefDatabase, InternDatabase},
|
db::{DefDatabase, InternDatabase},
|
||||||
expr::{ExprId, PatId},
|
hir::{ExprId, PatId},
|
||||||
item_scope::ItemScope,
|
item_scope::ItemScope,
|
||||||
nameres::DefMap,
|
nameres::DefMap,
|
||||||
src::HasSource,
|
src::HasSource,
|
||||||
|
@ -198,8 +198,8 @@ fn check_impl(ra_fixture: &str, allow_none: bool, only_types: bool, display_sour
|
||||||
|
|
||||||
for (expr_or_pat, mismatch) in inference_result.type_mismatches() {
|
for (expr_or_pat, mismatch) in inference_result.type_mismatches() {
|
||||||
let Some(node) = (match expr_or_pat {
|
let Some(node) = (match expr_or_pat {
|
||||||
hir_def::expr::ExprOrPatId::ExprId(expr) => expr_node(&body_source_map, expr, &db),
|
hir_def::hir::ExprOrPatId::ExprId(expr) => expr_node(&body_source_map, expr, &db),
|
||||||
hir_def::expr::ExprOrPatId::PatId(pat) => pat_node(&body_source_map, pat, &db),
|
hir_def::hir::ExprOrPatId::PatId(pat) => pat_node(&body_source_map, pat, &db),
|
||||||
}) else { continue; };
|
}) else { continue; };
|
||||||
let range = node.as_ref().original_file_range(&db);
|
let range = node.as_ref().original_file_range(&db);
|
||||||
let actual = format!(
|
let actual = format!(
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
//! are splitting the hir.
|
//! are splitting the hir.
|
||||||
|
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
expr::{BindingId, LabelId},
|
hir::{BindingId, LabelId},
|
||||||
AdtId, AssocItemId, DefWithBodyId, EnumVariantId, FieldId, GenericDefId, GenericParamId,
|
AdtId, AssocItemId, DefWithBodyId, EnumVariantId, FieldId, GenericDefId, GenericParamId,
|
||||||
ModuleDefId, VariantId,
|
ModuleDefId, VariantId,
|
||||||
};
|
};
|
||||||
|
|
|
@ -41,8 +41,8 @@ use either::Either;
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
body::{BodyDiagnostic, SyntheticSyntax},
|
body::{BodyDiagnostic, SyntheticSyntax},
|
||||||
data::adt::VariantData,
|
data::adt::VariantData,
|
||||||
expr::{BindingAnnotation, BindingId, ExprOrPatId, LabelId, Pat},
|
|
||||||
generics::{LifetimeParamData, TypeOrConstParamData, TypeParamProvenance},
|
generics::{LifetimeParamData, TypeOrConstParamData, TypeParamProvenance},
|
||||||
|
hir::{BindingAnnotation, BindingId, ExprOrPatId, LabelId, Pat},
|
||||||
item_tree::ItemTreeNode,
|
item_tree::ItemTreeNode,
|
||||||
lang_item::{LangItem, LangItemTarget},
|
lang_item::{LangItem, LangItemTarget},
|
||||||
layout::{Layout, LayoutError, ReprOptions},
|
layout::{Layout, LayoutError, ReprOptions},
|
||||||
|
|
|
@ -8,7 +8,7 @@ use base_db::{FileId, FileRange};
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
body,
|
body,
|
||||||
expr::Expr,
|
hir::Expr,
|
||||||
macro_id_to_def_id,
|
macro_id_to_def_id,
|
||||||
resolver::{self, HasResolver, Resolver, TypeNs},
|
resolver::{self, HasResolver, Resolver, TypeNs},
|
||||||
type_ref::Mutability,
|
type_ref::Mutability,
|
||||||
|
|
|
@ -89,7 +89,7 @@ use base_db::FileId;
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
child_by_source::ChildBySource,
|
child_by_source::ChildBySource,
|
||||||
dyn_map::DynMap,
|
dyn_map::DynMap,
|
||||||
expr::{BindingId, LabelId},
|
hir::{BindingId, LabelId},
|
||||||
keys::{self, Key},
|
keys::{self, Key},
|
||||||
AdtId, ConstId, ConstParamId, DefWithBodyId, EnumId, EnumVariantId, FieldId, FunctionId,
|
AdtId, ConstId, ConstParamId, DefWithBodyId, EnumId, EnumVariantId, FieldId, FunctionId,
|
||||||
GenericDefId, GenericParamId, ImplId, LifetimeParamId, MacroId, ModuleId, StaticId, StructId,
|
GenericDefId, GenericParamId, ImplId, LifetimeParamId, MacroId, ModuleId, StaticId, StructId,
|
||||||
|
|
|
@ -17,7 +17,7 @@ use hir_def::{
|
||||||
scope::{ExprScopes, ScopeId},
|
scope::{ExprScopes, ScopeId},
|
||||||
Body, BodySourceMap,
|
Body, BodySourceMap,
|
||||||
},
|
},
|
||||||
expr::{ExprId, Pat, PatId},
|
hir::{ExprId, Pat, PatId},
|
||||||
lang_item::LangItem,
|
lang_item::LangItem,
|
||||||
macro_id_to_def_id,
|
macro_id_to_def_id,
|
||||||
path::{ModPath, Path, PathKind},
|
path::{ModPath, Path, PathKind},
|
||||||
|
|
|
@ -13,7 +13,7 @@ use hir::{
|
||||||
};
|
};
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
body::{BodySourceMap, SyntheticSyntax},
|
body::{BodySourceMap, SyntheticSyntax},
|
||||||
expr::{ExprId, PatId},
|
hir::{ExprId, PatId},
|
||||||
FunctionId,
|
FunctionId,
|
||||||
};
|
};
|
||||||
use hir_ty::{Interner, TyExt, TypeFlags};
|
use hir_ty::{Interner, TyExt, TypeFlags};
|
||||||
|
|
Loading…
Reference in a new issue