File: lint-unnecessary-qualification-issue-121331.fixed

package info (click to toggle)
rustc 1.88.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 934,128 kB
  • sloc: xml: 158,127; python: 36,062; javascript: 19,855; sh: 19,700; cpp: 18,947; ansic: 12,993; asm: 4,792; makefile: 690; lisp: 29; perl: 29; ruby: 19; sql: 11
file content (50 lines) | stat: -rw-r--r-- 1,126 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//@ run-rustfix
//@ edition:2021
#![deny(unused_qualifications)]
#![deny(unused_imports)]
#![feature(coroutines, coroutine_trait)]

use std::ops::{
    Coroutine,
    CoroutineState::{self},
    //~^ ERROR unused import: `*`
};
use std::pin::Pin;

#[allow(dead_code)]
fn finish<T>(mut amt: usize, mut t: T) -> T::Return
    where T: Coroutine<(), Yield = ()> + Unpin,
{
    loop {
        match Pin::new(&mut t).resume(()) {
            CoroutineState::Yielded(()) => amt = amt.checked_sub(1).unwrap(),
            CoroutineState::Complete(ret) => {
                assert_eq!(amt, 0);
                return ret
            }
        }
    }
}


mod foo {
    pub fn bar() {}
}

pub fn main() {

    use foo::bar;
    bar();
    //~^ ERROR unnecessary qualification
    bar();

    // The item `use std::string::String` is imported redundantly.
    // Suppress `unused_imports` reporting, otherwise the fixed file will report an error
    #[allow(unused_imports)]
    use std::string::String;
    let s = String::new();
    let y = std::string::String::new();
    // unnecessary qualification
    println!("{} {}", s, y);

}