Skip to content

Commit

Permalink
Auto merge of #119234 - aDotInTheVoid:ast-lowering-asserts, r=<try>
Browse files Browse the repository at this point in the history
ast_lowering: Make some asserts debug only.

Ran into this code, as was kinda surprised these are still here in release. These methods seem hot.

r? `@ghost`

`@bors` try `@rust-timer` queue
  • Loading branch information
bors committed Dec 22, 2023
2 parents d6d7a93 + 0c7ec74 commit 3927ced
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions compiler/rustc_ast_lowering/src/lib.rs
Expand Up @@ -507,7 +507,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
span: Span,
) -> LocalDefId {
debug_assert_ne!(node_id, ast::DUMMY_NODE_ID);
assert!(
debug_assert!(
self.opt_local_def_id(node_id).is_none(),
"adding a def'n for node-id {:?} and def kind {:?} but a previous def'n exists: {:?}",
node_id,
Expand Down Expand Up @@ -702,7 +702,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
/// properly. Calling the method twice with the same `NodeId` is fine though.
#[instrument(level = "debug", skip(self), ret)]
fn lower_node_id(&mut self, ast_node_id: NodeId) -> hir::HirId {
assert_ne!(ast_node_id, DUMMY_NODE_ID);
debug_assert_ne!(ast_node_id, DUMMY_NODE_ID);

match self.node_id_to_local_id.entry(ast_node_id) {
Entry::Occupied(o) => {
Expand All @@ -717,7 +717,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
v.insert(local_id);
self.item_local_id_counter.increment_by(1);

assert_ne!(local_id, hir::ItemLocalId::new(0));
debug_assert_ne!(local_id, hir::ItemLocalId::new(0));
if let Some(def_id) = self.opt_local_def_id(ast_node_id) {
self.children.push((def_id, hir::MaybeOwner::NonOwner(hir_id)));
}
Expand All @@ -736,7 +736,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
fn next_id(&mut self) -> hir::HirId {
let owner = self.current_hir_id_owner;
let local_id = self.item_local_id_counter;
assert_ne!(local_id, hir::ItemLocalId::new(0));
debug_assert_ne!(local_id, hir::ItemLocalId::new(0));
self.item_local_id_counter.increment_by(1);
hir::HirId { owner, local_id }
}
Expand Down

0 comments on commit 3927ced

Please sign in to comment.