Rollup merge of #73813 - petrochenkov:restrait, r=davidtwco

Rename two `Resolver` traits

`trait Resolver` -> `trait ResolverExpand` for the resolver interface available from expansion.
`trait Resolver` -> `trait ResolverAstLowering` for the resolver interface available from AST lowering.

Addresses https://github.com/rust-lang/rust/pull/73587#discussion_r443242556
This commit is contained in:
Manish Goregaokar 2020-06-28 08:30:31 -07:00 committed by GitHub
commit dd81139927
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 24 additions and 25 deletions

View File

@ -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<Lrc<[Symbol]>>,
}
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 @@ fn reborrow<'this>(&'this mut self) -> ImplTraitContext<'this, '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> {

View File

@ -15,7 +15,7 @@
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 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),

View File

@ -6,7 +6,7 @@
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,

View File

@ -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 @@
pub fn inject(
mut krate: ast::Crate,
resolver: &mut dyn Resolver,
resolver: &mut dyn ResolverExpand,
sess: &ParseSess,
alt_std_name: Option<Symbol>,
) -> (ast::Crate, Option<Symbol>) {

View File

@ -6,7 +6,7 @@
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 @@ fn visit_mac(&mut self, _mac: &mut ast::MacCall) {
/// 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<Symbol>,
krate: &mut ast::Crate,
features: &Features,

View File

@ -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<Limit>,
pub root_path: PathBuf,
pub resolver: &'a mut dyn Resolver,
pub resolver: &'a mut dyn ResolverExpand,
pub current_expansion: ExpansionData,
pub expansions: FxHashMap<Span, Vec<String>>,
/// 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 {

View File

@ -19,7 +19,7 @@
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};

View File

@ -29,7 +29,7 @@
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;

View File

@ -4,7 +4,7 @@
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::*;

View File

@ -12,7 +12,7 @@
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};

View File

@ -16,7 +16,7 @@
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, *};

View File

@ -27,7 +27,7 @@
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;

View File

@ -7,12 +7,11 @@
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 @@ fn registered_idents(
(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()
}