Skip to content

Commit 5272291

Browse files
authored
Check clippy::large_stack_frames (#241)
* Check `clippy::large_stack_frames` * CHANGELOG.md * Allow bigger stack frames for Trouble * Allow for `main` * Remove the patches
1 parent 6940794 commit 5272291

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- Enable https://rust-lang.github.io/rust-clippy/master/index.html#large_stack_frames with a threshold of 1024 (#241)
13+
1214
### Changed
1315

1416
### Fixed

template/.clippy.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
stack-size-threshold = 1024

template/src/bin/async_main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
reason = "mem::forget is generally not safe to do with esp_hal types, especially those \
88
holding buffers for the duration of a data transfer."
99
)]
10+
#![deny(clippy::large_stack_frames)]
1011

1112
use esp_hal::clock::CpuClock;
1213
use esp_hal::timer::timg::TimerGroup;
@@ -57,6 +58,10 @@ const L2CAP_CHANNELS_MAX: usize = 1;
5758
// For more information see: <https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/app_image_format.html#application-description>
5859
esp_bootloader_esp_idf::esp_app_desc!();
5960

61+
#[allow(
62+
clippy::large_stack_frames,
63+
reason = "it's not unusual to allocate larger buffers etc. in main"
64+
)]
6065
#[esp_rtos::main]
6166
async fn main(spawner: Spawner) -> ! {
6267
//REPLACE generate-version generate-version
@@ -110,7 +115,7 @@ async fn main(spawner: Spawner) -> ! {
110115
//IF option("ble-trouble")
111116
// find more examples https://github.com/embassy-rs/trouble/tree/main/examples/esp32
112117
let transport = BleConnector::new(&radio_init, peripherals.BT, Default::default()).unwrap();
113-
let ble_controller = ExternalController::<_, 20>::new(transport);
118+
let ble_controller = ExternalController::<_, 1>::new(transport);
114119
let mut resources: HostResources<DefaultPacketPool, CONNECTIONS_MAX, L2CAP_CHANNELS_MAX> =
115120
HostResources::new();
116121
let _stack = trouble_host::new(ble_controller, &mut resources);

template/src/bin/main.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
reason = "mem::forget is generally not safe to do with esp_hal types, especially those \
77
holding buffers for the duration of a data transfer."
88
)]
9+
#![deny(clippy::large_stack_frames)]
910

1011
use esp_hal::{
1112
clock::CpuClock,
@@ -49,6 +50,10 @@ extern crate alloc;
4950
// For more information see: <https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/app_image_format.html#application-description>
5051
esp_bootloader_esp_idf::esp_app_desc!();
5152

53+
#[allow(
54+
clippy::large_stack_frames,
55+
reason = "it's not unusual to allocate larger buffers etc. in main"
56+
)]
5257
#[main]
5358
fn main() -> ! {
5459
//REPLACE generate-version generate-version

0 commit comments

Comments
 (0)