mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-27 18:26:19 +00:00
refactor: Remove unnecessary Arc
This commit is contained in:
parent
7edfeb9674
commit
b5eedad8e3
11 changed files with 22 additions and 26 deletions
|
|
@ -11,7 +11,6 @@ use hir_expand::{
|
|||
};
|
||||
use span::{Edition, SyntaxContext};
|
||||
use syntax::{Parse, ast};
|
||||
use triomphe::Arc;
|
||||
|
||||
use crate::type_ref::{TypesMap, TypesSourceMap};
|
||||
use crate::{
|
||||
|
|
@ -21,7 +20,6 @@ use crate::{
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct Expander {
|
||||
cfg_options: Arc<CfgOptions>,
|
||||
span_map: OnceCell<SpanMap>,
|
||||
current_file_id: HirFileId,
|
||||
pub(crate) module: ModuleId,
|
||||
|
|
@ -44,7 +42,6 @@ impl Expander {
|
|||
module,
|
||||
recursion_depth: 0,
|
||||
recursion_limit,
|
||||
cfg_options: Arc::clone(module.krate.cfg_options(db)),
|
||||
span_map: OnceCell::new(),
|
||||
}
|
||||
}
|
||||
|
|
@ -141,8 +138,8 @@ impl Expander {
|
|||
)
|
||||
}
|
||||
|
||||
pub(crate) fn cfg_options(&self) -> &CfgOptions {
|
||||
&self.cfg_options
|
||||
pub(crate) fn cfg_options<'db>(&self, db: &'db dyn DefDatabase) -> &'db CfgOptions {
|
||||
self.module.krate.cfg_options(db)
|
||||
}
|
||||
|
||||
pub fn current_file_id(&self) -> HirFileId {
|
||||
|
|
|
|||
|
|
@ -1894,14 +1894,14 @@ impl ExprCollector<'_> {
|
|||
fn check_cfg(&mut self, owner: &dyn ast::HasAttrs) -> Option<()> {
|
||||
match self.expander.parse_attrs(self.db, owner).cfg() {
|
||||
Some(cfg) => {
|
||||
if self.expander.cfg_options().check(&cfg) != Some(false) {
|
||||
if self.expander.cfg_options(self.db).check(&cfg) != Some(false) {
|
||||
return Some(());
|
||||
}
|
||||
|
||||
self.source_map.diagnostics.push(ExpressionStoreDiagnostics::InactiveCode {
|
||||
node: self.expander.in_file(SyntaxNodePtr::new(owner.syntax())),
|
||||
cfg,
|
||||
opts: self.expander.cfg_options().clone(),
|
||||
opts: self.expander.cfg_options(self.db).clone(),
|
||||
});
|
||||
|
||||
None
|
||||
|
|
|
|||
|
|
@ -167,13 +167,13 @@ impl<'a> AssocItemCollector<'a> {
|
|||
|
||||
'items: for &item in assoc_items {
|
||||
let attrs = item_tree.attrs(self.db, self.module_id.krate, ModItem::from(item).into());
|
||||
if !attrs.is_cfg_enabled(self.expander.cfg_options()) {
|
||||
if !attrs.is_cfg_enabled(self.expander.cfg_options(self.db)) {
|
||||
self.diagnostics.push(DefDiagnostic::unconfigured_code(
|
||||
self.module_id.local_id,
|
||||
tree_id,
|
||||
ModItem::from(item).into(),
|
||||
attrs.cfg().unwrap(),
|
||||
self.expander.cfg_options().clone(),
|
||||
self.expander.cfg_options(self.db).clone(),
|
||||
));
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ pub const BAZ: u32 = 0;
|
|||
Edition::CURRENT,
|
||||
Some(CrateDisplayName::from_canonical_name(crate_name)),
|
||||
None,
|
||||
Arc::default(),
|
||||
Default::default(),
|
||||
None,
|
||||
Env::default(),
|
||||
CrateOrigin::Local { repo: None, name: Some(Symbol::intern(crate_name)) },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue