Skip to content

Commit 603746a

Browse files
committed
Make ResolverAstLowering a struct.
1 parent 47799de commit 603746a

File tree

23 files changed

+354
-263
lines changed

23 files changed

+354
-263
lines changed

Cargo.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -3569,6 +3569,7 @@ dependencies = [
35693569
"rustc_errors",
35703570
"rustc_hir",
35713571
"rustc_index",
3572+
"rustc_middle",
35723573
"rustc_query_system",
35733574
"rustc_session",
35743575
"rustc_span",
@@ -4386,7 +4387,6 @@ dependencies = [
43864387
"bitflags",
43874388
"rustc_arena",
43884389
"rustc_ast",
4389-
"rustc_ast_lowering",
43904390
"rustc_ast_pretty",
43914391
"rustc_attr",
43924392
"rustc_data_structures",

compiler/rustc_ast_lowering/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ rustc_hir = { path = "../rustc_hir" }
1414
rustc_target = { path = "../rustc_target" }
1515
rustc_data_structures = { path = "../rustc_data_structures" }
1616
rustc_index = { path = "../rustc_index" }
17+
rustc_middle = { path = "../rustc_middle" }
1718
rustc_query_system = { path = "../rustc_query_system" }
1819
rustc_span = { path = "../rustc_span" }
1920
rustc_errors = { path = "../rustc_errors" }

compiler/rustc_ast_lowering/src/asm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{ImplTraitContext, ImplTraitPosition, ParamMode};
1+
use crate::{ImplTraitContext, ImplTraitPosition, ParamMode, ResolverAstLoweringExt};
22

33
use super::LoweringContext;
44

@@ -243,7 +243,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
243243
// Wrap the expression in an AnonConst.
244244
let parent_def_id = self.current_hir_id_owner;
245245
let node_id = self.resolver.next_node_id();
246-
self.resolver.create_def(
246+
self.create_def(
247247
parent_def_id,
248248
node_id,
249249
DefPathData::AnonConst,

compiler/rustc_ast_lowering/src/expr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use crate::{FnDeclKind, ImplTraitPosition};
2-
1+
use super::ResolverAstLoweringExt;
32
use super::{ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs};
3+
use crate::{FnDeclKind, ImplTraitPosition};
44

55
use rustc_ast::attr;
66
use rustc_ast::ptr::P as AstP;
@@ -358,7 +358,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
358358
let node_id = self.resolver.next_node_id();
359359

360360
// Add a definition for the in-band const def.
361-
self.resolver.create_def(
361+
self.create_def(
362362
parent_def_id,
363363
node_id,
364364
DefPathData::AnonConst,

compiler/rustc_ast_lowering/src/index.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use rustc_hir::definitions;
66
use rustc_hir::intravisit::{self, Visitor};
77
use rustc_hir::*;
88
use rustc_index::vec::{Idx, IndexVec};
9+
use rustc_middle::span_bug;
910
use rustc_session::Session;
1011
use rustc_span::source_map::SourceMap;
1112
use rustc_span::{Span, DUMMY_SP};
@@ -75,7 +76,8 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
7576
// owner of that node.
7677
if cfg!(debug_assertions) {
7778
if hir_id.owner != self.owner {
78-
panic!(
79+
span_bug!(
80+
span,
7981
"inconsistent DepNode at `{:?}` for `{:?}`: \
8082
current_dep_node_owner={} ({:?}), hir_id.owner={} ({:?})",
8183
self.source_map.span_to_diagnostic_string(span),

compiler/rustc_ast_lowering/src/item.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
use super::{AstOwner, ImplTraitContext, ImplTraitPosition, ResolverAstLowering};
1+
use super::ResolverAstLoweringExt;
2+
use super::{AstOwner, ImplTraitContext, ImplTraitPosition};
23
use super::{LoweringContext, ParamMode};
34
use crate::{Arena, FnDeclKind};
45

@@ -11,8 +12,11 @@ use rustc_errors::struct_span_err;
1112
use rustc_hir as hir;
1213
use rustc_hir::def::{DefKind, Res};
1314
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
15+
use rustc_hir::definitions::Definitions;
1416
use rustc_hir::PredicateOrigin;
1517
use rustc_index::vec::{Idx, IndexVec};
18+
use rustc_middle::ty::ResolverOutputs;
19+
use rustc_session::cstore::CrateStoreDyn;
1620
use rustc_session::Session;
1721
use rustc_span::source_map::DesugaringKind;
1822
use rustc_span::symbol::{kw, sym, Ident};
@@ -24,7 +28,9 @@ use std::iter;
2428

2529
pub(super) struct ItemLowerer<'a, 'hir> {
2630
pub(super) sess: &'a Session,
27-
pub(super) resolver: &'a mut dyn ResolverAstLowering,
31+
pub(super) definitions: &'a mut Definitions,
32+
pub(super) cstore: &'a CrateStoreDyn,
33+
pub(super) resolver: &'a mut ResolverOutputs,
2834
pub(super) arena: &'hir Arena<'hir>,
2935
pub(super) ast_index: &'a IndexVec<LocalDefId, AstOwner<'a>>,
3036
pub(super) owners: &'a mut IndexVec<LocalDefId, hir::MaybeOwner<&'hir hir::OwnerInfo<'hir>>>,
@@ -59,6 +65,8 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
5965
let mut lctx = LoweringContext {
6066
// Pseudo-globals.
6167
sess: &self.sess,
68+
definitions: self.definitions,
69+
cstore: self.cstore,
6270
resolver: self.resolver,
6371
arena: self.arena,
6472

@@ -136,7 +144,7 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
136144
let def_id = self.resolver.local_def_id(item.id);
137145

138146
let parent_id = {
139-
let parent = self.resolver.definitions().def_key(def_id).parent;
147+
let parent = self.definitions.def_key(def_id).parent;
140148
let local_def_index = parent.unwrap();
141149
LocalDefId { local_def_index }
142150
};

0 commit comments

Comments
 (0)