Skip to content

Commit c246363

Browse files
committed
Remove an argument that was always the same
1 parent 68a8580 commit c246363

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

compiler/rustc_ast_lowering/src/expr.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
488488
let mut generic_args = ThinVec::new();
489489
for (idx, arg) in args.iter().cloned().enumerate() {
490490
if legacy_args_idx.contains(&idx) {
491-
let parent_def_id = self.current_hir_id_owner.def_id;
492491
let node_id = self.next_node_id();
493-
self.create_def(parent_def_id, node_id, None, DefKind::AnonConst, f.span);
492+
self.create_def(node_id, None, DefKind::AnonConst, f.span);
494493
let mut visitor = WillCreateDefIdsVisitor {};
495494
let const_value = if let ControlFlow::Break(span) = visitor.visit_expr(&arg) {
496495
AstP(Expr {

compiler/rustc_ast_lowering/src/lib.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,6 @@ enum GenericArgsMode {
495495
impl<'a, 'hir> LoweringContext<'a, 'hir> {
496496
fn create_def(
497497
&mut self,
498-
parent: LocalDefId,
499498
node_id: ast::NodeId,
500499
name: Option<Symbol>,
501500
def_kind: DefKind,
@@ -510,7 +509,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
510509
self.tcx.hir_def_key(self.local_def_id(node_id)),
511510
);
512511

513-
let def_id = self.tcx.at(span).create_def(parent, name, def_kind).def_id();
512+
let def_id =
513+
self.tcx.at(span).create_def(self.current_hir_id_owner.def_id, name, def_kind).def_id();
514514

515515
debug!("create_def: def_id_to_node_id[{:?}] <-> {:?}", def_id, node_id);
516516
self.resolver.node_id_to_def_id.insert(node_id, def_id);
@@ -782,7 +782,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
782782
LifetimeRes::Fresh { param, kind, .. } => {
783783
// Late resolution delegates to us the creation of the `LocalDefId`.
784784
let _def_id = self.create_def(
785-
self.current_hir_id_owner.def_id,
786785
param,
787786
Some(kw::UnderscoreLifetime),
788787
DefKind::LifetimeParam,
@@ -2086,15 +2085,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20862085
} else {
20872086
// Construct an AnonConst where the expr is the "ty"'s path.
20882087

2089-
let parent_def_id = self.current_hir_id_owner.def_id;
20902088
let node_id = self.next_node_id();
20912089
let span = self.lower_span(span);
20922090

20932091
// Add a definition for the in-band const def.
20942092
// We're lowering a const argument that was originally thought to be a type argument,
20952093
// so the def collector didn't create the def ahead of time. That's why we have to do
20962094
// it here.
2097-
let def_id = self.create_def(parent_def_id, node_id, None, DefKind::AnonConst, span);
2095+
let def_id = self.create_def(node_id, None, DefKind::AnonConst, span);
20982096
let hir_id = self.lower_node_id(node_id);
20992097

21002098
let path_expr = Expr {

compiler/rustc_ast_lowering/src/pat.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -517,14 +517,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
517517
span: Span,
518518
base_type: Span,
519519
) -> &'hir hir::ConstArg<'hir> {
520-
let parent_def_id = self.current_hir_id_owner.def_id;
521520
let node_id = self.next_node_id();
522521

523522
// Add a definition for the in-band const def.
524523
// We're generating a range end that didn't exist in the AST,
525524
// so the def collector didn't create the def ahead of time. That's why we have to do
526525
// it here.
527-
let def_id = self.create_def(parent_def_id, node_id, None, DefKind::AnonConst, span);
526+
let def_id = self.create_def(node_id, None, DefKind::AnonConst, span);
528527
let hir_id = self.lower_node_id(node_id);
529528

530529
let unstable_span = self.mark_span_with_reason(

0 commit comments

Comments
 (0)