Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 99b6952

Browse files
committed
hir_def::expr -> hir_def::hir, hir_def::type_ref -> hir_def::hir::type_ref
1 parent 8e7c104 commit 99b6952

33 files changed

+96
-94
lines changed

crates/hir-def/src/body.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use syntax::{ast, AstPtr, SyntaxNode, SyntaxNodePtr};
2525
use crate::{
2626
attr::Attrs,
2727
db::DefDatabase,
28-
expr::{
28+
hir::{
2929
dummy_expr_id, Binding, BindingId, Expr, ExprId, Label, LabelId, Pat, PatId, RecordFieldPat,
3030
},
3131
item_scope::BuiltinShadowMode,

crates/hir-def/src/body/lower.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use crate::{
3333
builtin_type::{BuiltinFloat, BuiltinInt, BuiltinUint},
3434
data::adt::StructKind,
3535
db::DefDatabase,
36-
expr::{
36+
hir::{
3737
dummy_expr_id, Array, Binding, BindingAnnotation, BindingId, ClosureKind, Expr, ExprId,
3838
FloatTypeWrapper, Label, LabelId, Literal, MatchArm, Movability, Pat, PatId,
3939
RecordFieldPat, RecordLitField, Statement,

crates/hir-def/src/body/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::fmt::{self, Write};
55
use syntax::ast::HasName;
66

77
use crate::{
8-
expr::{Array, BindingAnnotation, BindingId, ClosureKind, Literal, Movability, Statement},
8+
hir::{Array, BindingAnnotation, BindingId, ClosureKind, Literal, Movability, Statement},
99
pretty::{print_generic_args, print_path, print_type_ref},
1010
type_ref::TypeRef,
1111
};

crates/hir-def/src/body/scope.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_hash::FxHashMap;
88
use crate::{
99
body::Body,
1010
db::DefDatabase,
11-
expr::{Binding, BindingId, Expr, ExprId, LabelId, Pat, PatId, Statement},
11+
hir::{Binding, BindingId, Expr, ExprId, LabelId, Pat, PatId, Statement},
1212
BlockId, DefWithBodyId,
1313
};
1414

crates/hir-def/src/expr.rs renamed to crates/hir-def/src/hir.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
//!
1313
//! See also a neighboring `body` module.
1414
15+
pub mod type_ref;
16+
1517
use std::fmt;
1618

1719
use hir_expand::name::Name;
@@ -28,10 +30,10 @@ use crate::{
2830

2931
pub use syntax::ast::{ArithOp, BinaryOp, CmpOp, LogicOp, Ordering, RangeOp, UnaryOp};
3032

31-
pub type ExprId = Idx<Expr>;
32-
3333
pub type BindingId = Idx<Binding>;
3434

35+
pub type ExprId = Idx<Expr>;
36+
3537
/// FIXME: this is a hacky function which should be removed
3638
pub(crate) fn dummy_expr_id() -> ExprId {
3739
ExprId::from_raw(RawIdx::from(u32::MAX))

crates/hir-def/src/type_ref.rs renamed to crates/hir-def/src/hir/type_ref.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use syntax::ast::{self, HasName};
1313
use crate::{
1414
body::LowerCtx,
1515
builtin_type::{BuiltinInt, BuiltinType, BuiltinUint},
16-
expr::Literal,
16+
hir::Literal,
1717
path::Path,
1818
};
1919

crates/hir-def/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ pub mod db;
1818

1919
pub mod attr;
2020
pub mod path;
21-
pub mod type_ref;
2221
pub mod builtin_type;
2322
pub mod builtin_attr;
2423
pub mod per_ns;
@@ -34,7 +33,8 @@ pub mod generics;
3433
pub mod lang_item;
3534
pub mod layout;
3635

37-
pub mod expr;
36+
pub mod hir;
37+
pub use self::hir::type_ref;
3838
pub mod body;
3939
pub mod resolver;
4040

crates/hir-def/src/resolver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use crate::{
1212
body::scope::{ExprScopes, ScopeId},
1313
builtin_type::BuiltinType,
1414
db::DefDatabase,
15-
expr::{BindingId, ExprId, LabelId},
1615
generics::{GenericParams, TypeOrConstParamData},
16+
hir::{BindingId, ExprId, LabelId},
1717
item_scope::{BuiltinShadowMode, BUILTIN_SCOPE},
1818
lang_item::LangItemTarget,
1919
nameres::DefMap,

crates/hir-ty/src/chalk_db.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use chalk_solve::rust_ir::{self, OpaqueTyDatumBound, WellKnownTrait};
99

1010
use base_db::CrateId;
1111
use hir_def::{
12-
expr::Movability,
12+
hir::Movability,
1313
lang_item::{lang_attr, LangItem, LangItemTarget},
1414
AssocItemId, BlockId, GenericDefId, HasModule, ItemContainerId, Lookup, TypeAliasId,
1515
};
@@ -415,8 +415,8 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
415415
let input_output = crate::make_type_and_const_binders(it, input_output);
416416

417417
let movability = match self.db.body(parent)[expr] {
418-
hir_def::expr::Expr::Closure {
419-
closure_kind: hir_def::expr::ClosureKind::Generator(movability),
418+
hir_def::hir::Expr::Closure {
419+
closure_kind: hir_def::hir::ClosureKind::Generator(movability),
420420
..
421421
} => movability,
422422
_ => unreachable!("non generator expression interned as generator"),

crates/hir-ty/src/consteval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use base_db::CrateId;
44
use chalk_ir::{BoundVar, DebruijnIndex, GenericArgData};
55
use hir_def::{
6-
expr::Expr,
6+
hir::Expr,
77
path::Path,
88
resolver::{Resolver, ValueNs},
99
type_ref::ConstRef,

crates/hir-ty/src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::sync::Arc;
66
use base_db::{impl_intern_key, salsa, CrateId, Upcast};
77
use hir_def::{
88
db::DefDatabase,
9-
expr::ExprId,
9+
hir::ExprId,
1010
layout::{Layout, LayoutError, TargetDataLayout},
1111
AdtId, BlockId, ConstId, ConstParamId, DefWithBodyId, EnumVariantId, FunctionId, GenericDefId,
1212
ImplId, LifetimeParamId, LocalFieldId, TypeOrConstParamId, VariantId,

crates/hir-ty/src/diagnostics/decl_check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::fmt;
1717
use base_db::CrateId;
1818
use hir_def::{
1919
data::adt::VariantData,
20-
expr::{Pat, PatId},
20+
hir::{Pat, PatId},
2121
src::HasSource,
2222
AdtId, AttrDefId, ConstId, EnumId, FunctionId, ItemContainerId, Lookup, ModuleDefId, StaticId,
2323
StructId,

crates/hir-ty/src/diagnostics/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::{
2727

2828
pub(crate) use hir_def::{
2929
body::Body,
30-
expr::{Expr, ExprId, MatchArm, Pat, PatId},
30+
hir::{Expr, ExprId, MatchArm, Pat, PatId},
3131
LocalFieldId, VariantId,
3232
};
3333

crates/hir-ty/src/diagnostics/match_check.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Validation of matches.
22
//!
3-
//! This module provides lowering from [hir_def::expr::Pat] to [self::Pat] and match
3+
//! This module provides lowering from [hir_def::hir::Pat] to [self::Pat] and match
44
//! checking algorithm.
55
//!
66
//! It is modeled on the rustc module `rustc_mir_build::thir::pattern`.
@@ -12,7 +12,7 @@ pub(crate) mod usefulness;
1212

1313
use chalk_ir::Mutability;
1414
use hir_def::{
15-
body::Body, data::adt::VariantData, expr::PatId, AdtId, EnumVariantId, LocalFieldId, VariantId,
15+
body::Body, data::adt::VariantData, hir::PatId, AdtId, EnumVariantId, LocalFieldId, VariantId,
1616
};
1717
use hir_expand::name::Name;
1818
use stdx::{always, never};
@@ -125,15 +125,15 @@ impl<'a> PatCtxt<'a> {
125125
let variant = self.infer.variant_resolution_for_pat(pat);
126126

127127
let kind = match self.body[pat] {
128-
hir_def::expr::Pat::Wild => PatKind::Wild,
128+
hir_def::hir::Pat::Wild => PatKind::Wild,
129129

130-
hir_def::expr::Pat::Lit(expr) => self.lower_lit(expr),
130+
hir_def::hir::Pat::Lit(expr) => self.lower_lit(expr),
131131

132-
hir_def::expr::Pat::Path(ref path) => {
132+
hir_def::hir::Pat::Path(ref path) => {
133133
return self.lower_path(pat, path);
134134
}
135135

136-
hir_def::expr::Pat::Tuple { ref args, ellipsis } => {
136+
hir_def::hir::Pat::Tuple { ref args, ellipsis } => {
137137
let arity = match *ty.kind(Interner) {
138138
TyKind::Tuple(arity, _) => arity,
139139
_ => {
@@ -146,7 +146,7 @@ impl<'a> PatCtxt<'a> {
146146
PatKind::Leaf { subpatterns }
147147
}
148148

149-
hir_def::expr::Pat::Bind { id, subpat, .. } => {
149+
hir_def::hir::Pat::Bind { id, subpat, .. } => {
150150
let bm = self.infer.pat_binding_modes[&pat];
151151
let name = &self.body.bindings[id].name;
152152
match (bm, ty.kind(Interner)) {
@@ -161,13 +161,13 @@ impl<'a> PatCtxt<'a> {
161161
PatKind::Binding { name: name.clone(), subpattern: self.lower_opt_pattern(subpat) }
162162
}
163163

164-
hir_def::expr::Pat::TupleStruct { ref args, ellipsis, .. } if variant.is_some() => {
164+
hir_def::hir::Pat::TupleStruct { ref args, ellipsis, .. } if variant.is_some() => {
165165
let expected_len = variant.unwrap().variant_data(self.db.upcast()).fields().len();
166166
let subpatterns = self.lower_tuple_subpats(args, expected_len, ellipsis);
167167
self.lower_variant_or_leaf(pat, ty, subpatterns)
168168
}
169169

170-
hir_def::expr::Pat::Record { ref args, .. } if variant.is_some() => {
170+
hir_def::hir::Pat::Record { ref args, .. } if variant.is_some() => {
171171
let variant_data = variant.unwrap().variant_data(self.db.upcast());
172172
let subpatterns = args
173173
.iter()
@@ -187,12 +187,12 @@ impl<'a> PatCtxt<'a> {
187187
}
188188
}
189189
}
190-
hir_def::expr::Pat::TupleStruct { .. } | hir_def::expr::Pat::Record { .. } => {
190+
hir_def::hir::Pat::TupleStruct { .. } | hir_def::hir::Pat::Record { .. } => {
191191
self.errors.push(PatternError::UnresolvedVariant);
192192
PatKind::Wild
193193
}
194194

195-
hir_def::expr::Pat::Or(ref pats) => PatKind::Or { pats: self.lower_patterns(pats) },
195+
hir_def::hir::Pat::Or(ref pats) => PatKind::Or { pats: self.lower_patterns(pats) },
196196

197197
_ => {
198198
self.errors.push(PatternError::Unimplemented);
@@ -279,8 +279,8 @@ impl<'a> PatCtxt<'a> {
279279
}
280280
}
281281

282-
fn lower_lit(&mut self, expr: hir_def::expr::ExprId) -> PatKind {
283-
use hir_def::expr::{Expr, Literal::Bool};
282+
fn lower_lit(&mut self, expr: hir_def::hir::ExprId) -> PatKind {
283+
use hir_def::hir::{Expr, Literal::Bool};
284284

285285
match self.body[expr] {
286286
Expr::Literal(Bool(value)) => PatKind::LiteralBool { value },

crates/hir-ty/src/diagnostics/unsafe_check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
use hir_def::{
55
body::Body,
6-
expr::{Expr, ExprId, UnaryOp},
6+
hir::{Expr, ExprId, UnaryOp},
77
resolver::{resolver_for_expr, ResolveValueResult, ValueNs},
88
DefWithBodyId,
99
};

crates/hir-ty/src/infer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ use std::{convert::identity, ops::Index};
1818

1919
use chalk_ir::{cast::Cast, DebruijnIndex, Mutability, Safety, Scalar, TypeFlags};
2020
use either::Either;
21-
use hir_def::expr::LabelId;
21+
use hir_def::hir::LabelId;
2222
use hir_def::{
2323
body::Body,
2424
builtin_type::{BuiltinInt, BuiltinType, BuiltinUint},
2525
data::{ConstData, StaticData},
26-
expr::{BindingAnnotation, BindingId, ExprId, ExprOrPatId, PatId},
26+
hir::{BindingAnnotation, BindingId, ExprId, ExprOrPatId, PatId},
2727
lang_item::{LangItem, LangItemTarget},
2828
layout::Integer,
2929
path::{ModPath, Path},

crates/hir-ty/src/infer/closure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Inference of closure parameter types based on the closure's expected type.
22
33
use chalk_ir::{cast::Cast, AliasEq, AliasTy, FnSubst, WhereClause};
4-
use hir_def::{expr::ExprId, HasModule};
4+
use hir_def::{hir::ExprId, HasModule};
55
use smallvec::SmallVec;
66

77
use crate::{

crates/hir-ty/src/infer/coerce.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::{iter, sync::Arc};
99

1010
use chalk_ir::{cast::Cast, BoundVar, Goal, Mutability, TyVariableKind};
1111
use hir_def::{
12-
expr::ExprId,
12+
hir::ExprId,
1313
lang_item::{LangItem, LangItemTarget},
1414
};
1515
use stdx::always;

crates/hir-ty/src/infer/expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ use chalk_ir::{
1010
cast::Cast, fold::Shift, DebruijnIndex, GenericArgData, Mutability, TyKind, TyVariableKind,
1111
};
1212
use hir_def::{
13-
expr::{
13+
generics::TypeOrConstParamData,
14+
hir::{
1415
ArithOp, Array, BinaryOp, ClosureKind, Expr, ExprId, LabelId, Literal, Statement, UnaryOp,
1516
},
16-
generics::TypeOrConstParamData,
1717
lang_item::LangItem,
1818
path::{GenericArg, GenericArgs},
1919
BlockId, ConstParamId, FieldId, ItemContainerId, Lookup,

crates/hir-ty/src/infer/mutability.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
use chalk_ir::Mutability;
55
use hir_def::{
6-
expr::{Array, BindingAnnotation, Expr, ExprId, PatId, Statement, UnaryOp},
6+
hir::{Array, BindingAnnotation, Expr, ExprId, PatId, Statement, UnaryOp},
77
lang_item::LangItem,
88
};
99
use hir_expand::name;

crates/hir-ty/src/infer/pat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::iter::repeat_with;
55
use chalk_ir::Mutability;
66
use hir_def::{
77
body::Body,
8-
expr::{Binding, BindingAnnotation, BindingId, Expr, ExprId, ExprOrPatId, Literal, Pat, PatId},
8+
hir::{Binding, BindingAnnotation, BindingId, Expr, ExprId, ExprOrPatId, Literal, Pat, PatId},
99
path::Path,
1010
};
1111
use hir_expand::name::Name;

crates/hir-ty/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use chalk_ir::{
4444
NoSolution, TyData,
4545
};
4646
use either::Either;
47-
use hir_def::{expr::ExprId, type_ref::Rawness, TypeOrConstParamId};
47+
use hir_def::{hir::ExprId, type_ref::Rawness, TypeOrConstParamId};
4848
use hir_expand::name;
4949
use la_arena::{Arena, Idx};
5050
use mir::MirEvalError;

crates/hir-ty/src/mir.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::{
77
};
88
use chalk_ir::Mutability;
99
use hir_def::{
10-
expr::{BindingId, Expr, ExprId, Ordering, PatId},
10+
hir::{BindingId, Expr, ExprId, Ordering, PatId},
1111
DefWithBodyId, FieldId, UnionId, VariantId,
1212
};
1313
use la_arena::{Arena, ArenaMap, Idx, RawIdx};
@@ -588,32 +588,32 @@ impl Display for BinOp {
588588
}
589589
}
590590

591-
impl From<hir_def::expr::ArithOp> for BinOp {
592-
fn from(value: hir_def::expr::ArithOp) -> Self {
591+
impl From<hir_def::hir::ArithOp> for BinOp {
592+
fn from(value: hir_def::hir::ArithOp) -> Self {
593593
match value {
594-
hir_def::expr::ArithOp::Add => BinOp::Add,
595-
hir_def::expr::ArithOp::Mul => BinOp::Mul,
596-
hir_def::expr::ArithOp::Sub => BinOp::Sub,
597-
hir_def::expr::ArithOp::Div => BinOp::Div,
598-
hir_def::expr::ArithOp::Rem => BinOp::Rem,
599-
hir_def::expr::ArithOp::Shl => BinOp::Shl,
600-
hir_def::expr::ArithOp::Shr => BinOp::Shr,
601-
hir_def::expr::ArithOp::BitXor => BinOp::BitXor,
602-
hir_def::expr::ArithOp::BitOr => BinOp::BitOr,
603-
hir_def::expr::ArithOp::BitAnd => BinOp::BitAnd,
594+
hir_def::hir::ArithOp::Add => BinOp::Add,
595+
hir_def::hir::ArithOp::Mul => BinOp::Mul,
596+
hir_def::hir::ArithOp::Sub => BinOp::Sub,
597+
hir_def::hir::ArithOp::Div => BinOp::Div,
598+
hir_def::hir::ArithOp::Rem => BinOp::Rem,
599+
hir_def::hir::ArithOp::Shl => BinOp::Shl,
600+
hir_def::hir::ArithOp::Shr => BinOp::Shr,
601+
hir_def::hir::ArithOp::BitXor => BinOp::BitXor,
602+
hir_def::hir::ArithOp::BitOr => BinOp::BitOr,
603+
hir_def::hir::ArithOp::BitAnd => BinOp::BitAnd,
604604
}
605605
}
606606
}
607607

608-
impl From<hir_def::expr::CmpOp> for BinOp {
609-
fn from(value: hir_def::expr::CmpOp) -> Self {
608+
impl From<hir_def::hir::CmpOp> for BinOp {
609+
fn from(value: hir_def::hir::CmpOp) -> Self {
610610
match value {
611-
hir_def::expr::CmpOp::Eq { negated: false } => BinOp::Eq,
612-
hir_def::expr::CmpOp::Eq { negated: true } => BinOp::Ne,
613-
hir_def::expr::CmpOp::Ord { ordering: Ordering::Greater, strict: false } => BinOp::Ge,
614-
hir_def::expr::CmpOp::Ord { ordering: Ordering::Greater, strict: true } => BinOp::Gt,
615-
hir_def::expr::CmpOp::Ord { ordering: Ordering::Less, strict: false } => BinOp::Le,
616-
hir_def::expr::CmpOp::Ord { ordering: Ordering::Less, strict: true } => BinOp::Lt,
611+
hir_def::hir::CmpOp::Eq { negated: false } => BinOp::Eq,
612+
hir_def::hir::CmpOp::Eq { negated: true } => BinOp::Ne,
613+
hir_def::hir::CmpOp::Ord { ordering: Ordering::Greater, strict: false } => BinOp::Ge,
614+
hir_def::hir::CmpOp::Ord { ordering: Ordering::Greater, strict: true } => BinOp::Gt,
615+
hir_def::hir::CmpOp::Ord { ordering: Ordering::Less, strict: false } => BinOp::Le,
616+
hir_def::hir::CmpOp::Ord { ordering: Ordering::Less, strict: true } => BinOp::Lt,
617617
}
618618
}
619619
}

0 commit comments

Comments
 (0)