Skip to content

Commit bbec284

Browse files
author
Carolyn Zech
committed
Upgrade toolchain to 2025-04-01
1 parent e84fccd commit bbec284

File tree

3 files changed

+12
-25
lines changed

3 files changed

+12
-25
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,11 @@ pub mod rustc_smir {
266266
for mapping in &cov_info.mappings {
267267
let Code { bcb } = mapping.kind else { unreachable!() };
268268
let source_map = tcx.sess.source_map();
269-
let file = source_map.lookup_source_file(cov_info.body_span.lo());
269+
let file = source_map.lookup_source_file(mapping.span.lo());
270270
if bcb == coverage {
271271
return Some((
272-
make_source_region(source_map, cov_info, &file, mapping.span).unwrap(),
273-
rustc_internal::stable(cov_info.body_span).get_filename(),
272+
make_source_region(source_map, &file, mapping.span).unwrap(),
273+
rustc_internal::stable(mapping.span).get_filename(),
274274
));
275275
}
276276
}

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

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
//! the `Span` to `CoverageRegion` conversion defined in
66
//! https://github.com/rust-lang/rust/tree/master/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/spans.rs
77
8-
use rustc_middle::mir::coverage::FunctionCoverageInfo;
98
use rustc_span::Span;
109
use rustc_span::source_map::SourceMap;
1110
use rustc_span::{BytePos, SourceFile};
@@ -27,33 +26,22 @@ impl Debug for SourceRegion {
2726
}
2827
}
2928

30-
fn ensure_non_empty_span(
31-
source_map: &SourceMap,
32-
fn_cov_info: &FunctionCoverageInfo,
33-
span: Span,
34-
) -> Option<Span> {
29+
fn ensure_non_empty_span(source_map: &SourceMap, span: Span) -> Option<Span> {
3530
if !span.is_empty() {
3631
return Some(span);
3732
}
38-
let lo = span.lo();
39-
let hi = span.hi();
40-
// The span is empty, so try to expand it to cover an adjacent '{' or '}',
41-
// but only within the bounds of the body span.
42-
let try_next = hi < fn_cov_info.body_span.hi();
43-
let try_prev = fn_cov_info.body_span.lo() < lo;
44-
if !(try_next || try_prev) {
45-
return None;
46-
}
33+
34+
// The span is empty, so try to enlarge it to cover an adjacent '{' or '}'.
4735
source_map
4836
.span_to_source(span, |src, start, end| try {
4937
// Adjusting span endpoints by `BytePos(1)` is normally a bug,
5038
// but in this case we have specifically checked that the character
5139
// we're skipping over is one of two specific ASCII characters, so
5240
// adjusting by exactly 1 byte is correct.
53-
if try_next && src.as_bytes()[end] == b'{' {
54-
Some(span.with_hi(hi + BytePos(1)))
55-
} else if try_prev && src.as_bytes()[start - 1] == b'}' {
56-
Some(span.with_lo(lo - BytePos(1)))
41+
if src.as_bytes().get(end).copied() == Some(b'{') {
42+
Some(span.with_hi(span.hi() + BytePos(1)))
43+
} else if start > 0 && src.as_bytes()[start - 1] == b'}' {
44+
Some(span.with_lo(span.lo() - BytePos(1)))
5745
} else {
5846
None
5947
}
@@ -104,11 +92,10 @@ fn check_source_region(source_region: SourceRegion) -> Option<SourceRegion> {
10492
/// better than an ICE or `llvm-cov` failure that the user might have no way to avoid.
10593
pub(crate) fn make_source_region(
10694
source_map: &SourceMap,
107-
fn_cov_info: &FunctionCoverageInfo,
10895
file: &SourceFile,
10996
span: Span,
11097
) -> Option<SourceRegion> {
111-
let span = ensure_non_empty_span(source_map, fn_cov_info, span)?;
98+
let span = ensure_non_empty_span(source_map, span)?;
11299
let lo = span.lo();
113100
let hi = span.hi();
114101
// Column numbers need to be in bytes, so we can't use the more convenient

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-03-19"
5+
channel = "nightly-2025-04-01"
66
components = ["llvm-tools", "rustc-dev", "rust-src", "rustfmt"]

0 commit comments

Comments
 (0)