rust/tests/ui/for-loop-while/while-prelude-drop.rs
surechen 40ae34194c remove redundant imports
detects redundant imports that can be eliminated.

for #117772 :

In order to facilitate review and modification, split the checking code and
removing redundant imports code into two PR.
2023-12-10 10:56:22 +08:00

22 lines
406 B
Rust

// run-pass
#![allow(non_camel_case_types)]
#[derive(PartialEq)]
enum t { a, b(String), }
fn make(i: isize) -> t {
if i > 10 { return t::a; }
let mut s = String::from("hello");
// Ensure s is non-const.
s.push_str("there");
return t::b(s);
}
pub fn main() {
let mut i = 0;
// The auto slot for the result of make(i) should not leak.
while make(i) != t::a { i += 1; }
}