Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 62837b4

Browse files
committed
Stop passing resolver disambiguator state to AST lowering.
1 parent 8051f01 commit 62837b4

File tree

9 files changed

+43
-11
lines changed

9 files changed

+43
-11
lines changed

‎compiler/rustc_ast_lowering/src/expr.rs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use rustc_data_structures::stack::ensure_sufficient_stack;
88
use rustc_hir as hir;
99
use rustc_hir::HirId;
1010
use rustc_hir::def::{DefKind, Res};
11+
use rustc_hir::definitions::DefPathData;
1112
use rustc_middle::span_bug;
1213
use rustc_middle::ty::TyCtxt;
1314
use rustc_session::errors::report_lit_error;
@@ -491,7 +492,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
491492
for (idx, arg) in args.iter().cloned().enumerate() {
492493
if legacy_args_idx.contains(&idx) {
493494
let node_id = self.next_node_id();
494-
self.create_def(node_id, None, DefKind::AnonConst, f.span);
495+
self.create_def(
496+
node_id,
497+
None,
498+
DefKind::AnonConst,
499+
DefPathData::LateAnonConst,
500+
f.span,
501+
);
495502
let mut visitor = WillCreateDefIdsVisitor {};
496503
let const_value = if let ControlFlow::Break(span) = visitor.visit_expr(&arg) {
497504
AstP(Expr {

‎compiler/rustc_ast_lowering/src/lib.rs‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ use rustc_data_structures::tagged_ptr::TaggedRef;
5151
use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle};
5252
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
5353
use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE, LocalDefId};
54+
use rustc_hir::definitions::{DefPathData, DisambiguatorState};
5455
use rustc_hir::lints::DelayedLint;
5556
use rustc_hir::{
5657
self as hir, AngleBrackets, ConstArg, GenericArg, HirId, ItemLocalMap, LangItem,
@@ -92,6 +93,7 @@ rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
9293
struct LoweringContext<'a, 'hir> {
9394
tcx: TyCtxt<'hir>,
9495
resolver: &'a mut ResolverAstLowering,
96+
disambiguator: DisambiguatorState,
9597

9698
/// Used to allocate HIR nodes.
9799
arena: &'hir hir::Arena<'hir>,
@@ -154,6 +156,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
154156
// Pseudo-globals.
155157
tcx,
156158
resolver,
159+
disambiguator: DisambiguatorState::new(),
157160
arena: tcx.hir_arena,
158161

159162
// HirId handling.
@@ -520,6 +523,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
520523
node_id: ast::NodeId,
521524
name: Option<Symbol>,
522525
def_kind: DefKind,
526+
def_path_data: DefPathData,
523527
span: Span,
524528
) -> LocalDefId {
525529
let parent = self.current_hir_id_owner.def_id;
@@ -535,7 +539,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
535539
let def_id = self
536540
.tcx
537541
.at(span)
538-
.create_def(parent, name, def_kind, None, &mut self.resolver.disambiguator)
542+
.create_def(parent, name, def_kind, Some(def_path_data), &mut self.disambiguator)
539543
.def_id();
540544

541545
debug!("create_def: def_id_to_node_id[{:?}] <-> {:?}", def_id, node_id);
@@ -820,6 +824,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
820824
param,
821825
Some(kw::UnderscoreLifetime),
822826
DefKind::LifetimeParam,
827+
DefPathData::DesugaredAnonymousLifetime,
823828
ident.span,
824829
);
825830
debug!(?_def_id);
@@ -2154,7 +2159,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
21542159
// We're lowering a const argument that was originally thought to be a type argument,
21552160
// so the def collector didn't create the def ahead of time. That's why we have to do
21562161
// it here.
2157-
let def_id = self.create_def(node_id, None, DefKind::AnonConst, span);
2162+
let def_id = self.create_def(
2163+
node_id,
2164+
None,
2165+
DefKind::AnonConst,
2166+
DefPathData::LateAnonConst,
2167+
span,
2168+
);
21582169
let hir_id = self.lower_node_id(node_id);
21592170

21602171
let path_expr = Expr {

‎compiler/rustc_ast_lowering/src/pat.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use rustc_ast::ptr::P;
44
use rustc_ast::*;
55
use rustc_data_structures::stack::ensure_sufficient_stack;
66
use rustc_hir::def::{DefKind, Res};
7+
use rustc_hir::definitions::DefPathData;
78
use rustc_hir::{self as hir, LangItem};
89
use rustc_middle::span_bug;
910
use rustc_span::source_map::{Spanned, respan};
@@ -528,7 +529,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
528529
// We're generating a range end that didn't exist in the AST,
529530
// so the def collector didn't create the def ahead of time. That's why we have to do
530531
// it here.
531-
let def_id = self.create_def(node_id, None, DefKind::AnonConst, span);
532+
let def_id =
533+
self.create_def(node_id, None, DefKind::AnonConst, DefPathData::LateAnonConst, span);
532534
let hir_id = self.lower_node_id(node_id);
533535

534536
let unstable_span = self.mark_span_with_reason(

‎compiler/rustc_hir/src/definitions.rs‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,10 @@ pub enum DefPathData {
306306
Ctor,
307307
/// A constant expression (see `{ast,hir}::AnonConst`).
308308
AnonConst,
309+
/// A constant expression created during AST->HIR lowering..
310+
LateAnonConst,
311+
/// A fresh anonymous lifetime created by desugaring elided lifetimes.
312+
DesugaredAnonymousLifetime,
309313
/// An existential `impl Trait` type node.
310314
/// Argument position `impl Trait` have a `TypeNs` with their pretty-printed name.
311315
OpaqueTy,
@@ -450,6 +454,8 @@ impl DefPathData {
450454
TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name)
451455
| OpaqueLifetime(name) => Some(name),
452456

457+
DesugaredAnonymousLifetime => Some(kw::UnderscoreLifetime),
458+
453459
Impl
454460
| ForeignMod
455461
| CrateRoot
@@ -458,6 +464,7 @@ impl DefPathData {
458464
| Closure
459465
| Ctor
460466
| AnonConst
467+
| LateAnonConst
461468
| OpaqueTy
462469
| AnonAssocTy(..)
463470
| SyntheticCoroutineBody
@@ -471,6 +478,8 @@ impl DefPathData {
471478
TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) | AnonAssocTy(name)
472479
| OpaqueLifetime(name) => Some(name),
473480

481+
DesugaredAnonymousLifetime => Some(kw::UnderscoreLifetime),
482+
474483
Impl
475484
| ForeignMod
476485
| CrateRoot
@@ -479,6 +488,7 @@ impl DefPathData {
479488
| Closure
480489
| Ctor
481490
| AnonConst
491+
| LateAnonConst
482492
| OpaqueTy
483493
| SyntheticCoroutineBody
484494
| NestedStatic => None,
@@ -498,7 +508,8 @@ impl DefPathData {
498508
GlobalAsm => DefPathDataName::Anon { namespace: sym::global_asm },
499509
Closure => DefPathDataName::Anon { namespace: sym::closure },
500510
Ctor => DefPathDataName::Anon { namespace: sym::constructor },
501-
AnonConst => DefPathDataName::Anon { namespace: sym::constant },
511+
AnonConst | LateAnonConst => DefPathDataName::Anon { namespace: sym::constant },
512+
DesugaredAnonymousLifetime => DefPathDataName::Named(kw::UnderscoreLifetime),
502513
OpaqueTy => DefPathDataName::Anon { namespace: sym::opaque },
503514
AnonAssocTy(..) => DefPathDataName::Anon { namespace: sym::anon_assoc },
504515
SyntheticCoroutineBody => DefPathDataName::Anon { namespace: sym::synthetic },

‎compiler/rustc_middle/src/ty/mod.rs‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ use rustc_errors::{Diag, ErrorGuaranteed};
3838
use rustc_hir::LangItem;
3939
use rustc_hir::def::{CtorKind, CtorOf, DefKind, DocLinkResMap, LifetimeRes, Res};
4040
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdMap};
41-
use rustc_hir::definitions::DisambiguatorState;
4241
use rustc_index::IndexVec;
4342
use rustc_index::bit_set::BitMatrix;
4443
use rustc_macros::{
@@ -221,8 +220,6 @@ pub struct ResolverAstLowering {
221220

222221
pub node_id_to_def_id: NodeMap<LocalDefId>,
223222

224-
pub disambiguator: DisambiguatorState,
225-
226223
pub trait_map: NodeMap<Vec<hir::TraitCandidate>>,
227224
/// List functions and methods for which lifetime elision was successful.
228225
pub lifetime_elision_allowed: FxHashSet<ast::NodeId>,

‎compiler/rustc_middle/src/ty/print/pretty.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2193,6 +2193,7 @@ fn guess_def_namespace(tcx: TyCtxt<'_>, def_id: DefId) -> Namespace {
21932193

21942194
DefPathData::ValueNs(..)
21952195
| DefPathData::AnonConst
2196+
| DefPathData::LateAnonConst
21962197
| DefPathData::Closure
21972198
| DefPathData::Ctor => Namespace::ValueNS,
21982199

‎compiler/rustc_resolve/src/lib.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1688,7 +1688,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
16881688
.into_items()
16891689
.map(|(k, f)| (k, f.key()))
16901690
.collect(),
1691-
disambiguator: self.disambiguator,
16921691
trait_map: self.trait_map,
16931692
lifetime_elision_allowed: self.lifetime_elision_allowed,
16941693
lint_buffer: Steal::new(self.lint_buffer),

‎compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,8 @@ fn encode_ty_name(tcx: TyCtxt<'_>, def_id: DefId) -> String {
714714
hir::definitions::DefPathData::ValueNs(..) => "v",
715715
hir::definitions::DefPathData::Closure => "C",
716716
hir::definitions::DefPathData::Ctor => "c",
717-
hir::definitions::DefPathData::AnonConst => "k",
717+
hir::definitions::DefPathData::AnonConst => "K",
718+
hir::definitions::DefPathData::LateAnonConst => "k",
718719
hir::definitions::DefPathData::OpaqueTy => "i",
719720
hir::definitions::DefPathData::SyntheticCoroutineBody => "s",
720721
hir::definitions::DefPathData::NestedStatic => "n",
@@ -724,6 +725,7 @@ fn encode_ty_name(tcx: TyCtxt<'_>, def_id: DefId) -> String {
724725
| hir::definitions::DefPathData::MacroNs(..)
725726
| hir::definitions::DefPathData::OpaqueLifetime(..)
726727
| hir::definitions::DefPathData::LifetimeNs(..)
728+
| hir::definitions::DefPathData::DesugaredAnonymousLifetime
727729
| hir::definitions::DefPathData::AnonAssocTy(..) => {
728730
bug!("encode_ty_name: unexpected `{:?}`", disambiguated_data.data);
729731
}

‎compiler/rustc_symbol_mangling/src/v0.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,8 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
874874
DefPathData::ValueNs(_) => 'v',
875875
DefPathData::Closure => 'C',
876876
DefPathData::Ctor => 'c',
877-
DefPathData::AnonConst => 'k',
877+
DefPathData::AnonConst => 'K',
878+
DefPathData::LateAnonConst => 'k',
878879
DefPathData::OpaqueTy => 'i',
879880
DefPathData::SyntheticCoroutineBody => 's',
880881
DefPathData::NestedStatic => 'n',
@@ -886,6 +887,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
886887
| DefPathData::Impl
887888
| DefPathData::MacroNs(_)
888889
| DefPathData::LifetimeNs(_)
890+
| DefPathData::DesugaredAnonymousLifetime
889891
| DefPathData::OpaqueLifetime(_)
890892
| DefPathData::AnonAssocTy(..) => {
891893
bug!("symbol_names: unexpected DefPathData: {:?}", disambiguated_data.data)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /