about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/crashes/ice-2774.fixed
blob: 35d969441763c08f9aee58bb2fff7abb2e8c33b2 (plain)
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
use std::collections::HashSet;

// See rust-lang/rust-clippy#2774.

#[derive(Eq, PartialEq, Debug, Hash)]
pub struct Bar {
    foo: Foo,
}

#[derive(Eq, PartialEq, Debug, Hash)]
pub struct Foo;

#[allow(clippy::implicit_hasher)]
// This should not cause a "cannot relate bound region" ICE.
pub fn add_barfoos_to_foos(bars: &HashSet<&Bar>) {
    //~^ needless_lifetimes

    let mut foos = HashSet::new();
    foos.extend(bars.iter().map(|b| &b.foo));
}

#[allow(clippy::implicit_hasher)]
// Also, this should not cause a "cannot relate bound region" ICE.
pub fn add_barfoos_to_foos2(bars: &HashSet<&Bar>) {
    let mut foos = HashSet::new();
    foos.extend(bars.iter().map(|b| &b.foo));
}

fn main() {}