rust/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.rs
surechen a61126cef6 By tracking import use types to check whether it is scope uses or the other situations like module-relative uses, we can do more accurate redundant import checking.
fixes #117448

For example unnecessary imports in std::prelude that can be eliminated:

```rust
use std::option::Option::Some;//~ WARNING the item `Some` is imported redundantly
use std::option::Option::None; //~ WARNING the item `None` is imported redundantly
```
2024-02-18 16:38:11 +08:00

20 lines
668 B
Rust

//@ check-pass
#![warn(unused_imports)]
use std::option::Option::Some;//~ WARNING the item `Some` is imported redundantly
use std::option::Option::None; //~ WARNING the item `None` is imported redundantly
use std::result::Result::Ok;//~ WARNING the item `Ok` is imported redundantly
use std::result::Result::Err;//~ WARNING the item `Err` is imported redundantly
use std::convert::{TryFrom, TryInto};
fn main() {
let _a: Option<i32> = Some(1);
let _b: Option<i32> = None;
let _c: Result<i32, String> = Ok(1);
let _d: Result<i32, &str> = Err("error");
let _e: Result<i32, _> = 8u8.try_into();
let _f: Result<i32, _> = i32::try_from(8u8);
}