From 6d0e5bf3487a627021f2346ea2e35d7e5b0007ef Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sat, 27 Jun 2020 23:51:28 +0300 Subject: [PATCH] Rename two `Resolver` traits --- src/librustc_ast_lowering/lib.rs | 6 +++--- src/librustc_builtin_macros/lib.rs | 4 ++-- src/librustc_builtin_macros/proc_macro_harness.rs | 4 ++-- src/librustc_builtin_macros/standard_library_imports.rs | 4 ++-- src/librustc_builtin_macros/test_harness.rs | 6 +++--- src/librustc_expand/base.rs | 6 +++--- src/librustc_resolve/build_reduced_graph.rs | 2 +- src/librustc_resolve/check_unused.rs | 2 +- src/librustc_resolve/def_collector.rs | 2 +- src/librustc_resolve/imports.rs | 2 +- src/librustc_resolve/late.rs | 2 +- src/librustc_resolve/lib.rs | 2 +- src/librustc_resolve/macros.rs | 7 +++---- 13 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/librustc_ast_lowering/lib.rs b/src/librustc_ast_lowering/lib.rs index 863f525bdc8f3..bc0980f041b94 100644 --- a/src/librustc_ast_lowering/lib.rs +++ b/src/librustc_ast_lowering/lib.rs @@ -91,7 +91,7 @@ struct LoweringContext<'a, 'hir: 'a> { /// Used to assign IDs to HIR nodes that do not directly correspond to AST nodes. sess: &'a Session, - resolver: &'a mut dyn Resolver, + resolver: &'a mut dyn ResolverAstLowering, /// HACK(Centril): there is a cyclic dependency between the parser and lowering /// if we don't have this function pointer. To avoid that dependency so that @@ -172,7 +172,7 @@ struct LoweringContext<'a, 'hir: 'a> { allow_gen_future: Option>, } -pub trait Resolver { +pub trait ResolverAstLowering { fn def_key(&mut self, id: DefId) -> DefKey; fn item_generics_num_lifetimes(&self, def: DefId, sess: &Session) -> usize; @@ -299,7 +299,7 @@ impl<'a> ImplTraitContext<'_, 'a> { pub fn lower_crate<'a, 'hir>( sess: &'a Session, krate: &'a Crate, - resolver: &'a mut dyn Resolver, + resolver: &'a mut dyn ResolverAstLowering, nt_to_tokenstream: NtToTokenstream, arena: &'hir Arena<'hir>, ) -> hir::Crate<'hir> { diff --git a/src/librustc_builtin_macros/lib.rs b/src/librustc_builtin_macros/lib.rs index f56d8a372a73e..173a823dc7d52 100644 --- a/src/librustc_builtin_macros/lib.rs +++ b/src/librustc_builtin_macros/lib.rs @@ -15,7 +15,7 @@ extern crate proc_macro; use crate::deriving::*; -use rustc_expand::base::{MacroExpanderFn, Resolver, SyntaxExtension, SyntaxExtensionKind}; +use rustc_expand::base::{MacroExpanderFn, ResolverExpand, SyntaxExtension, SyntaxExtensionKind}; use rustc_expand::proc_macro::BangProcMacro; use rustc_span::edition::Edition; use rustc_span::symbol::{sym, Ident}; @@ -45,7 +45,7 @@ pub mod proc_macro_harness; pub mod standard_library_imports; pub mod test_harness; -pub fn register_builtin_macros(resolver: &mut dyn Resolver, edition: Edition) { +pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand, edition: Edition) { let mut register = |name, kind| { resolver.register_builtin_macro( Ident::with_dummy_span(name), diff --git a/src/librustc_builtin_macros/proc_macro_harness.rs b/src/librustc_builtin_macros/proc_macro_harness.rs index adaf5f03079eb..7cc9c1f76631e 100644 --- a/src/librustc_builtin_macros/proc_macro_harness.rs +++ b/src/librustc_builtin_macros/proc_macro_harness.rs @@ -6,7 +6,7 @@ use rustc_ast::expand::is_proc_macro_attr; use rustc_ast::ptr::P; use rustc_ast::visit::{self, Visitor}; use rustc_ast_pretty::pprust; -use rustc_expand::base::{ExtCtxt, Resolver}; +use rustc_expand::base::{ExtCtxt, ResolverExpand}; use rustc_expand::expand::{AstFragment, ExpansionConfig}; use rustc_session::parse::ParseSess; use rustc_span::hygiene::AstPass; @@ -52,7 +52,7 @@ struct CollectProcMacros<'a> { pub fn inject( sess: &ParseSess, - resolver: &mut dyn Resolver, + resolver: &mut dyn ResolverExpand, mut krate: ast::Crate, is_proc_macro_crate: bool, has_proc_macro_decls: bool, diff --git a/src/librustc_builtin_macros/standard_library_imports.rs b/src/librustc_builtin_macros/standard_library_imports.rs index cd3773c76c483..671ff8ce54f0e 100644 --- a/src/librustc_builtin_macros/standard_library_imports.rs +++ b/src/librustc_builtin_macros/standard_library_imports.rs @@ -1,6 +1,6 @@ use rustc_ast::ptr::P; use rustc_ast::{ast, attr}; -use rustc_expand::base::{ExtCtxt, Resolver}; +use rustc_expand::base::{ExtCtxt, ResolverExpand}; use rustc_expand::expand::ExpansionConfig; use rustc_session::parse::ParseSess; use rustc_span::edition::Edition; @@ -10,7 +10,7 @@ use rustc_span::DUMMY_SP; pub fn inject( mut krate: ast::Crate, - resolver: &mut dyn Resolver, + resolver: &mut dyn ResolverExpand, sess: &ParseSess, alt_std_name: Option, ) -> (ast::Crate, Option) { diff --git a/src/librustc_builtin_macros/test_harness.rs b/src/librustc_builtin_macros/test_harness.rs index 34ed4c800e04f..da8bf2b8b5169 100644 --- a/src/librustc_builtin_macros/test_harness.rs +++ b/src/librustc_builtin_macros/test_harness.rs @@ -6,7 +6,7 @@ use rustc_ast::attr; use rustc_ast::entry::{self, EntryPointType}; use rustc_ast::mut_visit::{ExpectOne, *}; use rustc_ast::ptr::P; -use rustc_expand::base::{ExtCtxt, Resolver}; +use rustc_expand::base::{ExtCtxt, ResolverExpand}; use rustc_expand::expand::{AstFragment, ExpansionConfig}; use rustc_feature::Features; use rustc_session::parse::ParseSess; @@ -37,7 +37,7 @@ struct TestCtxt<'a> { // existing main functions, and synthesizing a main test harness pub fn inject( sess: &ParseSess, - resolver: &mut dyn Resolver, + resolver: &mut dyn ResolverExpand, should_test: bool, krate: &mut ast::Crate, span_diagnostic: &rustc_errors::Handler, @@ -192,7 +192,7 @@ impl MutVisitor for EntryPointCleaner { /// Crawl over the crate, inserting test reexports and the test main function fn generate_test_harness( sess: &ParseSess, - resolver: &mut dyn Resolver, + resolver: &mut dyn ResolverExpand, reexport_test_harness_main: Option, krate: &mut ast::Crate, features: &Features, diff --git a/src/librustc_expand/base.rs b/src/librustc_expand/base.rs index d4c756c9ec7f8..757eee8bb46e1 100644 --- a/src/librustc_expand/base.rs +++ b/src/librustc_expand/base.rs @@ -889,7 +889,7 @@ pub enum InvocationRes { /// Error type that denotes indeterminacy. pub struct Indeterminate; -pub trait Resolver { +pub trait ResolverExpand { fn next_node_id(&mut self) -> NodeId; fn resolve_dollar_crates(&mut self); @@ -946,7 +946,7 @@ pub struct ExtCtxt<'a> { pub ecfg: expand::ExpansionConfig<'a>, pub reduced_recursion_limit: Option, pub root_path: PathBuf, - pub resolver: &'a mut dyn Resolver, + pub resolver: &'a mut dyn ResolverExpand, pub current_expansion: ExpansionData, pub expansions: FxHashMap>, /// Called directly after having parsed an external `mod foo;` in expansion. @@ -957,7 +957,7 @@ impl<'a> ExtCtxt<'a> { pub fn new( parse_sess: &'a ParseSess, ecfg: expand::ExpansionConfig<'a>, - resolver: &'a mut dyn Resolver, + resolver: &'a mut dyn ResolverExpand, extern_mod_loaded: Option<&'a dyn Fn(&ast::Crate)>, ) -> ExtCtxt<'a> { ExtCtxt { diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 72faa68d0b243..a92d451dfd006 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -19,7 +19,7 @@ use rustc_ast::ast::{self, Block, ForeignItem, ForeignItemKind, Item, ItemKind, use rustc_ast::ast::{AssocItem, AssocItemKind, MetaItemKind, StmtKind}; use rustc_ast::token::{self, Token}; use rustc_ast::visit::{self, AssocCtxt, Visitor}; -use rustc_ast_lowering::Resolver as ResolverAstLowering; +use rustc_ast_lowering::ResolverAstLowering; use rustc_attr as attr; use rustc_data_structures::sync::Lrc; use rustc_errors::{struct_span_err, Applicability}; diff --git a/src/librustc_resolve/check_unused.rs b/src/librustc_resolve/check_unused.rs index 0ca01a384e73e..1f36e1ed83de7 100644 --- a/src/librustc_resolve/check_unused.rs +++ b/src/librustc_resolve/check_unused.rs @@ -29,7 +29,7 @@ use crate::Resolver; use rustc_ast::ast; use rustc_ast::node_id::NodeMap; use rustc_ast::visit::{self, Visitor}; -use rustc_ast_lowering::Resolver as ResolverAstLowering; +use rustc_ast_lowering::ResolverAstLowering; use rustc_data_structures::fx::FxHashSet; use rustc_errors::pluralize; use rustc_middle::ty; diff --git a/src/librustc_resolve/def_collector.rs b/src/librustc_resolve/def_collector.rs index dc8d1a8d3fdf9..c25a20210e026 100644 --- a/src/librustc_resolve/def_collector.rs +++ b/src/librustc_resolve/def_collector.rs @@ -4,7 +4,7 @@ use rustc_ast::ast::*; use rustc_ast::token::{self, Token}; use rustc_ast::visit::{self, FnKind}; use rustc_ast::walk_list; -use rustc_ast_lowering::Resolver as ResolverAstLowering; +use rustc_ast_lowering::ResolverAstLowering; use rustc_expand::expand::AstFragment; use rustc_hir::def_id::LocalDefId; use rustc_hir::definitions::*; diff --git a/src/librustc_resolve/imports.rs b/src/librustc_resolve/imports.rs index 8a6541b399e38..ded0ee8a96699 100644 --- a/src/librustc_resolve/imports.rs +++ b/src/librustc_resolve/imports.rs @@ -12,7 +12,7 @@ use crate::{NameBinding, NameBindingKind, PathResult, PrivacyError, ToNameBindin use rustc_ast::ast::NodeId; use rustc_ast::unwrap_or; use rustc_ast::util::lev_distance::find_best_match_for_name; -use rustc_ast_lowering::Resolver as ResolverAstLowering; +use rustc_ast_lowering::ResolverAstLowering; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::ptr_key::PtrKey; use rustc_errors::{pluralize, struct_span_err, Applicability}; diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs index b8fb813ea155f..84ba9094ea16f 100644 --- a/src/librustc_resolve/late.rs +++ b/src/librustc_resolve/late.rs @@ -16,7 +16,7 @@ use rustc_ast::ptr::P; use rustc_ast::util::lev_distance::find_best_match_for_name; use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor}; use rustc_ast::{unwrap_or, walk_list}; -use rustc_ast_lowering::Resolver as ResolverAstLowering; +use rustc_ast_lowering::ResolverAstLowering; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::DiagnosticId; use rustc_hir::def::Namespace::{self, *}; diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 9ddcf9e1de7d1..dccaf76723a58 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -27,7 +27,7 @@ use rustc_ast::attr; use rustc_ast::node_id::NodeMap; use rustc_ast::unwrap_or; use rustc_ast::visit::{self, Visitor}; -use rustc_ast_lowering::Resolver as ResolverAstLowering; +use rustc_ast_lowering::ResolverAstLowering; use rustc_ast_pretty::pprust; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; use rustc_data_structures::ptr_key::PtrKey; diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 398b0e92d9d8c..3976e501c169f 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -7,12 +7,11 @@ use crate::{AmbiguityError, AmbiguityErrorMisc, AmbiguityKind, Determinacy}; use crate::{CrateLint, ParentScope, ResolutionError, Resolver, Scope, ScopeSet, Weak}; use crate::{ModuleKind, ModuleOrUniformRoot, NameBinding, PathResult, Segment, ToNameBinding}; use rustc_ast::ast::{self, NodeId}; -use rustc_ast_lowering::Resolver as ResolverAstLowering; +use rustc_ast_lowering::ResolverAstLowering; use rustc_ast_pretty::pprust; use rustc_attr::{self as attr, StabilityLevel}; use rustc_data_structures::fx::FxHashSet; -use rustc_expand::base::SyntaxExtension; -use rustc_expand::base::{self, Indeterminate, InvocationRes}; +use rustc_expand::base::{Indeterminate, InvocationRes, ResolverExpand, SyntaxExtension}; use rustc_expand::compile_declarative_macro; use rustc_expand::expand::{AstFragment, AstFragmentKind, Invocation, InvocationKind}; use rustc_feature::is_builtin_attr_name; @@ -141,7 +140,7 @@ crate fn registered_attrs_and_tools( (registered_attrs, registered_tools) } -impl<'a> base::Resolver for Resolver<'a> { +impl<'a> ResolverExpand for Resolver<'a> { fn next_node_id(&mut self) -> NodeId { self.next_node_id() }