rust/tests/ui/traits/suggest-dereferences/invalid-suggest-deref-issue-127590.rs
2024-07-16 22:01:10 +08:00

19 lines
706 B
Rust

fn main() {
let fields = vec![1];
let variant = vec![2];
// should not suggest `*&variant.iter()`
for (src, dest) in std::iter::zip(fields.iter(), &variant.iter()) {
//~^ ERROR `&std::slice::Iter<'_, {integer}>` is not an iterator
//~| ERROR `&std::slice::Iter<'_, {integer}>` is not an iterator
eprintln!("{} {}", src, dest);
}
// don't suggest add `variant.iter().clone().clone()`
for (src, dest) in std::iter::zip(fields.iter(), &variant.iter().clone()) {
//~^ ERROR `&std::slice::Iter<'_, {integer}>` is not an iterator
//~| ERROR `&std::slice::Iter<'_, {integer}>` is not an iterator
eprintln!("{} {}", src, dest);
}
}