rust/tests/ui/lint/use-redundant/use-redundant-issue-71450.rs
2024-03-05 10:45:09 +08:00

46 lines
804 B
Rust

//@ check-pass
#![warn(unused_imports)]
mod foo {
use std::fmt;
pub struct String;
impl String {
pub fn new() -> String {
String{}
}
}
impl fmt::Display for String {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "String")
}
}
}
fn main() {
{
use std::string::String; //~ WARNING the item `String` is imported redundantly
// 'String' from 'std::string::String'.
let s = String::new();
println!("{}", s);
}
{
// 'String' from 'std::string::String'.
let s = String::new();
println!("{}", s);
}
{
use foo::*;
// 'String' from 'foo::String'.
let s = String::new();
println!("{}", s);
}
}