diff --git a/crates/hir-def/src/attr.rs b/crates/hir-def/src/attr.rs index 4dde093f9689..9224773aa804 100644 --- a/crates/hir-def/src/attr.rs +++ b/crates/hir-def/src/attr.rs @@ -1,5 +1,7 @@ //! A higher level attributes based on TokenTree, with also some shortcuts. +pub mod builtin; + #[cfg(test)] mod tests; diff --git a/crates/hir-def/src/builtin_attr.rs b/crates/hir-def/src/attr/builtin.rs similarity index 100% rename from crates/hir-def/src/builtin_attr.rs rename to crates/hir-def/src/attr/builtin.rs diff --git a/crates/hir-def/src/body.rs b/crates/hir-def/src/body.rs index 0bea905e115f..faa3a8931b03 100644 --- a/crates/hir-def/src/body.rs +++ b/crates/hir-def/src/body.rs @@ -25,7 +25,7 @@ use syntax::{ast, AstPtr, SyntaxNode, SyntaxNodePtr}; use crate::{ attr::Attrs, db::DefDatabase, - expr::{ + hir::{ dummy_expr_id, Binding, BindingId, Expr, ExprId, Label, LabelId, Pat, PatId, RecordFieldPat, }, item_scope::BuiltinShadowMode, diff --git a/crates/hir-def/src/body/lower.rs b/crates/hir-def/src/body/lower.rs index 91eeff5b0eb0..8d12d728f7cc 100644 --- a/crates/hir-def/src/body/lower.rs +++ b/crates/hir-def/src/body/lower.rs @@ -26,12 +26,14 @@ use syntax::{ }; use crate::{ - adt::StructKind, - body::{Body, BodySourceMap, Expander, ExprPtr, LabelPtr, LabelSource, PatPtr}, - body::{BodyDiagnostic, ExprSource, PatSource}, + body::{ + Body, BodyDiagnostic, BodySourceMap, Expander, ExprPtr, ExprSource, LabelPtr, LabelSource, + PatPtr, PatSource, + }, builtin_type::{BuiltinFloat, BuiltinInt, BuiltinUint}, + data::adt::StructKind, db::DefDatabase, - expr::{ + hir::{ dummy_expr_id, Array, Binding, BindingAnnotation, BindingId, ClosureKind, Expr, ExprId, FloatTypeWrapper, Label, LabelId, Literal, MatchArm, Movability, Pat, PatId, RecordFieldPat, RecordLitField, Statement, diff --git a/crates/hir-def/src/body/pretty.rs b/crates/hir-def/src/body/pretty.rs index 9ac42c86214d..0a5bcb557978 100644 --- a/crates/hir-def/src/body/pretty.rs +++ b/crates/hir-def/src/body/pretty.rs @@ -5,7 +5,7 @@ use std::fmt::{self, Write}; use syntax::ast::HasName; 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}, type_ref::TypeRef, }; diff --git a/crates/hir-def/src/body/scope.rs b/crates/hir-def/src/body/scope.rs index 8fe20da74778..f3f9aa79461f 100644 --- a/crates/hir-def/src/body/scope.rs +++ b/crates/hir-def/src/body/scope.rs @@ -8,7 +8,7 @@ use rustc_hash::FxHashMap; use crate::{ body::Body, db::DefDatabase, - expr::{Binding, BindingId, Expr, ExprId, LabelId, Pat, PatId, Statement}, + hir::{Binding, BindingId, Expr, ExprId, LabelId, Pat, PatId, Statement}, BlockId, DefWithBodyId, }; diff --git a/crates/hir-def/src/child_by_source.rs b/crates/hir-def/src/child_by_source.rs index 68b57acca2ad..21180fcbdae4 100644 --- a/crates/hir-def/src/child_by_source.rs +++ b/crates/hir-def/src/child_by_source.rs @@ -10,9 +10,8 @@ use syntax::ast::HasDocComments; use crate::{ db::DefDatabase, - dyn_map::DynMap, + dyn_map::{keys, DynMap}, item_scope::ItemScope, - keys, src::{HasChildSource, HasSource}, AdtId, AssocItemId, DefWithBodyId, EnumId, EnumVariantId, FieldId, ImplId, Lookup, MacroId, ModuleDefId, ModuleId, TraitId, VariantId, diff --git a/crates/hir-def/src/data.rs b/crates/hir-def/src/data.rs index 431140a665d7..9d368911a4c1 100644 --- a/crates/hir-def/src/data.rs +++ b/crates/hir-def/src/data.rs @@ -1,5 +1,7 @@ //! Contains basic data about various HIR declarations. +pub mod adt; + use std::sync::Arc; use hir_expand::{name::Name, AstId, ExpandResult, HirFileId, InFile, MacroCallId, MacroDefKind}; diff --git a/crates/hir-def/src/adt.rs b/crates/hir-def/src/data/adt.rs similarity index 100% rename from crates/hir-def/src/adt.rs rename to crates/hir-def/src/data/adt.rs diff --git a/crates/hir-def/src/db.rs b/crates/hir-def/src/db.rs index 8d236aca3674..2dfe4b626484 100644 --- a/crates/hir-def/src/db.rs +++ b/crates/hir-def/src/db.rs @@ -9,10 +9,10 @@ use la_arena::ArenaMap; use syntax::{ast, AstPtr}; use crate::{ - adt::{EnumData, StructData}, attr::{Attrs, AttrsWithOwner}, body::{scope::ExprScopes, Body, BodySourceMap}, data::{ + adt::{EnumData, StructData}, ConstData, FunctionData, ImplData, Macro2Data, MacroRulesData, ProcMacroData, StaticData, TraitAliasData, TraitData, TypeAliasData, }, diff --git a/crates/hir-def/src/dyn_map.rs b/crates/hir-def/src/dyn_map.rs index 166aa04da044..63138aa6ad78 100644 --- a/crates/hir-def/src/dyn_map.rs +++ b/crates/hir-def/src/dyn_map.rs @@ -21,6 +21,8 @@ //! //! This is a work of fiction. Any similarities to Kotlin's `BindingContext` are //! a coincidence. +pub mod keys; + use std::{ hash::Hash, marker::PhantomData, diff --git a/crates/hir-def/src/keys.rs b/crates/hir-def/src/dyn_map/keys.rs similarity index 100% rename from crates/hir-def/src/keys.rs rename to crates/hir-def/src/dyn_map/keys.rs diff --git a/crates/hir-def/src/generics.rs b/crates/hir-def/src/generics.rs index e4912fa8a64a..354b8fd0af4a 100644 --- a/crates/hir-def/src/generics.rs +++ b/crates/hir-def/src/generics.rs @@ -20,8 +20,7 @@ use crate::{ body::{Expander, LowerCtx}, child_by_source::ChildBySource, db::DefDatabase, - dyn_map::DynMap, - keys, + dyn_map::{keys, DynMap}, src::{HasChildSource, HasSource}, type_ref::{LifetimeRef, TypeBound, TypeRef}, AdtId, ConstParamId, GenericDefId, HasModule, LifetimeParamId, LocalLifetimeParamId, diff --git a/crates/hir-def/src/expr.rs b/crates/hir-def/src/hir.rs similarity index 99% rename from crates/hir-def/src/expr.rs rename to crates/hir-def/src/hir.rs index 9e83d8ab118d..cdd3a93a2936 100644 --- a/crates/hir-def/src/expr.rs +++ b/crates/hir-def/src/hir.rs @@ -12,6 +12,8 @@ //! //! See also a neighboring `body` module. +pub mod type_ref; + use std::fmt; use hir_expand::name::Name; @@ -28,10 +30,10 @@ use crate::{ pub use syntax::ast::{ArithOp, BinaryOp, CmpOp, LogicOp, Ordering, RangeOp, UnaryOp}; -pub type ExprId = Idx; - pub type BindingId = Idx; +pub type ExprId = Idx; + /// FIXME: this is a hacky function which should be removed pub(crate) fn dummy_expr_id() -> ExprId { ExprId::from_raw(RawIdx::from(u32::MAX)) diff --git a/crates/hir-def/src/type_ref.rs b/crates/hir-def/src/hir/type_ref.rs similarity index 99% rename from crates/hir-def/src/type_ref.rs rename to crates/hir-def/src/hir/type_ref.rs index 8e30f429a9f8..0e2c0d864dc1 100644 --- a/crates/hir-def/src/type_ref.rs +++ b/crates/hir-def/src/hir/type_ref.rs @@ -13,7 +13,7 @@ use syntax::ast::{self, HasName}; use crate::{ body::LowerCtx, builtin_type::{BuiltinInt, BuiltinType, BuiltinUint}, - expr::Literal, + hir::Literal, path::Path, }; diff --git a/crates/hir-def/src/lib.rs b/crates/hir-def/src/lib.rs index 8c2e93f09059..65c33322b1dc 100644 --- a/crates/hir-def/src/lib.rs +++ b/crates/hir-def/src/lib.rs @@ -18,24 +18,21 @@ pub mod db; pub mod attr; pub mod path; -pub mod type_ref; pub mod builtin_type; -pub mod builtin_attr; pub mod per_ns; pub mod item_scope; pub mod dyn_map; -pub mod keys; pub mod item_tree; -pub mod adt; pub mod data; pub mod generics; pub mod lang_item; pub mod layout; -pub mod expr; +pub mod hir; +pub use self::hir::type_ref; pub mod body; pub mod resolver; @@ -82,8 +79,8 @@ use syntax::ast; use ::tt::token_id as tt; use crate::{ - adt::VariantData, builtin_type::BuiltinType, + data::adt::VariantData, item_tree::{ Const, Enum, Function, Impl, ItemTreeId, ItemTreeNode, MacroDef, MacroRules, ModItem, Static, Struct, Trait, TraitAlias, TypeAlias, Union, @@ -236,7 +233,7 @@ pub struct EnumVariantId { pub local_id: LocalEnumVariantId, } -pub type LocalEnumVariantId = Idx; +pub type LocalEnumVariantId = Idx; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct FieldId { @@ -244,7 +241,7 @@ pub struct FieldId { pub local_id: LocalFieldId, } -pub type LocalFieldId = Idx; +pub type LocalFieldId = Idx; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct ConstId(salsa::InternId); diff --git a/crates/hir-def/src/macro_expansion_tests.rs b/crates/hir-def/src/macro_expansion_tests/mod.rs similarity index 100% rename from crates/hir-def/src/macro_expansion_tests.rs rename to crates/hir-def/src/macro_expansion_tests/mod.rs diff --git a/crates/hir-def/src/nameres/attr_resolution.rs b/crates/hir-def/src/nameres/attr_resolution.rs index 79cabeb0fb7a..6fad01ec2f75 100644 --- a/crates/hir-def/src/nameres/attr_resolution.rs +++ b/crates/hir-def/src/nameres/attr_resolution.rs @@ -4,7 +4,8 @@ use hir_expand::{attrs::Attr, MacroCallId}; use syntax::{ast, SmolStr}; use crate::{ - attr_macro_as_call_id, builtin_attr, + attr::builtin::{find_builtin_attr_idx, TOOL_MODULES}, + attr_macro_as_call_id, db::DefDatabase, item_scope::BuiltinShadowMode, macro_id_to_def_id, @@ -76,19 +77,15 @@ impl DefMap { let pred = |n: &_| *n == name; let registered = self.registered_tools.iter().map(SmolStr::as_str); - let is_tool = builtin_attr::TOOL_MODULES.iter().copied().chain(registered).any(pred); + let is_tool = TOOL_MODULES.iter().copied().chain(registered).any(pred); // FIXME: tool modules can be shadowed by actual modules if is_tool { return true; } if segments.len() == 1 { - let registered = self.registered_attrs.iter().map(SmolStr::as_str); - let is_inert = builtin_attr::INERT_ATTRIBUTES - .iter() - .map(|it| it.name) - .chain(registered) - .any(pred); + let mut registered = self.registered_attrs.iter().map(SmolStr::as_str); + let is_inert = find_builtin_attr_idx(&name).is_some() || registered.any(pred); return is_inert; } } diff --git a/crates/hir-def/src/nameres/path_resolution.rs b/crates/hir-def/src/nameres/path_resolution.rs index 25478481dd0b..8299d9684bbb 100644 --- a/crates/hir-def/src/nameres/path_resolution.rs +++ b/crates/hir-def/src/nameres/path_resolution.rs @@ -331,11 +331,11 @@ impl DefMap { Some(local_id) => { let variant = EnumVariantId { parent: e, local_id }; match &*enum_data.variants[local_id].variant_data { - crate::adt::VariantData::Record(_) => { + crate::data::adt::VariantData::Record(_) => { PerNs::types(variant.into(), Visibility::Public) } - crate::adt::VariantData::Tuple(_) - | crate::adt::VariantData::Unit => { + crate::data::adt::VariantData::Tuple(_) + | crate::data::adt::VariantData::Unit => { PerNs::both(variant.into(), variant.into(), Visibility::Public) } } diff --git a/crates/hir-def/src/resolver.rs b/crates/hir-def/src/resolver.rs index 9afe07932ecc..670495e4d16f 100644 --- a/crates/hir-def/src/resolver.rs +++ b/crates/hir-def/src/resolver.rs @@ -12,8 +12,8 @@ use crate::{ body::scope::{ExprScopes, ScopeId}, builtin_type::BuiltinType, db::DefDatabase, - expr::{BindingId, ExprId, LabelId}, generics::{GenericParams, TypeOrConstParamData}, + hir::{BindingId, ExprId, LabelId}, item_scope::{BuiltinShadowMode, BUILTIN_SCOPE}, lang_item::LangItemTarget, nameres::DefMap, diff --git a/crates/hir-ty/src/chalk_db.rs b/crates/hir-ty/src/chalk_db.rs index 94123ed23eae..c30a99e06ca5 100644 --- a/crates/hir-ty/src/chalk_db.rs +++ b/crates/hir-ty/src/chalk_db.rs @@ -9,7 +9,7 @@ use chalk_solve::rust_ir::{self, OpaqueTyDatumBound, WellKnownTrait}; use base_db::CrateId; use hir_def::{ - expr::Movability, + hir::Movability, lang_item::{lang_attr, LangItem, LangItemTarget}, AssocItemId, BlockId, GenericDefId, HasModule, ItemContainerId, Lookup, TypeAliasId, }; @@ -415,8 +415,8 @@ impl<'a> chalk_solve::RustIrDatabase for ChalkContext<'a> { let input_output = crate::make_type_and_const_binders(it, input_output); let movability = match self.db.body(parent)[expr] { - hir_def::expr::Expr::Closure { - closure_kind: hir_def::expr::ClosureKind::Generator(movability), + hir_def::hir::Expr::Closure { + closure_kind: hir_def::hir::ClosureKind::Generator(movability), .. } => movability, _ => unreachable!("non generator expression interned as generator"), diff --git a/crates/hir-ty/src/consteval.rs b/crates/hir-ty/src/consteval.rs index 7e69971fee78..78033b4e89b5 100644 --- a/crates/hir-ty/src/consteval.rs +++ b/crates/hir-ty/src/consteval.rs @@ -3,7 +3,7 @@ use base_db::CrateId; use chalk_ir::{BoundVar, DebruijnIndex, GenericArgData}; use hir_def::{ - expr::Expr, + hir::Expr, path::Path, resolver::{Resolver, ValueNs}, type_ref::ConstRef, diff --git a/crates/hir-ty/src/db.rs b/crates/hir-ty/src/db.rs index 56f5d90bb351..e11770e12313 100644 --- a/crates/hir-ty/src/db.rs +++ b/crates/hir-ty/src/db.rs @@ -6,7 +6,7 @@ use std::sync::Arc; use base_db::{impl_intern_key, salsa, CrateId, Upcast}; use hir_def::{ db::DefDatabase, - expr::ExprId, + hir::ExprId, layout::{Layout, LayoutError, TargetDataLayout}, AdtId, BlockId, ConstId, ConstParamId, DefWithBodyId, EnumVariantId, FunctionId, GenericDefId, ImplId, LifetimeParamId, LocalFieldId, TypeOrConstParamId, VariantId, diff --git a/crates/hir-ty/src/diagnostics/decl_check.rs b/crates/hir-ty/src/diagnostics/decl_check.rs index d36b93e3bdde..b3a699e2d1b3 100644 --- a/crates/hir-ty/src/diagnostics/decl_check.rs +++ b/crates/hir-ty/src/diagnostics/decl_check.rs @@ -16,8 +16,8 @@ use std::fmt; use base_db::CrateId; use hir_def::{ - adt::VariantData, - expr::{Pat, PatId}, + data::adt::VariantData, + hir::{Pat, PatId}, src::HasSource, AdtId, AttrDefId, ConstId, EnumId, FunctionId, ItemContainerId, Lookup, ModuleDefId, StaticId, StructId, diff --git a/crates/hir-ty/src/diagnostics/expr.rs b/crates/hir-ty/src/diagnostics/expr.rs index 2e9066788cf6..d39e077b716f 100644 --- a/crates/hir-ty/src/diagnostics/expr.rs +++ b/crates/hir-ty/src/diagnostics/expr.rs @@ -27,7 +27,7 @@ use crate::{ pub(crate) use hir_def::{ body::Body, - expr::{Expr, ExprId, MatchArm, Pat, PatId}, + hir::{Expr, ExprId, MatchArm, Pat, PatId}, LocalFieldId, VariantId, }; diff --git a/crates/hir-ty/src/diagnostics/match_check.rs b/crates/hir-ty/src/diagnostics/match_check.rs index fe1cda71dd58..202f4aa66bce 100644 --- a/crates/hir-ty/src/diagnostics/match_check.rs +++ b/crates/hir-ty/src/diagnostics/match_check.rs @@ -1,6 +1,6 @@ //! 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. //! //! 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 hir_def::{ - adt::VariantData, body::Body, expr::PatId, AdtId, EnumVariantId, LocalFieldId, VariantId, + body::Body, data::adt::VariantData, hir::PatId, AdtId, EnumVariantId, LocalFieldId, VariantId, }; use hir_expand::name::Name; use stdx::{always, never}; @@ -125,15 +125,15 @@ impl<'a> PatCtxt<'a> { let variant = self.infer.variant_resolution_for_pat(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); } - hir_def::expr::Pat::Tuple { ref args, ellipsis } => { + hir_def::hir::Pat::Tuple { ref args, ellipsis } => { let arity = match *ty.kind(Interner) { TyKind::Tuple(arity, _) => arity, _ => { @@ -146,7 +146,7 @@ impl<'a> PatCtxt<'a> { 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 name = &self.body.bindings[id].name; match (bm, ty.kind(Interner)) { @@ -161,13 +161,13 @@ impl<'a> PatCtxt<'a> { 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 subpatterns = self.lower_tuple_subpats(args, expected_len, ellipsis); 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 subpatterns = args .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); 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); @@ -279,8 +279,8 @@ impl<'a> PatCtxt<'a> { } } - fn lower_lit(&mut self, expr: hir_def::expr::ExprId) -> PatKind { - use hir_def::expr::{Expr, Literal::Bool}; + fn lower_lit(&mut self, expr: hir_def::hir::ExprId) -> PatKind { + use hir_def::hir::{Expr, Literal::Bool}; match self.body[expr] { Expr::Literal(Bool(value)) => PatKind::LiteralBool { value }, diff --git a/crates/hir-ty/src/diagnostics/unsafe_check.rs b/crates/hir-ty/src/diagnostics/unsafe_check.rs index 664822ee6fb4..7c38e6583a75 100644 --- a/crates/hir-ty/src/diagnostics/unsafe_check.rs +++ b/crates/hir-ty/src/diagnostics/unsafe_check.rs @@ -3,7 +3,7 @@ use hir_def::{ body::Body, - expr::{Expr, ExprId, UnaryOp}, + hir::{Expr, ExprId, UnaryOp}, resolver::{resolver_for_expr, ResolveValueResult, ValueNs}, DefWithBodyId, }; diff --git a/crates/hir-ty/src/display.rs b/crates/hir-ty/src/display.rs index bd3eccfe43da..f1a649157c35 100644 --- a/crates/hir-ty/src/display.rs +++ b/crates/hir-ty/src/display.rs @@ -7,8 +7,8 @@ use std::fmt::{self, Debug}; use base_db::CrateId; use chalk_ir::{BoundVar, TyKind}; use hir_def::{ - adt::VariantData, body, + data::adt::VariantData, db::DefDatabase, find_path, generics::{TypeOrConstParamData, TypeParamProvenance}, diff --git a/crates/hir-ty/src/infer.rs b/crates/hir-ty/src/infer.rs index c1012cc3d9ce..76fd3effc058 100644 --- a/crates/hir-ty/src/infer.rs +++ b/crates/hir-ty/src/infer.rs @@ -18,12 +18,12 @@ use std::{convert::identity, ops::Index}; use chalk_ir::{cast::Cast, DebruijnIndex, Mutability, Safety, Scalar, TypeFlags}; use either::Either; -use hir_def::expr::LabelId; +use hir_def::hir::LabelId; use hir_def::{ body::Body, builtin_type::{BuiltinInt, BuiltinType, BuiltinUint}, data::{ConstData, StaticData}, - expr::{BindingAnnotation, BindingId, ExprId, ExprOrPatId, PatId}, + hir::{BindingAnnotation, BindingId, ExprId, ExprOrPatId, PatId}, lang_item::{LangItem, LangItemTarget}, layout::Integer, path::{ModPath, Path}, diff --git a/crates/hir-ty/src/infer/closure.rs b/crates/hir-ty/src/infer/closure.rs index a6449d019ff6..916f29466f37 100644 --- a/crates/hir-ty/src/infer/closure.rs +++ b/crates/hir-ty/src/infer/closure.rs @@ -1,7 +1,7 @@ //! Inference of closure parameter types based on the closure's expected type. 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 crate::{ diff --git a/crates/hir-ty/src/infer/coerce.rs b/crates/hir-ty/src/infer/coerce.rs index 96c35bbb8c4a..f2e1ab269c71 100644 --- a/crates/hir-ty/src/infer/coerce.rs +++ b/crates/hir-ty/src/infer/coerce.rs @@ -9,7 +9,7 @@ use std::{iter, sync::Arc}; use chalk_ir::{cast::Cast, BoundVar, Goal, Mutability, TyVariableKind}; use hir_def::{ - expr::ExprId, + hir::ExprId, lang_item::{LangItem, LangItemTarget}, }; use stdx::always; diff --git a/crates/hir-ty/src/infer/expr.rs b/crates/hir-ty/src/infer/expr.rs index 129ff33ae5db..7180b88d6a6e 100644 --- a/crates/hir-ty/src/infer/expr.rs +++ b/crates/hir-ty/src/infer/expr.rs @@ -10,10 +10,10 @@ use chalk_ir::{ cast::Cast, fold::Shift, DebruijnIndex, GenericArgData, Mutability, TyKind, TyVariableKind, }; use hir_def::{ - expr::{ + generics::TypeOrConstParamData, + hir::{ ArithOp, Array, BinaryOp, ClosureKind, Expr, ExprId, LabelId, Literal, Statement, UnaryOp, }, - generics::TypeOrConstParamData, lang_item::LangItem, path::{GenericArg, GenericArgs}, BlockId, ConstParamId, FieldId, ItemContainerId, Lookup, diff --git a/crates/hir-ty/src/infer/mutability.rs b/crates/hir-ty/src/infer/mutability.rs index 6f5ca2cf95de..52f356342152 100644 --- a/crates/hir-ty/src/infer/mutability.rs +++ b/crates/hir-ty/src/infer/mutability.rs @@ -3,7 +3,7 @@ use chalk_ir::Mutability; use hir_def::{ - expr::{Array, BindingAnnotation, Expr, ExprId, PatId, Statement, UnaryOp}, + hir::{Array, BindingAnnotation, Expr, ExprId, PatId, Statement, UnaryOp}, lang_item::LangItem, }; use hir_expand::name; diff --git a/crates/hir-ty/src/infer/pat.rs b/crates/hir-ty/src/infer/pat.rs index 5f839fc307aa..ce179210d34f 100644 --- a/crates/hir-ty/src/infer/pat.rs +++ b/crates/hir-ty/src/infer/pat.rs @@ -5,7 +5,7 @@ use std::iter::repeat_with; use chalk_ir::Mutability; use hir_def::{ body::Body, - expr::{Binding, BindingAnnotation, BindingId, Expr, ExprId, ExprOrPatId, Literal, Pat, PatId}, + hir::{Binding, BindingAnnotation, BindingId, Expr, ExprId, ExprOrPatId, Literal, Pat, PatId}, path::Path, }; use hir_expand::name::Name; diff --git a/crates/hir-ty/src/inhabitedness.rs b/crates/hir-ty/src/inhabitedness.rs index 39324d27306b..25b226bb3b55 100644 --- a/crates/hir-ty/src/inhabitedness.rs +++ b/crates/hir-ty/src/inhabitedness.rs @@ -6,8 +6,8 @@ use chalk_ir::{ DebruijnIndex, }; use hir_def::{ - adt::VariantData, attr::Attrs, visibility::Visibility, AdtId, EnumVariantId, HasModule, Lookup, - ModuleId, VariantId, + attr::Attrs, data::adt::VariantData, visibility::Visibility, AdtId, EnumVariantId, HasModule, + Lookup, ModuleId, VariantId, }; use rustc_hash::FxHashSet; diff --git a/crates/hir-ty/src/lang_items.rs b/crates/hir-ty/src/lang_items.rs index b0ad4fc946a8..adfdb01e72af 100644 --- a/crates/hir-ty/src/lang_items.rs +++ b/crates/hir-ty/src/lang_items.rs @@ -1,6 +1,6 @@ //! Functions to detect special lang items -use hir_def::{adt::StructFlags, lang_item::LangItem, AdtId}; +use hir_def::{data::adt::StructFlags, lang_item::LangItem, AdtId}; use hir_expand::name::Name; use crate::db::HirDatabase; diff --git a/crates/hir-ty/src/layout/adt.rs b/crates/hir-ty/src/layout/adt.rs index 18199f327d14..3f3017deee9a 100644 --- a/crates/hir-ty/src/layout/adt.rs +++ b/crates/hir-ty/src/layout/adt.rs @@ -3,7 +3,7 @@ use std::ops::Bound; use hir_def::{ - adt::VariantData, + data::adt::VariantData, layout::{Integer, IntegerExt, Layout, LayoutCalculator, LayoutError, RustcEnumVariantIdx}, AdtId, EnumVariantId, HasModule, LocalEnumVariantId, VariantId, }; diff --git a/crates/hir-ty/src/lib.rs b/crates/hir-ty/src/lib.rs index c36fad614f8d..50fe5a724d09 100644 --- a/crates/hir-ty/src/lib.rs +++ b/crates/hir-ty/src/lib.rs @@ -44,7 +44,7 @@ use chalk_ir::{ NoSolution, TyData, }; 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 la_arena::{Arena, Idx}; use mir::MirEvalError; diff --git a/crates/hir-ty/src/lower.rs b/crates/hir-ty/src/lower.rs index adadbb888ba9..c4326f98cd7a 100644 --- a/crates/hir-ty/src/lower.rs +++ b/crates/hir-ty/src/lower.rs @@ -18,9 +18,9 @@ use chalk_ir::{ use either::Either; use hir_def::{ - adt::StructKind, body::{Expander, LowerCtx}, builtin_type::BuiltinType, + data::adt::StructKind, generics::{ TypeOrConstParamData, TypeParamProvenance, WherePredicate, WherePredicateTypeTarget, }, diff --git a/crates/hir-ty/src/method_resolution.rs b/crates/hir-ty/src/method_resolution.rs index 5d06906aa3a9..b04029d54bc9 100644 --- a/crates/hir-ty/src/method_resolution.rs +++ b/crates/hir-ty/src/method_resolution.rs @@ -7,9 +7,11 @@ use std::{ops::ControlFlow, sync::Arc}; use base_db::{CrateId, Edition}; use chalk_ir::{cast::Cast, Mutability, TyKind, UniverseIndex, WhereClause}; use hir_def::{ - adt::StructFlags, data::ImplData, item_scope::ItemScope, nameres::DefMap, AssocItemId, BlockId, - ConstId, FunctionId, HasModule, ImplId, ItemContainerId, Lookup, ModuleDefId, ModuleId, - TraitId, + data::{adt::StructFlags, ImplData}, + item_scope::ItemScope, + nameres::DefMap, + AssocItemId, BlockId, ConstId, FunctionId, HasModule, ImplId, ItemContainerId, Lookup, + ModuleDefId, ModuleId, TraitId, }; use hir_expand::name::Name; use rustc_hash::{FxHashMap, FxHashSet}; diff --git a/crates/hir-ty/src/mir.rs b/crates/hir-ty/src/mir.rs index 7c1cbbdf53d2..ab5f199a0383 100644 --- a/crates/hir-ty/src/mir.rs +++ b/crates/hir-ty/src/mir.rs @@ -7,7 +7,7 @@ use crate::{ }; use chalk_ir::Mutability; use hir_def::{ - expr::{BindingId, Expr, ExprId, Ordering, PatId}, + hir::{BindingId, Expr, ExprId, Ordering, PatId}, DefWithBodyId, FieldId, UnionId, VariantId, }; use la_arena::{Arena, ArenaMap, Idx, RawIdx}; @@ -588,32 +588,32 @@ impl Display for BinOp { } } -impl From for BinOp { - fn from(value: hir_def::expr::ArithOp) -> Self { +impl From for BinOp { + fn from(value: hir_def::hir::ArithOp) -> Self { match value { - hir_def::expr::ArithOp::Add => BinOp::Add, - hir_def::expr::ArithOp::Mul => BinOp::Mul, - hir_def::expr::ArithOp::Sub => BinOp::Sub, - hir_def::expr::ArithOp::Div => BinOp::Div, - hir_def::expr::ArithOp::Rem => BinOp::Rem, - hir_def::expr::ArithOp::Shl => BinOp::Shl, - hir_def::expr::ArithOp::Shr => BinOp::Shr, - hir_def::expr::ArithOp::BitXor => BinOp::BitXor, - hir_def::expr::ArithOp::BitOr => BinOp::BitOr, - hir_def::expr::ArithOp::BitAnd => BinOp::BitAnd, + hir_def::hir::ArithOp::Add => BinOp::Add, + hir_def::hir::ArithOp::Mul => BinOp::Mul, + hir_def::hir::ArithOp::Sub => BinOp::Sub, + hir_def::hir::ArithOp::Div => BinOp::Div, + hir_def::hir::ArithOp::Rem => BinOp::Rem, + hir_def::hir::ArithOp::Shl => BinOp::Shl, + hir_def::hir::ArithOp::Shr => BinOp::Shr, + hir_def::hir::ArithOp::BitXor => BinOp::BitXor, + hir_def::hir::ArithOp::BitOr => BinOp::BitOr, + hir_def::hir::ArithOp::BitAnd => BinOp::BitAnd, } } } -impl From for BinOp { - fn from(value: hir_def::expr::CmpOp) -> Self { +impl From for BinOp { + fn from(value: hir_def::hir::CmpOp) -> Self { match value { - hir_def::expr::CmpOp::Eq { negated: false } => BinOp::Eq, - hir_def::expr::CmpOp::Eq { negated: true } => BinOp::Ne, - hir_def::expr::CmpOp::Ord { ordering: Ordering::Greater, strict: false } => BinOp::Ge, - hir_def::expr::CmpOp::Ord { ordering: Ordering::Greater, strict: true } => BinOp::Gt, - hir_def::expr::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::Eq { negated: false } => BinOp::Eq, + hir_def::hir::CmpOp::Eq { negated: true } => BinOp::Ne, + hir_def::hir::CmpOp::Ord { ordering: Ordering::Greater, strict: false } => BinOp::Ge, + hir_def::hir::CmpOp::Ord { ordering: Ordering::Greater, strict: true } => BinOp::Gt, + hir_def::hir::CmpOp::Ord { ordering: Ordering::Less, strict: false } => BinOp::Le, + hir_def::hir::CmpOp::Ord { ordering: Ordering::Less, strict: true } => BinOp::Lt, } } } diff --git a/crates/hir-ty/src/mir/lower.rs b/crates/hir-ty/src/mir/lower.rs index 0aa5b4dc8d5c..7f3fdf343a2d 100644 --- a/crates/hir-ty/src/mir/lower.rs +++ b/crates/hir-ty/src/mir/lower.rs @@ -4,9 +4,9 @@ use std::{iter, mem, sync::Arc}; use chalk_ir::{BoundVar, ConstData, DebruijnIndex, TyKind}; use hir_def::{ - adt::{StructKind, VariantData}, body::Body, - expr::{ + data::adt::{StructKind, VariantData}, + hir::{ Array, BindingAnnotation, BindingId, ExprId, LabelId, Literal, MatchArm, Pat, PatId, RecordFieldPat, RecordLitField, }, @@ -713,20 +713,20 @@ impl MirLowerCtx<'_> { Ok(Some(current)) } 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 { return Ok(None); }; self.push_assignment(current, place, Operand::Copy(p).into(), expr_id.into()); 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 { return Ok(None); }; let operation = match op { - hir_def::expr::UnaryOp::Not => UnOp::Not, - hir_def::expr::UnaryOp::Neg => UnOp::Neg, + hir_def::hir::UnaryOp::Not => UnOp::Not, + hir_def::hir::UnaryOp::Neg => UnOp::Neg, _ => unreachable!(), }; self.push_assignment( @@ -739,7 +739,7 @@ impl MirLowerCtx<'_> { }, Expr::BinaryOp { lhs, rhs, op } => { 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() { not_supported!("assignment with arith op (like +=)"); } @@ -765,13 +765,13 @@ impl MirLowerCtx<'_> { place, Rvalue::CheckedBinaryOp( match op { - hir_def::expr::BinaryOp::LogicOp(op) => match op { - hir_def::expr::LogicOp::And => BinOp::BitAnd, // FIXME: make these short circuit - hir_def::expr::LogicOp::Or => BinOp::BitOr, + hir_def::hir::BinaryOp::LogicOp(op) => match op { + hir_def::hir::LogicOp::And => BinOp::BitAnd, // FIXME: make these short circuit + hir_def::hir::LogicOp::Or => BinOp::BitOr, }, - hir_def::expr::BinaryOp::ArithOp(op) => BinOp::from(op), - hir_def::expr::BinaryOp::CmpOp(op) => BinOp::from(op), - hir_def::expr::BinaryOp::Assignment { .. } => unreachable!(), // handled above + hir_def::hir::BinaryOp::ArithOp(op) => BinOp::from(op), + hir_def::hir::BinaryOp::CmpOp(op) => BinOp::from(op), + hir_def::hir::BinaryOp::Assignment { .. } => unreachable!(), // handled above }, lhs_op, rhs_op, @@ -910,7 +910,7 @@ impl MirLowerCtx<'_> { .size .bytes_usize(); let bytes = match l { - hir_def::expr::Literal::String(b) => { + hir_def::hir::Literal::String(b) => { let b = b.as_bytes(); let mut data = vec![]; data.extend(0usize.to_le_bytes()); @@ -919,7 +919,7 @@ impl MirLowerCtx<'_> { mm.insert(0, b.to_vec()); 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![]; data.extend(0usize.to_le_bytes()); data.extend(b.len().to_le_bytes()); @@ -927,11 +927,11 @@ impl MirLowerCtx<'_> { mm.insert(0, b.to_vec()); return Ok(Operand::from_concrete_const(data, mm, ty)); } - hir_def::expr::Literal::Char(c) => u32::from(*c).to_le_bytes().into(), - hir_def::expr::Literal::Bool(b) => vec![*b as u8], - hir_def::expr::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::expr::Literal::Float(f, _) => match size { + hir_def::hir::Literal::Char(c) => u32::from(*c).to_le_bytes().into(), + hir_def::hir::Literal::Bool(b) => vec![*b as u8], + hir_def::hir::Literal::Int(x, _) => x.to_le_bytes()[0..size].into(), + hir_def::hir::Literal::Uint(x, _) => x.to_le_bytes()[0..size].into(), + hir_def::hir::Literal::Float(f, _) => match size { 8 => f.into_f64().to_le_bytes().into(), 4 => f.into_f32().to_le_bytes().into(), _ => { @@ -1218,14 +1218,14 @@ impl MirLowerCtx<'_> { fn lower_block_to_place( &mut self, - statements: &[hir_def::expr::Statement], + statements: &[hir_def::hir::Statement], mut current: BasicBlockId, tail: Option, place: Place, ) -> Result>> { for statement in statements.iter() { 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 { let else_block; 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 { return Ok(None); }; diff --git a/crates/hir-ty/src/mir/lower/as_place.rs b/crates/hir-ty/src/mir/lower/as_place.rs index 91163e5bd61f..a1574f559369 100644 --- a/crates/hir-ty/src/mir/lower/as_place.rs +++ b/crates/hir-ty/src/mir/lower/as_place.rs @@ -141,7 +141,7 @@ impl MirLowerCtx<'_> { } } Expr::UnaryOp { expr, op } => match op { - hir_def::expr::UnaryOp::Deref => { + hir_def::hir::UnaryOp::Deref => { if !matches!( self.expr_ty(*expr).kind(Interner), TyKind::Ref(..) | TyKind::Raw(..) diff --git a/crates/hir-ty/src/mir/pretty.rs b/crates/hir-ty/src/mir/pretty.rs index 9ec2913dce97..d6253b378b2c 100644 --- a/crates/hir-ty/src/mir/pretty.rs +++ b/crates/hir-ty/src/mir/pretty.rs @@ -2,7 +2,7 @@ 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 la_arena::ArenaMap; diff --git a/crates/hir-ty/src/tests.rs b/crates/hir-ty/src/tests.rs index 83d31f002a1d..1e46bb1d0409 100644 --- a/crates/hir-ty/src/tests.rs +++ b/crates/hir-ty/src/tests.rs @@ -17,7 +17,7 @@ use expect_test::Expect; use hir_def::{ body::{Body, BodySourceMap, SyntheticSyntax}, db::{DefDatabase, InternDatabase}, - expr::{ExprId, PatId}, + hir::{ExprId, PatId}, item_scope::ItemScope, nameres::DefMap, 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() { let Some(node) = (match expr_or_pat { - hir_def::expr::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::ExprId(expr) => expr_node(&body_source_map, expr, &db), + hir_def::hir::ExprOrPatId::PatId(pat) => pat_node(&body_source_map, pat, &db), }) else { continue; }; let range = node.as_ref().original_file_range(&db); let actual = format!( diff --git a/crates/hir/src/display.rs b/crates/hir/src/display.rs index 5aae92efd19e..7cb29114d7fb 100644 --- a/crates/hir/src/display.rs +++ b/crates/hir/src/display.rs @@ -1,6 +1,6 @@ //! HirDisplay implementations for various hir types. use hir_def::{ - adt::VariantData, + data::adt::VariantData, generics::{ TypeOrConstParamData, TypeParamProvenance, WherePredicate, WherePredicateTypeTarget, }, diff --git a/crates/hir/src/from_id.rs b/crates/hir/src/from_id.rs index aaaa7abf3863..883e6a29b06a 100644 --- a/crates/hir/src/from_id.rs +++ b/crates/hir/src/from_id.rs @@ -4,7 +4,7 @@ //! are splitting the hir. use hir_def::{ - expr::{BindingId, LabelId}, + hir::{BindingId, LabelId}, AdtId, AssocItemId, DefWithBodyId, EnumVariantId, FieldId, GenericDefId, GenericParamId, ModuleDefId, VariantId, }; diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index dbb41b1b6674..a355ea164229 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -39,10 +39,10 @@ use arrayvec::ArrayVec; use base_db::{CrateDisplayName, CrateId, CrateOrigin, Edition, FileId, ProcMacroKind}; use either::Either; use hir_def::{ - adt::VariantData, body::{BodyDiagnostic, SyntheticSyntax}, - expr::{BindingAnnotation, BindingId, ExprOrPatId, LabelId, Pat}, + data::adt::VariantData, generics::{LifetimeParamData, TypeOrConstParamData, TypeParamProvenance}, + hir::{BindingAnnotation, BindingId, ExprOrPatId, LabelId, Pat}, item_tree::ItemTreeNode, lang_item::{LangItem, LangItemTarget}, layout::{Layout, LayoutError, ReprOptions}, @@ -109,9 +109,8 @@ pub use crate::{ pub use { cfg::{CfgAtom, CfgExpr, CfgOptions}, hir_def::{ - adt::StructKind, - attr::{Attrs, AttrsWithOwner, Documentation}, - builtin_attr::AttributeTemplate, + attr::{builtin::AttributeTemplate, Attrs, AttrsWithOwner, Documentation}, + data::adt::StructKind, find_path::PrefixKind, import_map, nameres::ModuleSource, @@ -2697,9 +2696,7 @@ impl BuiltinAttr { } fn builtin(name: &str) -> Option { - hir_def::builtin_attr::INERT_ATTRIBUTES - .iter() - .position(|tool| tool.name == name) + hir_def::attr::builtin::find_builtin_attr_idx(name) .map(|idx| BuiltinAttr { krate: None, idx: idx as u32 }) } @@ -2707,14 +2704,14 @@ impl BuiltinAttr { // FIXME: Return a `Name` here match self.krate { Some(krate) => db.crate_def_map(krate).registered_attrs()[self.idx as usize].clone(), - None => SmolStr::new(hir_def::builtin_attr::INERT_ATTRIBUTES[self.idx as usize].name), + None => SmolStr::new(hir_def::attr::builtin::INERT_ATTRIBUTES[self.idx as usize].name), } } pub fn template(&self, _: &dyn HirDatabase) -> Option { match self.krate { Some(_) => None, - None => Some(hir_def::builtin_attr::INERT_ATTRIBUTES[self.idx as usize].template), + None => Some(hir_def::attr::builtin::INERT_ATTRIBUTES[self.idx as usize].template), } } } @@ -2737,7 +2734,7 @@ impl ToolModule { } fn builtin(name: &str) -> Option { - hir_def::builtin_attr::TOOL_MODULES + hir_def::attr::builtin::TOOL_MODULES .iter() .position(|&tool| tool == name) .map(|idx| ToolModule { krate: None, idx: idx as u32 }) @@ -2747,7 +2744,7 @@ impl ToolModule { // FIXME: Return a `Name` here match self.krate { Some(krate) => db.crate_def_map(krate).registered_tools()[self.idx as usize].clone(), - None => SmolStr::new(hir_def::builtin_attr::TOOL_MODULES[self.idx as usize]), + None => SmolStr::new(hir_def::attr::builtin::TOOL_MODULES[self.idx as usize]), } } } diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index 2b2a2966c1c3..5b1d7649fa3e 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs @@ -8,7 +8,7 @@ use base_db::{FileId, FileRange}; use either::Either; use hir_def::{ body, - expr::Expr, + hir::Expr, macro_id_to_def_id, resolver::{self, HasResolver, Resolver, TypeNs}, type_ref::Mutability, diff --git a/crates/hir/src/semantics/source_to_def.rs b/crates/hir/src/semantics/source_to_def.rs index f6f8c9a250f0..c50ffa4f8b70 100644 --- a/crates/hir/src/semantics/source_to_def.rs +++ b/crates/hir/src/semantics/source_to_def.rs @@ -14,7 +14,7 @@ //! expression, an item definition. //! //! Knowing only the syntax gives us relatively little info. For example, -//! looking at the syntax of the function we can realise that it is a part of an +//! looking at the syntax of the function we can realize that it is a part of an //! `impl` block, but we won't be able to tell what trait function the current //! function overrides, and whether it does that correctly. For that, we need to //! go from [`ast::Fn`] to [`crate::Function`], and that's exactly what this @@ -88,9 +88,11 @@ use base_db::FileId; use hir_def::{ child_by_source::ChildBySource, - dyn_map::DynMap, - expr::{BindingId, LabelId}, - keys::{self, Key}, + dyn_map::{ + keys::{self, Key}, + DynMap, + }, + hir::{BindingId, LabelId}, AdtId, ConstId, ConstParamId, DefWithBodyId, EnumId, EnumVariantId, FieldId, FunctionId, GenericDefId, GenericParamId, ImplId, LifetimeParamId, MacroId, ModuleId, StaticId, StructId, TraitAliasId, TraitId, TypeAliasId, TypeParamId, UnionId, VariantId, diff --git a/crates/hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs index 4d33c71fdd84..1c50d81e1bd9 100644 --- a/crates/hir/src/source_analyzer.rs +++ b/crates/hir/src/source_analyzer.rs @@ -17,7 +17,7 @@ use hir_def::{ scope::{ExprScopes, ScopeId}, Body, BodySourceMap, }, - expr::{ExprId, Pat, PatId}, + hir::{ExprId, Pat, PatId}, lang_item::LangItem, macro_id_to_def_id, path::{ModPath, Path, PathKind}, diff --git a/crates/ide-assists/src/handlers/sort_items.rs b/crates/ide-assists/src/handlers/sort_items.rs index a93704b39474..63e350e155fc 100644 --- a/crates/ide-assists/src/handlers/sort_items.rs +++ b/crates/ide-assists/src/handlers/sort_items.rs @@ -116,9 +116,11 @@ trait AddRewrite { new: Vec, target: TextRange, ) -> Option<()>; + fn yeet() {} } impl AddRewrite for Assists { + fn yeet() {} fn add_rewrite( &mut self, label: &str, diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs index e1504743bfdb..bd4777757172 100644 --- a/crates/rust-analyzer/src/cli/analysis_stats.rs +++ b/crates/rust-analyzer/src/cli/analysis_stats.rs @@ -13,7 +13,7 @@ use hir::{ }; use hir_def::{ body::{BodySourceMap, SyntheticSyntax}, - expr::{ExprId, PatId}, + hir::{ExprId, PatId}, FunctionId, }; use hir_ty::{Interner, TyExt, TypeFlags};