mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-18 22:09:30 +02:00
Merge tag 'rust-fixes-7.3-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux
Pull Rust fixes from Miguel Ojeda:
"Toolchain and infrastructure:
- Work around a 'bindgen' 0.73.2 bug that emits an 'allow' attribute
for 'unnecessary_transmutes', which is unknown in older compilers
- Clean 'clippy::as_underscore' lints in generated code by the new
'bindgen' 0.73.0+ releases
- Clean new 'clippy::needless_range_loop' lint for the upcoming Rust
1.100.0 (expected 2026-11-12)
'kernel' crate:
- 'num' module: fix soundness issue in 'Bounded' by sealing the
'Integer' trait
'pin-init' crate:
- Fix unreachable warning for the upcoming Rust 1.100.0 (expected
2026-11-12) due to 'Infallible' becoming an alias of '!'
Samples:
- Add missing newlines in 'pr_*!'s macro calls"
* tag 'rust-fixes-7.3-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux:
rust: allow `unknown_lints` in generated bindings for Rust < 1.88
rust: allow `clippy::as_underscore` in the generated bindings
rust: num: seal Integer
drm/panic: clean new `clippy::needless_range_loop` lint for Rust 1.100.0
rust: samples: add missing newlines in rust_print_main
rust: pin-init: use irrefutable pattern for `stack_pin_init`
This commit is contained in:
@@ -407,8 +407,8 @@ impl DecFifo {
|
||||
for i in (0..self.len).rev() {
|
||||
self.decimals[i + len] = self.decimals[i];
|
||||
}
|
||||
for i in 0..len {
|
||||
self.decimals[i] = (chunk % 10) as u8;
|
||||
for decimal in &mut self.decimals[..len] {
|
||||
*decimal = (chunk % 10) as u8;
|
||||
chunk = div10(chunk);
|
||||
}
|
||||
self.len += len;
|
||||
|
||||
@@ -22,11 +22,13 @@
|
||||
#![feature(cfi_encoding)]
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[allow(clippy::as_underscore)]
|
||||
#[allow(clippy::cast_lossless)]
|
||||
#[allow(clippy::ptr_as_ptr)]
|
||||
#[allow(clippy::ref_as_ptr)]
|
||||
#[allow(clippy::undocumented_unsafe_blocks)]
|
||||
#[cfg_attr(CONFIG_RUSTC_HAS_UNNECESSARY_TRANSMUTES, allow(unnecessary_transmutes))]
|
||||
#[cfg_attr(not(CONFIG_RUSTC_HAS_UNNECESSARY_TRANSMUTES), allow(unknown_lints))]
|
||||
#[allow(unnecessary_transmutes)]
|
||||
#[cfg_attr(
|
||||
CONFIG_RUSTC_HAS_SUSPICIOUS_RUNTIME_SYMBOL_DEFINITIONS,
|
||||
allow(suspicious_runtime_symbol_definitions)
|
||||
|
||||
+8
-1
@@ -15,9 +15,14 @@ pub enum Unsigned {}
|
||||
/// Designates signed primitive types.
|
||||
pub enum Signed {}
|
||||
|
||||
mod private {
|
||||
pub trait Sealed {}
|
||||
}
|
||||
|
||||
/// Describes core properties of integer types.
|
||||
pub trait Integer:
|
||||
Sized
|
||||
private::Sealed
|
||||
+ Sized
|
||||
+ Copy
|
||||
+ Clone
|
||||
+ PartialEq
|
||||
@@ -56,6 +61,8 @@ pub trait Integer:
|
||||
macro_rules! impl_integer {
|
||||
($($type:ty: $signedness:ty), *) => {
|
||||
$(
|
||||
impl private::Sealed for $type {}
|
||||
|
||||
impl Integer for $type {
|
||||
type Signedness = $signedness;
|
||||
|
||||
|
||||
@@ -490,13 +490,7 @@ macro_rules! stack_pin_init {
|
||||
(let $var:ident $(: $t:ty)? = $val:expr) => {
|
||||
let val = $val;
|
||||
let mut $var = ::core::pin::pin!($crate::__internal::StackInit$(::<$t>)?::uninit());
|
||||
let mut $var = match $crate::__internal::StackInit::init($var, val) {
|
||||
Ok(res) => res,
|
||||
Err(x) => {
|
||||
let x: ::core::convert::Infallible = x;
|
||||
match x {}
|
||||
}
|
||||
};
|
||||
let Ok(mut $var) = $crate::__internal::StackInit::init($var, val);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -10,6 +10,7 @@
|
||||
#![no_std]
|
||||
#![allow(
|
||||
clippy::all,
|
||||
clippy::as_underscore,
|
||||
clippy::cast_lossless,
|
||||
clippy::ptr_as_ptr,
|
||||
clippy::ref_as_ptr,
|
||||
@@ -23,7 +24,8 @@
|
||||
unreachable_pub,
|
||||
unsafe_op_in_unsafe_fn
|
||||
)]
|
||||
#![cfg_attr(CONFIG_RUSTC_HAS_UNNECESSARY_TRANSMUTES, allow(unnecessary_transmutes))]
|
||||
#![cfg_attr(not(CONFIG_RUSTC_HAS_UNNECESSARY_TRANSMUTES), allow(unknown_lints))]
|
||||
#![allow(unnecessary_transmutes)]
|
||||
#![cfg_attr(
|
||||
CONFIG_RUSTC_HAS_SUSPICIOUS_RUNTIME_SYMBOL_DEFINITIONS,
|
||||
allow(suspicious_runtime_symbol_definitions)
|
||||
|
||||
@@ -23,10 +23,10 @@ fn arc_print() -> Result {
|
||||
let b = UniqueArc::new("hello, world", GFP_KERNEL)?;
|
||||
|
||||
// Prints the value of data in `a`.
|
||||
pr_info!("{}", a);
|
||||
pr_info!("{}\n", a);
|
||||
|
||||
// Uses ":?" to print debug fmt of `b`.
|
||||
pr_info!("{:?}", b);
|
||||
pr_info!("{:?}\n", b);
|
||||
|
||||
let a: Arc<&str> = b.into();
|
||||
let c = a.clone();
|
||||
@@ -42,7 +42,7 @@ fn arc_print() -> Result {
|
||||
|
||||
use kernel::fmt::Display;
|
||||
fn arc_dyn_print(arc: &Arc<dyn Display>) {
|
||||
pr_info!("Arc<dyn Display> says {arc}");
|
||||
pr_info!("Arc<dyn Display> says {arc}\n");
|
||||
}
|
||||
|
||||
let a_i32_display: Arc<dyn Display> = Arc::new(42i32, GFP_KERNEL)?;
|
||||
@@ -53,7 +53,7 @@ fn arc_print() -> Result {
|
||||
}
|
||||
|
||||
// Pretty-prints the debug formatting with lower-case hexadecimal integers.
|
||||
pr_info!("{:#x?}", a);
|
||||
pr_info!("{:#x?}\n", a);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user