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:
commit
968669b00a
5 changed files with 67 additions and 13 deletions
26
tests/ui/result_unit_error_no_std.rs
Normal file
26
tests/ui/result_unit_error_no_std.rs
Normal 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() {}
|
||||
12
tests/ui/result_unit_error_no_std.stderr
Normal file
12
tests/ui/result_unit_error_no_std.stderr
Normal 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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue