Remove QPath::LangItem from contracts
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
use thin_vec::thin_vec;
|
use thin_vec::thin_vec;
|
||||||
|
|
||||||
use crate::LoweringContext;
|
use crate::LoweringContext;
|
||||||
@@ -118,9 +120,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||||||
let req_span = self.mark_span_with_reason(
|
let req_span = self.mark_span_with_reason(
|
||||||
rustc_span::DesugaringKind::Contract,
|
rustc_span::DesugaringKind::Contract,
|
||||||
lowered_req.span,
|
lowered_req.span,
|
||||||
None,
|
Some(Arc::clone(&self.allow_contracts)),
|
||||||
);
|
);
|
||||||
let precond = self.expr_call_lang_item_qpath_fn_mut(
|
let precond = self.expr_call_lang_item_fn_mut(
|
||||||
req_span,
|
req_span,
|
||||||
rustc_hir::LangItem::ContractCheckRequires,
|
rustc_hir::LangItem::ContractCheckRequires,
|
||||||
&*arena_vec![self; lowered_req],
|
&*arena_vec![self; lowered_req],
|
||||||
@@ -133,10 +135,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||||||
ens: &Box<rustc_ast::Expr>,
|
ens: &Box<rustc_ast::Expr>,
|
||||||
) -> &'hir rustc_hir::Expr<'hir> {
|
) -> &'hir rustc_hir::Expr<'hir> {
|
||||||
let ens_span = self.lower_span(ens.span);
|
let ens_span = self.lower_span(ens.span);
|
||||||
let ens_span =
|
let ens_span = self.mark_span_with_reason(
|
||||||
self.mark_span_with_reason(rustc_span::DesugaringKind::Contract, ens_span, None);
|
rustc_span::DesugaringKind::Contract,
|
||||||
|
ens_span,
|
||||||
|
Some(Arc::clone(&self.allow_contracts)),
|
||||||
|
);
|
||||||
let lowered_ens = self.lower_expr_mut(&ens);
|
let lowered_ens = self.lower_expr_mut(&ens);
|
||||||
self.expr_call_lang_item_qpath_fn(
|
self.expr_call_lang_item_fn(
|
||||||
ens_span,
|
ens_span,
|
||||||
rustc_hir::LangItem::ContractBuildCheckEnsures,
|
rustc_hir::LangItem::ContractBuildCheckEnsures,
|
||||||
&*arena_vec![self; lowered_ens],
|
&*arena_vec![self; lowered_ens],
|
||||||
@@ -291,7 +296,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||||||
let ret = self.expr_ident(span, ret_ident, ret_hir_id);
|
let ret = self.expr_ident(span, ret_ident, ret_hir_id);
|
||||||
|
|
||||||
let cond_fn = self.expr_ident(span, cond_ident, cond_hir_id);
|
let cond_fn = self.expr_ident(span, cond_ident, cond_hir_id);
|
||||||
let contract_check = self.expr_call_lang_item_qpath_fn_mut(
|
let contract_check = self.expr_call_lang_item_fn_mut(
|
||||||
span,
|
span,
|
||||||
rustc_hir::LangItem::ContractCheckEnsures,
|
rustc_hir::LangItem::ContractCheckEnsures,
|
||||||
arena_vec![self; *cond_fn, *ret],
|
arena_vec![self; *cond_fn, *ret],
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ struct LoweringContext<'a, 'hir> {
|
|||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
node_id_to_local_id: NodeMap<hir::ItemLocalId>,
|
node_id_to_local_id: NodeMap<hir::ItemLocalId>,
|
||||||
|
|
||||||
|
allow_contracts: Arc<[Symbol]>,
|
||||||
allow_try_trait: Arc<[Symbol]>,
|
allow_try_trait: Arc<[Symbol]>,
|
||||||
allow_gen_future: Arc<[Symbol]>,
|
allow_gen_future: Arc<[Symbol]>,
|
||||||
allow_pattern_type: Arc<[Symbol]>,
|
allow_pattern_type: Arc<[Symbol]>,
|
||||||
@@ -183,6 +184,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||||||
current_item: None,
|
current_item: None,
|
||||||
impl_trait_defs: Vec::new(),
|
impl_trait_defs: Vec::new(),
|
||||||
impl_trait_bounds: Vec::new(),
|
impl_trait_bounds: Vec::new(),
|
||||||
|
allow_contracts: [sym::contracts_internals].into(),
|
||||||
allow_try_trait: [sym::try_trait_v2, sym::yeet_desugar_details].into(),
|
allow_try_trait: [sym::try_trait_v2, sym::yeet_desugar_details].into(),
|
||||||
allow_pattern_type: [sym::pattern_types, sym::pattern_type_range_trait].into(),
|
allow_pattern_type: [sym::pattern_types, sym::pattern_type_range_trait].into(),
|
||||||
allow_gen_future: if tcx.features().async_fn_track_caller() {
|
allow_gen_future: if tcx.features().async_fn_track_caller() {
|
||||||
|
|||||||
Reference in New Issue
Block a user