rust/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.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

12 lines
329 B
Rust

//@ check-pass
//@ edition:2021
#![warn(unused_imports)]
use std::convert::TryFrom;//~ WARNING the item `TryFrom` is imported redundantly
use std::convert::TryInto;//~ WARNING the item `TryInto` is imported redundantly
fn main() {
let _e: Result<i32, _> = 8u8.try_into();
let _f: Result<i32, _> = i32::try_from(8u8);
}