Skip to content

Commit 59c8746

Browse files
committed
rust: avoid the need of crate attributes in kernel modules
Instead of enabling the features per-module, do it globally. This removes the need to write boilerplate such as `#![no_std]` in kernel modules, which does not bring much value given the allowed features are constrained anyway. There is the question of whether to enable only the most common ones (`allocator_api` and `global_asm`) in order to easily see uncommon features being used. However, we only have other three features, and they are either going to get stabilized/workarounded/removed at some point and/or they are easy to spot anyway. We are using `-Zcrate-attr` for convenience here, but we do not really depend on it: like for other unstable features, if this was the last feature to get stabilized, we would simply workaround it. Furthermore, it is likely we will change how modules are compiled in a way that makes this not needed. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 90965d5 commit 59c8746

14 files changed

+5
-41
lines changed

drivers/android/rust_binder.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
//!
55
//! TODO: This module is a work in progress.
66
7-
#![no_std]
8-
#![feature(global_asm, allocator_api, concat_idents, generic_associated_types)]
9-
107
use kernel::{
118
io_buffer::IoBufferWriter,
129
linked_list::{GetLinks, GetLinksWrapped, Links},

drivers/char/hw_random/bcm2835_rng_rust.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
//! Broadcom BCM2835 Random Number Generator support.
44
5-
#![no_std]
6-
#![feature(allocator_api, global_asm)]
7-
85
use kernel::{
96
c_str, device, file::File, file_operations::FileOperations, io_buffer::IoBufferWriter, miscdev,
107
module_platform_driver, of, platform, prelude::*, sync::Ref,

drivers/gpio/gpio_pl061_rust.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
//!
55
//! Based on the C driver written by Baruch Siach <baruch@tkos.co.il>.
66
7-
#![no_std]
8-
#![feature(global_asm, allocator_api)]
9-
107
use kernel::{
118
amba, bit, bits_iter, define_amba_id_table, device, gpio,
129
io_mem::IoMem,

samples/rust/rust_chrdev.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
//! Rust character device sample
44
5-
#![no_std]
6-
#![feature(allocator_api, global_asm)]
7-
85
use kernel::prelude::*;
96
use kernel::{chrdev, file, file_operations::FileOperations};
107

samples/rust/rust_minimal.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
//! Rust minimal sample
44
5-
#![no_std]
6-
#![feature(allocator_api, global_asm)]
7-
85
use kernel::prelude::*;
96

107
module! {

samples/rust/rust_miscdev.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
//! Rust miscellaneous device sample
44
5-
#![no_std]
6-
#![feature(allocator_api, global_asm)]
7-
85
use kernel::prelude::*;
96
use kernel::{
107
file::File,

samples/rust/rust_module_parameters.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
//! Rust module parameters sample
44
5-
#![no_std]
6-
#![feature(allocator_api, global_asm)]
7-
85
use kernel::prelude::*;
96

107
module! {

samples/rust/rust_platform.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
//! Rust platform device driver sample.
44
5-
#![no_std]
6-
#![feature(allocator_api, global_asm)]
7-
85
use kernel::{module_platform_driver, of, platform, prelude::*};
96

107
module_platform_driver! {

samples/rust/rust_print.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
//! Rust printing macros sample
44
5-
#![no_std]
6-
#![feature(allocator_api, global_asm)]
7-
85
use kernel::prelude::*;
96
use kernel::{pr_cont, str::CStr, ThisModule};
107

samples/rust/rust_random.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
//! Adapted from Alex Gaynor's original available at
66
//! <https://github.com/alex/just-use/blob/master/src/lib.rs>.
77
8-
#![no_std]
9-
#![feature(allocator_api, global_asm)]
10-
118
use kernel::{
129
file::File,
1310
file_operations::FileOperations,

0 commit comments

Comments
 (0)