summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/crashes/ice-2774.rs
blob: 88cfa1f923c0bff23329871fa193c2698e3c65b5 (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
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<'a>(bars: &HashSet<&'a Bar>) {
    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() {}