From 6b0870d12efd868202cfca45da651d21f2441031 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 11 Apr 2020 17:00:31 +0200 Subject: [PATCH] Simplify --- crates/ra_hir_def/src/body.rs | 5 +++++ crates/ra_hir_def/src/body/lower.rs | 11 +++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index e09996c6f87..ff0758da0a5 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs @@ -14,6 +14,7 @@ use rustc_hash::FxHashMap; use crate::{ + attr::Attrs, db::DefDatabase, expr::{Expr, ExprId, Pat, PatId}, item_scope::BuiltinShadowMode, @@ -102,6 +103,10 @@ pub(crate) fn to_source(&self, value: T) -> InFile { InFile { file_id: self.current_file_id, value } } + pub(crate) fn parse_attrs(&self, owner: &dyn ast::AttrsOwner) -> Attrs { + Attrs::new(owner, &self.hygiene) + } + fn parse_path(&mut self, path: ast::Path) -> Option { Path::from_src(path, &self.hygiene) } diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 9d6ee095ef3..06df88a34ee 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -2,9 +2,7 @@ //! representation. use either::Either; - use hir_expand::{ - hygiene::Hygiene, name::{name, AsName, Name}, MacroDefId, MacroDefKind, }; @@ -18,10 +16,8 @@ }; use test_utils::tested_by; -use super::{ExprSource, PatSource}; use crate::{ adt::StructKind, - attr::Attrs, body::{Body, BodySourceMap, Expander, PatPtr, SyntheticSyntax}, builtin_type::{BuiltinFloat, BuiltinInt}, db::DefDatabase, @@ -37,6 +33,8 @@ ModuleDefId, StaticLoc, StructLoc, TraitLoc, TypeAliasLoc, UnionLoc, }; +use super::{ExprSource, PatSource}; + pub(super) fn lower( db: &dyn DefDatabase, def: DefWithBodyId, @@ -309,10 +307,7 @@ fn collect_expr(&mut self, expr: ast::Expr) -> ExprId { .inspect(|field| field_ptrs.push(AstPtr::new(field))) .filter_map(|field| { let module_id = ContainerId::DefWithBodyId(self.def).module(self.db); - let attrs = Attrs::new( - &field, - &Hygiene::new(self.db.upcast(), self.expander.current_file_id), - ); + let attrs = self.expander.parse_attrs(&field); if !attrs.is_cfg_enabled(&crate_graph[module_id.krate].cfg_options) { return None;