Skip to content

Commit 2666964

Browse files
authored
Merge pull request #500 from skibon02/fix_vect_active_from
Fixed VectActive::from() returning incorrect value
2 parents 1ef0864 + e15768d commit 2666964

File tree

7 files changed

+12
-27
lines changed

7 files changed

+12
-27
lines changed

.github/bors.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ delete_merged_branches = true
33
required_approvals = 1
44
status = [
55
"ci-linux (stable)",
6-
"ci-linux (1.38.0)",
6+
"ci-linux (1.59.0)",
77
"rustfmt",
88
"clippy",
99
]

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
include:
1919
# Test MSRV
20-
- rust: 1.38.0
20+
- rust: 1.59.0
2121
features: ""
2222

2323
# Test nightly but don't fail

Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ version = "1"
2727
features = [ "derive" ]
2828
optional = true
2929

30+
[dependencies.serde_json]
31+
version = "1"
32+
optional = true
33+
3034
[features]
3135
cm7 = []
3236
cm7-r0p1 = ["cm7"]

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This project is developed and maintained by the [Cortex-M team][team].
1111

1212
## Minimum Supported Rust Version (MSRV)
1313

14-
This crate is guaranteed to compile on stable Rust 1.38 and up. It might compile with older versions but that may change in any new patch release.
14+
This crate is guaranteed to compile on stable Rust 1.59 and up. It might compile with older versions but that may change in any new patch release.
1515

1616
## License
1717

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
//!
6464
//! # Minimum Supported Rust Version (MSRV)
6565
//!
66-
//! This crate is guaranteed to compile on stable Rust 1.38 and up. It *might*
66+
//! This crate is guaranteed to compile on stable Rust 1.59 and up. It *might*
6767
//! compile with older versions but that may change in any new patch release.
6868
6969
#![deny(missing_docs)]

src/peripheral/scb.rs

+3-20
Original file line numberDiff line numberDiff line change
@@ -172,25 +172,8 @@ impl SCB {
172172
pub fn vect_active() -> VectActive {
173173
let icsr = unsafe { ptr::read(&(*SCB::PTR).icsr as *const _ as *const u32) };
174174

175-
match icsr as u8 {
176-
0 => VectActive::ThreadMode,
177-
2 => VectActive::Exception(Exception::NonMaskableInt),
178-
3 => VectActive::Exception(Exception::HardFault),
179-
#[cfg(not(armv6m))]
180-
4 => VectActive::Exception(Exception::MemoryManagement),
181-
#[cfg(not(armv6m))]
182-
5 => VectActive::Exception(Exception::BusFault),
183-
#[cfg(not(armv6m))]
184-
6 => VectActive::Exception(Exception::UsageFault),
185-
#[cfg(any(armv8m, native))]
186-
7 => VectActive::Exception(Exception::SecureFault),
187-
11 => VectActive::Exception(Exception::SVCall),
188-
#[cfg(not(armv6m))]
189-
12 => VectActive::Exception(Exception::DebugMonitor),
190-
14 => VectActive::Exception(Exception::PendSV),
191-
15 => VectActive::Exception(Exception::SysTick),
192-
irqn => VectActive::Interrupt { irqn: irqn - 16 },
193-
}
175+
// NOTE(unsafe): Assume correctly selected target.
176+
unsafe { VectActive::from(icsr as u8).unwrap_unchecked() }
194177
}
195178
}
196179

@@ -300,7 +283,7 @@ impl VectActive {
300283
12 => VectActive::Exception(Exception::DebugMonitor),
301284
14 => VectActive::Exception(Exception::PendSV),
302285
15 => VectActive::Exception(Exception::SysTick),
303-
irqn if irqn >= 16 => VectActive::Interrupt { irqn },
286+
irqn if irqn >= 16 => VectActive::Interrupt { irqn: irqn - 16 },
304287
_ => return None,
305288
})
306289
}

xtask/tests/ci.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ fn check_crates_build(is_nightly: bool, is_msrv: bool) {
5858
// Relies on all crates in this repo to use the same convention.
5959
let should_use_feature = |feat: &str| {
6060
match feat {
61-
// critical-section doesn't build in 1.38 due to using `#[doc(include_str!(..))]`
62-
"critical-section-single-core" => !is_msrv,
6361
// This is nightly-only, so don't use it on stable.
6462
"inline-asm" => is_nightly,
6563
// This only affects thumbv7em targets.
@@ -105,7 +103,7 @@ fn main() {
105103

106104
let output = Command::new("rustc").arg("-V").output().unwrap();
107105
let is_nightly = str::from_utf8(&output.stdout).unwrap().contains("nightly");
108-
let is_msrv = str::from_utf8(&output.stdout).unwrap().contains("1.38");
106+
let is_msrv = str::from_utf8(&output.stdout).unwrap().contains("1.59");
109107

110108
check_crates_build(is_nightly, is_msrv);
111109

0 commit comments

Comments
 (0)