Skip to content

Commit 9c98533

Browse files
committed
Remove QPath::LangItem from contracts
1 parent eac2c25 commit 9c98533

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

compiler/rustc_ast_lowering/src/contract.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::sync::Arc;
2+
13
use thin_vec::thin_vec;
24

35
use crate::LoweringContext;
@@ -118,9 +120,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
118120
let req_span = self.mark_span_with_reason(
119121
rustc_span::DesugaringKind::Contract,
120122
lowered_req.span,
121-
None,
123+
Some(Arc::clone(&self.allow_contracts)),
122124
);
123-
let precond = self.expr_call_lang_item_qpath_fn_mut(
125+
let precond = self.expr_call_lang_item_fn_mut(
124126
req_span,
125127
rustc_hir::LangItem::ContractCheckRequires,
126128
&*arena_vec![self; lowered_req],
@@ -133,10 +135,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
133135
ens: &Box<rustc_ast::Expr>,
134136
) -> &'hir rustc_hir::Expr<'hir> {
135137
let ens_span = self.lower_span(ens.span);
136-
let ens_span =
137-
self.mark_span_with_reason(rustc_span::DesugaringKind::Contract, ens_span, None);
138+
let ens_span = self.mark_span_with_reason(
139+
rustc_span::DesugaringKind::Contract,
140+
ens_span,
141+
Some(Arc::clone(&self.allow_contracts)),
142+
);
138143
let lowered_ens = self.lower_expr_mut(&ens);
139-
self.expr_call_lang_item_qpath_fn(
144+
self.expr_call_lang_item_fn(
140145
ens_span,
141146
rustc_hir::LangItem::ContractBuildCheckEnsures,
142147
&*arena_vec![self; lowered_ens],
@@ -291,7 +296,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
291296
let ret = self.expr_ident(span, ret_ident, ret_hir_id);
292297

293298
let cond_fn = self.expr_ident(span, cond_ident, cond_hir_id);
294-
let contract_check = self.expr_call_lang_item_qpath_fn_mut(
299+
let contract_check = self.expr_call_lang_item_fn_mut(
295300
span,
296301
rustc_hir::LangItem::ContractCheckEnsures,
297302
arena_vec![self; *cond_fn, *ret],

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ struct LoweringContext<'a, 'hir> {
138138
#[cfg(debug_assertions)]
139139
node_id_to_local_id: NodeMap<hir::ItemLocalId>,
140140

141+
allow_contracts: Arc<[Symbol]>,
141142
allow_try_trait: Arc<[Symbol]>,
142143
allow_gen_future: Arc<[Symbol]>,
143144
allow_pattern_type: Arc<[Symbol]>,
@@ -183,6 +184,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
183184
current_item: None,
184185
impl_trait_defs: Vec::new(),
185186
impl_trait_bounds: Vec::new(),
187+
allow_contracts: [sym::contracts_internals].into(),
186188
allow_try_trait: [sym::try_trait_v2, sym::yeet_desugar_details].into(),
187189
allow_pattern_type: [sym::pattern_types, sym::pattern_type_range_trait].into(),
188190
allow_gen_future: if tcx.features().async_fn_track_caller() {

0 commit comments

Comments
 (0)