Skip to content

Commit

Permalink
Remove another duplicate def-creation
Browse files Browse the repository at this point in the history
  • Loading branch information
camelid committed Jun 14, 2024
1 parent ff85c3e commit 405f7de
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
14 changes: 2 additions & 12 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ use rustc_ast::ptr::P as AstP;
use rustc_ast::*;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def::Res;
use rustc_hir::HirId;
use rustc_middle::span_bug;
use rustc_session::errors::report_lit_error;
use rustc_span::source_map::{respan, Spanned};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::DUMMY_SP;
use rustc_span::{DesugaringKind, Span};
use thin_vec::{thin_vec, ThinVec};
Expand Down Expand Up @@ -377,18 +377,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
let mut generic_args = ThinVec::new();
for (idx, arg) in args.into_iter().enumerate() {
if legacy_args_idx.contains(&idx) {
let parent_def_id = self.current_hir_id_owner;
let node_id = self.next_node_id();

// Add a definition for the in-band const def.
self.create_def(
parent_def_id.def_id,
node_id,
kw::Empty,
DefKind::AnonConst,
f.span,
);

let anon_const = AnonConst { id: node_id, value: arg };
generic_args.push(AngleBracketedArg::Arg(GenericArg::Const(anon_const)));
} else {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2417,6 +2417,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
}

#[instrument(level = "debug", skip(self))]
fn lower_anon_const(&mut self, c: &AnonConst) -> &'hir hir::AnonConst {
// Some ast::AnonConst's turn into ConstArgKind::Path's, so we create their def
// only when we're sure they're going to stay as an AnonConst.
Expand Down

0 comments on commit 405f7de

Please sign in to comment.