Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust: remove all uses of unstable pragma "in_band_lifetimes" #1646

Merged
merged 1 commit into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 1 addition & 8 deletions arch/rv32i/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@

#![crate_name = "rv32i"]
#![crate_type = "rlib"]
#![feature(
asm,
const_fn,
lang_items,
global_asm,
naked_functions,
in_band_lifetimes
)]
#![feature(asm, const_fn, lang_items, global_asm, naked_functions)]
#![no_std]

use core::fmt::Write;
Expand Down
8 changes: 4 additions & 4 deletions arch/rv32i/src/machine_timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ pub struct MachineTimer<'a> {
client: OptionalCell<&'a dyn hil::time::AlarmClient>,
}

impl MachineTimer<'a> {
pub const fn new(base: StaticRef<MachineTimerRegisters>) -> MachineTimer<'a> {
impl MachineTimer<'_> {
pub const fn new(base: StaticRef<MachineTimerRegisters>) -> Self {
MachineTimer {
registers: base,
client: OptionalCell::empty(),
Expand All @@ -53,7 +53,7 @@ impl MachineTimer<'a> {
}
}

impl hil::time::Time for MachineTimer<'a> {
impl hil::time::Time for MachineTimer<'_> {
type Frequency = hil::time::Freq32KHz;

fn now(&self) -> u32 {
Expand All @@ -65,7 +65,7 @@ impl hil::time::Time for MachineTimer<'a> {
}
}

impl hil::time::Alarm<'a> for MachineTimer<'a> {
impl<'a> hil::time::Alarm<'a> for MachineTimer<'a> {
fn set_client(&self, client: &'a dyn hil::time::AlarmClient) {
self.client.set(client);
}
Expand Down
2 changes: 1 addition & 1 deletion boards/arty_e21/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Disable this attribute when documenting, as a workaround for
// https://github.com/rust-lang/rust/issues/62184.
#![cfg_attr(not(doc), no_main)]
#![feature(const_fn, in_band_lifetimes)]
#![feature(const_fn)]

use capsules::virtual_alarm::{MuxAlarm, VirtualMuxAlarm};
use kernel::capabilities;
Expand Down
4 changes: 2 additions & 2 deletions boards/arty_e21/src/timer_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct TimerTest<'a, A: Alarm<'a>> {
alarm: &'a A,
}

impl<A: Alarm<'a>> TimerTest<'a, A> {
impl<'a, A: Alarm<'a>> TimerTest<'a, A> {
pub const fn new(alarm: &'a A) -> TimerTest<'a, A> {
TimerTest { alarm: alarm }
}
Expand All @@ -20,7 +20,7 @@ impl<A: Alarm<'a>> TimerTest<'a, A> {
}
}

impl<A: Alarm<'a>> time::AlarmClient for TimerTest<'a, A> {
impl<'a, A: Alarm<'a>> time::AlarmClient for TimerTest<'a, A> {
fn fired(&self) {
debug!("timer!!");
}
Expand Down
1 change: 0 additions & 1 deletion boards/imix/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// Disable this attribute when documenting, as a workaround for
// https://github.com/rust-lang/rust/issues/62184.
#![cfg_attr(not(doc), no_main)]
#![feature(in_band_lifetimes)]
#![deny(missing_docs)]

mod imix_components;
Expand Down
2 changes: 1 addition & 1 deletion boards/imix/src/test/icmp_lowpan_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl<'a, A: time::Alarm<'a>> capsules::net::icmpv6::icmpv6_send::ICMP6SendClient
}
}

impl<A: time::Alarm<'a>> LowpanICMPTest<'a, A> {
impl<'a, A: time::Alarm<'a>> LowpanICMPTest<'a, A> {
pub fn new(
alarm: A,
icmp_sender: &'a dyn ICMP6Sender<'a>,
Expand Down
8 changes: 4 additions & 4 deletions capsules/src/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub static mut ADC_BUFFER2: [u16; 128] = [0; 128];
pub static mut ADC_BUFFER3: [u16; 128] = [0; 128];

/// Functions to create, initialize, and interact with the ADC
impl<A: hil::adc::Adc + hil::adc::AdcHighSpeed> Adc<'a, A> {
impl<'a, A: hil::adc::Adc + hil::adc::AdcHighSpeed> Adc<'a, A> {
/// Create a new `Adc` application interface.
///
/// - `adc` - ADC driver to provide application access to
Expand Down Expand Up @@ -570,7 +570,7 @@ impl<A: hil::adc::Adc + hil::adc::AdcHighSpeed> Adc<'a, A> {
}

/// Callbacks from the ADC driver
impl<A: hil::adc::Adc + hil::adc::AdcHighSpeed> hil::adc::Client for Adc<'a, A> {
impl<A: hil::adc::Adc + hil::adc::AdcHighSpeed> hil::adc::Client for Adc<'_, A> {
/// Single sample operation complete.
///
/// Collects the sample and provides a callback to the application.
Expand Down Expand Up @@ -644,7 +644,7 @@ impl<A: hil::adc::Adc + hil::adc::AdcHighSpeed> hil::adc::Client for Adc<'a, A>
}

/// Callbacks from the High Speed ADC driver
impl<A: hil::adc::Adc + hil::adc::AdcHighSpeed> hil::adc::HighSpeedClient for Adc<'a, A> {
impl<A: hil::adc::Adc + hil::adc::AdcHighSpeed> hil::adc::HighSpeedClient for Adc<'_, A> {
/// Internal buffer has filled from a buffered sampling operation.
/// Copies data over to application buffer, determines if more data is
/// needed, and performs a callback to the application if ready. If
Expand Down Expand Up @@ -968,7 +968,7 @@ impl<A: hil::adc::Adc + hil::adc::AdcHighSpeed> hil::adc::HighSpeedClient for Ad
}

/// Implementations of application syscalls
impl<A: hil::adc::Adc + hil::adc::AdcHighSpeed> Driver for Adc<'a, A> {
impl<A: hil::adc::Adc + hil::adc::AdcHighSpeed> Driver for Adc<'_, A> {
/// Provides access to a buffer from the application to store data in or
/// read data from.
///
Expand Down
8 changes: 5 additions & 3 deletions capsules/src/aes_ccm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub struct AES128CCM<'a, A: AES128<'a> + AES128Ctr + AES128CBC> {
saved_tag: Cell<[u8; AES128_BLOCK_SIZE]>,
}

impl<A: AES128<'a> + AES128Ctr + AES128CBC> AES128CCM<'a, A> {
impl<'a, A: AES128<'a> + AES128Ctr + AES128CBC> AES128CCM<'a, A> {
pub fn new(aes: &'a A, crypt_buf: &'static mut [u8]) -> AES128CCM<'a, A> {
AES128CCM {
aes: aes,
Expand Down Expand Up @@ -414,7 +414,7 @@ impl<A: AES128<'a> + AES128Ctr + AES128CBC> AES128CCM<'a, A> {
}
}

impl<A: AES128<'a> + AES128Ctr + AES128CBC> symmetric_encryption::AES128CCM<'a>
impl<'a, A: AES128<'a> + AES128Ctr + AES128CBC> symmetric_encryption::AES128CCM<'a>
for AES128CCM<'a, A>
{
fn set_client(&self, client: &'a dyn symmetric_encryption::CCMClient) {
Expand Down Expand Up @@ -492,7 +492,9 @@ impl<A: AES128<'a> + AES128Ctr + AES128CBC> symmetric_encryption::AES128CCM<'a>
}
}

impl<A: AES128<'a> + AES128Ctr + AES128CBC> symmetric_encryption::Client<'a> for AES128CCM<'a, A> {
impl<'a, A: AES128<'a> + AES128Ctr + AES128CBC> symmetric_encryption::Client<'a>
for AES128CCM<'a, A>
{
fn crypt_done(&self, _: Option<&'a mut [u8]>, crypt_buf: &'a mut [u8]) {
self.crypt_buf.replace(crypt_buf);
match self.state.get() {
Expand Down
6 changes: 3 additions & 3 deletions capsules/src/alarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub struct AlarmDriver<'a, A: Alarm<'a>> {
prev: Cell<u32>,
}

impl<A: Alarm<'a>> AlarmDriver<'a, A> {
impl<'a, A: Alarm<'a>> AlarmDriver<'a, A> {
pub const fn new(alarm: &'a A, grant: Grant<AlarmData>) -> AlarmDriver<'a, A> {
AlarmDriver {
alarm: alarm,
Expand Down Expand Up @@ -76,7 +76,7 @@ impl<A: Alarm<'a>> AlarmDriver<'a, A> {
}
}

impl<A: Alarm<'a>> Driver for AlarmDriver<'a, A> {
impl<'a, A: Alarm<'a>> Driver for AlarmDriver<'a, A> {
/// Subscribe to alarm expiration
///
/// ### `_subscribe_num`
Expand Down Expand Up @@ -180,7 +180,7 @@ fn has_expired(alarm: u32, now: u32, prev: u32) -> bool {
now.wrapping_sub(prev) >= alarm.wrapping_sub(prev)
}

impl<A: Alarm<'a>> time::AlarmClient for AlarmDriver<'a, A> {
impl<'a, A: Alarm<'a>> time::AlarmClient for AlarmDriver<'a, A> {
fn fired(&self) {
let now = self.alarm.now();
self.app_alarm.each(|alarm| {
Expand Down
8 changes: 4 additions & 4 deletions capsules/src/ambient_light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct AmbientLight<'a> {
apps: Grant<App>,
}

impl AmbientLight<'a> {
impl<'a> AmbientLight<'a> {
pub fn new(sensor: &'a dyn hil::sensors::AmbientLight, grant: Grant<App>) -> AmbientLight {
AmbientLight {
sensor: sensor,
Expand All @@ -58,7 +58,7 @@ impl AmbientLight<'a> {
}
}

impl Driver for AmbientLight<'a> {
impl Driver for AmbientLight<'_> {
/// Subscribe to light intensity readings
///
/// ### `subscribe`
Expand Down Expand Up @@ -94,7 +94,7 @@ impl Driver for AmbientLight<'a> {
///
/// - `0`: Check driver presence
/// - `1`: Start a light sensor reading
fn command(&self, command_num: usize, _arg1: usize, _: usize, appid: AppId) -> ReturnCode {
fn command(&self, command_num: usize, _: usize, _: usize, appid: AppId) -> ReturnCode {
match command_num {
0 /* check if present */ => ReturnCode::SUCCESS,
1 => {
Expand All @@ -106,7 +106,7 @@ impl Driver for AmbientLight<'a> {
}
}

impl hil::sensors::AmbientLightClient for AmbientLight<'a> {
impl hil::sensors::AmbientLightClient for AmbientLight<'_> {
fn callback(&self, lux: usize) {
self.command_pending.set(false);
self.apps.each(|app| {
Expand Down
12 changes: 6 additions & 6 deletions capsules/src/analog_sensor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct AnalogLightSensor<'a, A: hil::adc::Adc> {
client: OptionalCell<&'a dyn hil::sensors::AmbientLightClient>,
}

impl<A: hil::adc::Adc> AnalogLightSensor<'a, A> {
impl<'a, A: hil::adc::Adc> AnalogLightSensor<'a, A> {
pub fn new(
adc: &'a A,
channel: &'a <A as hil::adc::Adc>::Channel,
Expand All @@ -38,7 +38,7 @@ impl<A: hil::adc::Adc> AnalogLightSensor<'a, A> {
}

/// Callbacks from the ADC driver
impl<A: hil::adc::Adc> hil::adc::Client for AnalogLightSensor<'a, A> {
impl<A: hil::adc::Adc> hil::adc::Client for AnalogLightSensor<'_, A> {
fn sample_ready(&self, sample: u16) {
// TODO: calculate the actual light reading.
let measurement: usize = match self.sensor_type {
Expand All @@ -51,7 +51,7 @@ impl<A: hil::adc::Adc> hil::adc::Client for AnalogLightSensor<'a, A> {
}
}

impl<A: hil::adc::Adc> hil::sensors::AmbientLight for AnalogLightSensor<'a, A> {
impl<A: hil::adc::Adc> hil::sensors::AmbientLight for AnalogLightSensor<'_, A> {
fn set_client(&self, client: &'static dyn hil::sensors::AmbientLightClient) {
self.client.set(client);
}
Expand All @@ -74,7 +74,7 @@ pub struct AnalogTemperatureSensor<'a, A: hil::adc::Adc> {
client: OptionalCell<&'a dyn hil::sensors::TemperatureClient>,
}

impl<A: hil::adc::Adc> AnalogTemperatureSensor<'a, A> {
impl<'a, A: hil::adc::Adc> AnalogTemperatureSensor<'a, A> {
pub fn new(
adc: &'a A,
channel: &'a <A as hil::adc::Adc>::Channel,
Expand All @@ -90,7 +90,7 @@ impl<A: hil::adc::Adc> AnalogTemperatureSensor<'a, A> {
}

/// Callbacks from the ADC driver
impl<A: hil::adc::Adc> hil::adc::Client for AnalogTemperatureSensor<'a, A> {
impl<A: hil::adc::Adc> hil::adc::Client for AnalogTemperatureSensor<'_, A> {
fn sample_ready(&self, sample: u16) {
// TODO: calculate the actual temperature reading.
let measurement: usize = match self.sensor_type {
Expand All @@ -107,7 +107,7 @@ impl<A: hil::adc::Adc> hil::adc::Client for AnalogTemperatureSensor<'a, A> {
}
}

impl<A: hil::adc::Adc> hil::sensors::TemperatureDriver for AnalogTemperatureSensor<'a, A> {
impl<A: hil::adc::Adc> hil::sensors::TemperatureDriver for AnalogTemperatureSensor<'_, A> {
fn set_client(&self, client: &'static dyn hil::sensors::TemperatureClient) {
self.client.set(client);
}
Expand Down
6 changes: 3 additions & 3 deletions capsules/src/app_flash_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub struct AppFlash<'a> {
buffer: TakeCell<'static, [u8]>,
}

impl AppFlash<'a> {
impl<'a> AppFlash<'a> {
pub fn new(
driver: &'a dyn hil::nonvolatile_storage::NonvolatileStorage<'static>,
grant: Grant<App>,
Expand Down Expand Up @@ -106,7 +106,7 @@ impl AppFlash<'a> {
}
}

impl hil::nonvolatile_storage::NonvolatileStorageClient<'static> for AppFlash<'a> {
impl hil::nonvolatile_storage::NonvolatileStorageClient<'static> for AppFlash<'_> {
fn read_done(&self, _buffer: &'static mut [u8], _length: usize) {}

fn write_done(&self, buffer: &'static mut [u8], _length: usize) {
Expand Down Expand Up @@ -158,7 +158,7 @@ impl hil::nonvolatile_storage::NonvolatileStorageClient<'static> for AppFlash<'a
}
}

impl Driver for AppFlash<'a> {
impl Driver for AppFlash<'_> {
/// Setup buffer to write from.
///
/// ### `allow_num`
Expand Down
10 changes: 5 additions & 5 deletions capsules/src/ble_advertising_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ where
receiving_app: OptionalCell<kernel::AppId>,
}

impl<B, A> BLE<'a, B, A>
impl<'a, B, A> BLE<'a, B, A>
where
B: ble_advertising::BleAdvertisementDriver + ble_advertising::BleConfig,
A: kernel::hil::time::Alarm<'a>,
Expand Down Expand Up @@ -359,7 +359,7 @@ where
}

// Timer alarm
impl<B, A> kernel::hil::time::AlarmClient for BLE<'a, B, A>
impl<'a, B, A> kernel::hil::time::AlarmClient for BLE<'a, B, A>
where
B: ble_advertising::BleAdvertisementDriver + ble_advertising::BleConfig,
A: kernel::hil::time::Alarm<'a>,
Expand Down Expand Up @@ -428,7 +428,7 @@ where
}

// Callback from the radio once a RX event occur
impl<B, A> ble_advertising::RxClient for BLE<'a, B, A>
impl<'a, B, A> ble_advertising::RxClient for BLE<'a, B, A>
where
B: ble_advertising::BleAdvertisementDriver + ble_advertising::BleConfig,
A: kernel::hil::time::Alarm<'a>,
Expand Down Expand Up @@ -495,7 +495,7 @@ where
}

// Callback from the radio once a TX event occur
impl<B, A> ble_advertising::TxClient for BLE<'a, B, A>
impl<'a, B, A> ble_advertising::TxClient for BLE<'a, B, A>
where
B: ble_advertising::BleAdvertisementDriver + ble_advertising::BleConfig,
A: kernel::hil::time::Alarm<'a>,
Expand Down Expand Up @@ -536,7 +536,7 @@ where
}

// System Call implementation
impl<B, A> kernel::Driver for BLE<'a, B, A>
impl<'a, B, A> kernel::Driver for BLE<'a, B, A>
where
B: ble_advertising::BleAdvertisementDriver + ble_advertising::BleConfig,
A: kernel::hil::time::Alarm<'a>,
Expand Down
6 changes: 3 additions & 3 deletions capsules/src/buzzer_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub struct Buzzer<'a, A: hil::time::Alarm<'a>> {
max_duration_ms: usize,
}

impl<A: hil::time::Alarm<'a>> Buzzer<'a, A> {
impl<'a, A: hil::time::Alarm<'a>> Buzzer<'a, A> {
pub fn new(
pwm_pin: &'a dyn hil::pwm::PwmPin,
alarm: &'a A,
Expand Down Expand Up @@ -162,7 +162,7 @@ impl<A: hil::time::Alarm<'a>> Buzzer<'a, A> {
}
}

impl<A: hil::time::Alarm<'a>> hil::time::AlarmClient for Buzzer<'a, A> {
impl<'a, A: hil::time::Alarm<'a>> hil::time::AlarmClient for Buzzer<'a, A> {
fn fired(&self) {
// All we have to do is stop the PWM and check if there are any pending
// uses of the buzzer.
Expand All @@ -180,7 +180,7 @@ impl<A: hil::time::Alarm<'a>> hil::time::AlarmClient for Buzzer<'a, A> {
}

/// Provide an interface for userland.
impl<A: hil::time::Alarm<'a>> Driver for Buzzer<'a, A> {
impl<'a, A: hil::time::Alarm<'a>> Driver for Buzzer<'a, A> {
/// Setup callbacks.
///
/// ### `subscribe_num`
Expand Down