Skip to content

Commit 04aed9d

Browse files
committed
Make ResolverAstLowering a struct.
1 parent 21ec51d commit 04aed9d

File tree

22 files changed

+345
-262
lines changed

22 files changed

+345
-262
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3474,6 +3474,7 @@ dependencies = [
34743474
"rustc_errors",
34753475
"rustc_hir",
34763476
"rustc_index",
3477+
"rustc_middle",
34773478
"rustc_query_system",
34783479
"rustc_session",
34793480
"rustc_span",
@@ -4276,7 +4277,6 @@ dependencies = [
42764277
"bitflags",
42774278
"rustc_arena",
42784279
"rustc_ast",
4279-
"rustc_ast_lowering",
42804280
"rustc_ast_pretty",
42814281
"rustc_attr",
42824282
"rustc_data_structures",

compiler/rustc_ast_lowering/Cargo.toml

Lines changed: 1 addition & 0 deletions
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

Lines changed: 2 additions & 2 deletions
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

@@ -239,7 +239,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
239239
// Wrap the expression in an AnonConst.
240240
let parent_def_id = self.current_hir_id_owner;
241241
let node_id = self.resolver.next_node_id();
242-
self.resolver.create_def(
242+
self.create_def(
243243
parent_def_id,
244244
node_id,
245245
DefPathData::AnonConst,

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 3 additions & 3 deletions
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;
@@ -342,7 +342,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
342342
let node_id = self.resolver.next_node_id();
343343

344344
// Add a definition for the in-band const def.
345-
self.resolver.create_def(
345+
self.create_def(
346346
parent_def_id,
347347
node_id,
348348
DefPathData::AnonConst,

compiler/rustc_ast_lowering/src/index.rs

Lines changed: 3 additions & 1 deletion
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

Lines changed: 11 additions & 3 deletions
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,7 +12,10 @@ 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_index::vec::{Idx, IndexVec};
17+
use rustc_middle::ty::ResolverOutputs;
18+
use rustc_session::cstore::CrateStoreDyn;
1519
use rustc_session::utils::NtToTokenstream;
1620
use rustc_session::Session;
1721
use rustc_span::source_map::DesugaringKind;
@@ -25,7 +29,9 @@ use std::iter;
2529

2630
pub(super) struct ItemLowerer<'a, 'hir> {
2731
pub(super) sess: &'a Session,
28-
pub(super) resolver: &'a mut dyn ResolverAstLowering,
32+
pub(super) definitions: &'a mut Definitions,
33+
pub(super) cstore: &'a CrateStoreDyn,
34+
pub(super) resolver: &'a mut ResolverOutputs,
2935
pub(super) nt_to_tokenstream: NtToTokenstream,
3036
pub(super) arena: &'hir Arena<'hir>,
3137
pub(super) ast_index: &'a IndexVec<LocalDefId, AstOwner<'a>>,
@@ -61,6 +67,8 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
6167
let mut lctx = LoweringContext {
6268
// Pseudo-globals.
6369
sess: &self.sess,
70+
definitions: self.definitions,
71+
cstore: self.cstore,
6472
resolver: self.resolver,
6573
nt_to_tokenstream: self.nt_to_tokenstream,
6674
arena: self.arena,
@@ -135,7 +143,7 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
135143
let def_id = self.resolver.local_def_id(item.id);
136144

137145
let parent_id = {
138-
let parent = self.resolver.definitions().def_key(def_id).parent;
146+
let parent = self.definitions.def_key(def_id).parent;
139147
let local_def_index = parent.unwrap();
140148
LocalDefId { local_def_index }
141149
};

0 commit comments

Comments
 (0)