resolve/expand: Cache intermediate results of #[derive]
expansion
This commit is contained in:
parent
b1ea2618d3
commit
fbf1bec482
5 changed files with 97 additions and 73 deletions
|
@ -37,7 +37,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
|
|||
use rustc_data_structures::ptr_key::PtrKey;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
|
||||
use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind};
|
||||
use rustc_expand::base::{DeriveResolutions, SyntaxExtension, SyntaxExtensionKind};
|
||||
use rustc_hir::def::Namespace::*;
|
||||
use rustc_hir::def::{self, CtorOf, DefKind, NonMacroAttrKind, PartialRes};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, CRATE_DEF_INDEX};
|
||||
|
@ -851,6 +851,12 @@ enum BuiltinMacroState {
|
|||
AlreadySeen(Span),
|
||||
}
|
||||
|
||||
struct DeriveData {
|
||||
resolutions: DeriveResolutions,
|
||||
helper_attrs: Vec<Ident>,
|
||||
has_derive_copy: bool,
|
||||
}
|
||||
|
||||
/// The main resolver class.
|
||||
///
|
||||
/// This is the visitor that walks the whole crate.
|
||||
|
@ -973,8 +979,9 @@ pub struct Resolver<'a> {
|
|||
output_macro_rules_scopes: FxHashMap<ExpnId, MacroRulesScopeRef<'a>>,
|
||||
/// Helper attributes that are in scope for the given expansion.
|
||||
helper_attrs: FxHashMap<ExpnId, Vec<Ident>>,
|
||||
/// Resolutions for paths inside the `#[derive(...)]` attribute with the given `ExpnId`.
|
||||
derive_resolutions: FxHashMap<ExpnId, Vec<(Lrc<SyntaxExtension>, ast::Path)>>,
|
||||
/// Ready or in-progress results of resolving paths inside the `#[derive(...)]` attribute
|
||||
/// with the given `ExpnId`.
|
||||
derive_data: FxHashMap<ExpnId, DeriveData>,
|
||||
|
||||
/// Avoid duplicated errors for "name already defined".
|
||||
name_already_seen: FxHashMap<Symbol, Span>,
|
||||
|
@ -1310,7 +1317,7 @@ impl<'a> Resolver<'a> {
|
|||
invocation_parent_scopes: Default::default(),
|
||||
output_macro_rules_scopes: Default::default(),
|
||||
helper_attrs: Default::default(),
|
||||
derive_resolutions: Default::default(),
|
||||
derive_data: Default::default(),
|
||||
local_macro_def_scopes: FxHashMap::default(),
|
||||
name_already_seen: FxHashMap::default(),
|
||||
potentially_unused_imports: Vec::new(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue