Skip to content

Commit 51de000

Browse files
Upgrade toolchain to 2025-02-11 (model-checking#3887)
Update Rust to nightly-2025-02-11 Upstream PR: rust-lang/rust@ee7dc06#diff-51b3860a8aed92b0e981635d4118d369c49850f5b7acf780d31f5ddd5d5d0bc2 Resolves model-checking#3884 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses. --------- Co-authored-by: Zyad Hassan <[email protected]> Co-authored-by: Zyad Hassan <[email protected]>
1 parent 006e5da commit 51de000

File tree

4 files changed

+17
-32
lines changed

4 files changed

+17
-32
lines changed

kani-compiler/src/codegen_cprover_gotoc/codegen/function.rs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl GotocCtx<'_> {
220220
pub mod rustc_smir {
221221
use crate::codegen_cprover_gotoc::codegen::source_region::{SourceRegion, make_source_region};
222222
use crate::stable_mir::CrateDef;
223-
use rustc_middle::mir::coverage::CovTerm;
223+
use rustc_middle::mir::coverage::BasicCoverageBlock;
224224
use rustc_middle::mir::coverage::MappingKind::Code;
225225
use rustc_middle::ty::TyCtxt;
226226
use rustc_smir::rustc_internal;
@@ -236,16 +236,16 @@ pub mod rustc_smir {
236236
coverage_opaque: &CoverageOpaque,
237237
instance: Instance,
238238
) -> Option<(SourceRegion, Filename)> {
239-
let cov_term = parse_coverage_opaque(coverage_opaque);
240-
region_from_coverage(tcx, cov_term, instance)
239+
let bcb = parse_coverage_opaque(coverage_opaque);
240+
region_from_coverage(tcx, bcb, instance)
241241
}
242242

243-
/// Retrieves the `SourceRegion` associated with a `CovTerm` object.
243+
/// Retrieves the `SourceRegion` associated with a `BasicCoverageBlock` object.
244244
///
245245
/// Note: This function could be in the internal `rustc` impl for `Coverage`.
246246
pub fn region_from_coverage(
247247
tcx: TyCtxt<'_>,
248-
coverage: CovTerm,
248+
coverage: BasicCoverageBlock,
249249
instance: Instance,
250250
) -> Option<(SourceRegion, Filename)> {
251251
// We need to pull the coverage info from the internal MIR instance.
@@ -257,10 +257,10 @@ pub mod rustc_smir {
257257
if let Some(cov_info) = &body.function_coverage_info {
258258
// Iterate over the coverage mappings and match with the coverage term.
259259
for mapping in &cov_info.mappings {
260-
let Code(term) = mapping.kind else { unreachable!() };
260+
let Code { bcb } = mapping.kind else { unreachable!() };
261261
let source_map = tcx.sess.source_map();
262262
let file = source_map.lookup_source_file(cov_info.body_span.lo());
263-
if term == coverage {
263+
if bcb == coverage {
264264
return Some((
265265
make_source_region(source_map, cov_info, &file, mapping.span).unwrap(),
266266
rustc_internal::stable(cov_info.body_span).get_filename(),
@@ -271,25 +271,17 @@ pub mod rustc_smir {
271271
None
272272
}
273273

274-
/// Parse a `CoverageOpaque` item and return the corresponding `CovTerm`:
275-
/// <https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/coverage/enum.CovTerm.html>
276-
///
277-
/// At present, a `CovTerm` can be one of the following:
278-
/// - `CounterIncrement(<num>)`: A physical counter.
279-
/// - `ExpressionUsed(<num>)`: An expression-based counter.
280-
/// - `Zero`: A counter with a constant zero value.
281-
fn parse_coverage_opaque(coverage_opaque: &Opaque) -> CovTerm {
274+
/// Parse a `CoverageOpaque` item and return the corresponding `BasicCoverageBlock`:
275+
fn parse_coverage_opaque(coverage_opaque: &Opaque) -> BasicCoverageBlock {
282276
let coverage_str = coverage_opaque.to_string();
283-
if let Some(rest) = coverage_str.strip_prefix("CounterIncrement(") {
284-
let (num_str, _rest) = rest.split_once(')').unwrap();
285-
let num = num_str.parse::<u32>().unwrap();
286-
CovTerm::Counter(num.into())
287-
} else if let Some(rest) = coverage_str.strip_prefix("ExpressionUsed(") {
277+
if let Some(rest) = coverage_str.strip_prefix("VirtualCounter(bcb") {
288278
let (num_str, _rest) = rest.split_once(')').unwrap();
289279
let num = num_str.parse::<u32>().unwrap();
290-
CovTerm::Expression(num.into())
280+
BasicCoverageBlock::from_u32(num)
291281
} else {
292-
CovTerm::Zero
282+
// When the coverage statement is injected into mir_body, it always has the form CoverageKind::VirtualCounter { bcb }
283+
// https://github.com/rust-lang/rust/pull/136053/files#diff-c99ec9a281dce4a381fa7e11cf2d04f55dba5573d1d14389d47929fe0a154d24R209-R212
284+
unreachable!();
293285
}
294286
}
295287
}

kani-driver/src/call_cbmc.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ fn coverage_results_from_properties(properties: &[Property]) -> Option<CoverageR
501501
static COUNTER_RE: OnceLock<Regex> = OnceLock::new();
502502
COUNTER_RE.get_or_init(|| {
503503
Regex::new(
504-
r#"^(?<kind>CounterIncrement|ExpressionUsed)\((?<counter_num>[0-9]+)\) \$(?<func_name>[^\$]+)\$ - (?<span>.+)"#,
504+
r#"^(?<kind>VirtualCounter\(bcb)(?<counter_num>[0-9]+)\) \$(?<func_name>[^\$]+)\$ - (?<span>.+)"#,
505505
)
506506
.unwrap()
507507
})
@@ -511,20 +511,14 @@ fn coverage_results_from_properties(properties: &[Property]) -> Option<CoverageR
511511

512512
for prop in cov_properties {
513513
let mut prop_processed = false;
514-
515514
if let Some(captures) = counter_re.captures(&prop.description) {
516-
let kind = &captures["kind"];
517515
let counter_num = &captures["counter_num"];
518516
let function = demangle(&captures["func_name"]).to_string();
519517
let status = prop.status;
520518
let span = captures["span"].to_string();
521519

522520
let counter_id = counter_num.parse().unwrap();
523-
let term = match kind {
524-
"CounterIncrement" => CoverageTerm::Counter(counter_id),
525-
"ExpressionUsed" => CoverageTerm::Expression(counter_id),
526-
_ => unreachable!("counter kind could not be recognized: {:?}", kind),
527-
};
521+
let term = CoverageTerm::Counter(counter_id);
528522
let region = CoverageRegion::from_str(span);
529523

530524
let cov_check = CoverageCheck::new(function, term, region, status);

kani-driver/src/coverage/cov_results.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ impl CoverageCheck {
6464
#[derive(Debug, Clone, Serialize, Deserialize)]
6565
pub enum CoverageTerm {
6666
Counter(u32),
67-
Expression(u32),
6867
}
6968

7069
#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# SPDX-License-Identifier: Apache-2.0 OR MIT
33

44
[toolchain]
5-
channel = "nightly-2025-02-10"
5+
channel = "nightly-2025-02-11"
66
components = ["llvm-tools", "rustc-dev", "rust-src", "rustfmt"]

0 commit comments

Comments
 (0)