6 Commits

Author SHA1 Message Date
bors
6906167e01 Auto merge of #148193 - camsteffen:remove-qpath-langitem, r=cjgillot
Remove `QPath::LangItem`

Closes rust-lang/rust#115178.

r? cjgillot
2025-10-30 10:04:21 +00:00
Cameron Steffen
9c98533491 Remove QPath::LangItem from contracts 2025-10-27 20:35:55 -05:00
Cameron Steffen
7e51a763c9 Prefactor LangItem::QPath lowering functions
Get ready to incrementally remove LangItem::QPath.
2025-10-27 19:31:45 -05:00
Dawid Lachowicz
aeae085dc3
Add contract variable declarations
Contract variables can be declared in the `requires` clause and
can be referenced both in `requires` and `ensures`, subject to usual
borrow checking rules.

This allows any setup common to both the `requires` and `ensures`
clauses to only be done once.
2025-10-18 15:00:34 +01:00
Dawid Lachowicz
2d87527e42
Guard HIR contracts based on compiler flag rather than lang_item
This allows the optimiser to properly eliminate contract code
when runtime contract checks are disabled.

It comes at the cost of having to recompile upstream crates
(e.g. std) to enable contracts in them. However, this trade
off is acceptable if it means disabled runtime contract checks
do not affect the runtime performance of the functions they annotate.

With the proper elimination of contract code, which this change
introduces, the runtime performance of annotated functions
should be the same as the original unannotated function.
2025-10-11 00:16:44 +01:00
Dawid Lachowicz
e4ead0ec70
Guard HIR lowered contracts with contract_checks
Refactor contract HIR lowering to ensure no contract code is
executed when contract-checks are disabled.

The call to contract_checks is moved to inside the lowered fn
body, and contract closures are built conditionally, ensuring
no side-effects present in contracts occur when those are disabled.
2025-10-11 00:16:29 +01:00