Do not suggest using Error in no_std before Rust 1.81 (#13834)

changelog: [`result_unit_err`]: do not suggest using `Error` in `no_std`
mode before Rust 1.81

Fix #9767
This commit is contained in:
llogiq 2024-12-16 05:15:20 +00:00 committed by GitHub
commit 968669b00a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 67 additions and 13 deletions

View file

@ -0,0 +1,26 @@
#![feature(lang_items, start, libc)]
#![no_std]
#![warn(clippy::result_unit_err)]
#[clippy::msrv = "1.80"]
pub fn returns_unit_error_no_lint() -> Result<u32, ()> {
Err(())
}
#[clippy::msrv = "1.81"]
pub fn returns_unit_error_lint() -> Result<u32, ()> {
Err(())
}
#[start]
fn main(_argc: isize, _argv: *const *const u8) -> isize {
0
}
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
loop {}
}
#[lang = "eh_personality"]
extern "C" fn eh_personality() {}

View file

@ -0,0 +1,12 @@
error: this returns a `Result<_, ()>`
--> tests/ui/result_unit_error_no_std.rs:11:1
|
LL | pub fn returns_unit_error_lint() -> Result<u32, ()> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: use a custom `Error` type instead
= note: `-D clippy::result-unit-err` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::result_unit_err)]`
error: aborting due to 1 previous error