Description
HILs with 'static
not in the context of buffers:
- adc (Remove 'static from ADC HIL client #3455)
- ble_advertising.rs (hil: remove 'static from ble_advertising #1964)
- crc.rs (CRC HIL: make lifetime 'a, not 'static #1956)
- gpio.rs (hil: gpio: remove 'static #1965)
- i2c.rs (hil: i2c: remove 'static from client #3467)
- radio.rs (hil: remove 'static for client in radio #3459)
- screen (hil: screen: make client 'a #3461)
- sensors.rs (HIL: remove 'static from sensors #1959)
- spi.rs (hil: spi: remove 'static from client #3460)
Early in Tock we used 'static
lifetimes fairly liberally. As interfaces matured, we shifted towards generic lifetimes ('a
) for the flexibility it (could eventually) affords components. Unfortunately, many of the HILs currently specific static rather than generic lifetimes.
As noted in (2) of #1069, one example of a negative consequence is an artificial restriction of where and how clients can be set.
I believe that the use of static lifetimes is largely a historical artifact, however I wanted to open this as an RFC in case this is something folks feel we need to discuss further before adapting.
Current Status
From a highly scientific and imprecise study, we have more HILs with static lifetimes than generic, but I think that can be attributed to history. Loosely, the newer HILs seem to prefer generic lifetimes:
# Static
$ git grep static | grep -v '//!' | cut -d':' -f1 | sort | uniq -c
9 adc.rs
5 ble_advertising.rs
4 flash.rs
11 i2c.rs
4 led.rs
1 ninedof.rs
5 nonvolatile_storage.rs
12 radio.rs
4 sensors.rs
14 spi.rs
3 symmetric_encryption.rs
6 uart.rs
# Generic
$ git grep "'a" | grep -v '//!' | cut -d':' -f1 | sort | uniq -c
2 flash.rs
10 symmetric_encryption.rs