This commit is contained in:
Aleksey Kladov 2020-04-11 17:00:31 +02:00
parent 997c959d4f
commit 6b0870d12e
2 changed files with 8 additions and 8 deletions

View File

@ -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<T>(&self, value: T) -> InFile<T> {
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> {
Path::from_src(path, &self.hygiene)
}

View File

@ -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;