Skip to content

Commit 43549eb

Browse files
committed
fixes #3151 by skipping the lint instead of crashing
1 parent fdd830f commit 43549eb

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

clippy_lints/src/types.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,9 +1810,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImplicitHasher {
18101810

18111811
let generics_suggestion_span = generics.span.substitute_dummy({
18121812
let pos = snippet_opt(cx, item.span.until(target.span()))
1813-
.and_then(|snip| Some(item.span.lo() + BytePos(snip.find("impl")? as u32 + 4)))
1814-
.expect("failed to create span for type arguments");
1815-
Span::new(pos, pos, item.span.data().ctxt)
1813+
.and_then(|snip| Some(item.span.lo() + BytePos(snip.find("impl")? as u32 + 4)));
1814+
if let Some(pos) = pos {
1815+
Span::new(pos, pos, item.span.data().ctxt)
1816+
}else{
1817+
return;
1818+
}
18161819
});
18171820

18181821
let mut ctr_vis = ImplicitHasherConstructorVisitor::new(cx, target);

tests/run-pass/ice-3151.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#[derive(Clone)]
2+
pub struct HashMap<V, S> {
3+
hash_builder: S,
4+
table: RawTable<V>,
5+
}
6+
7+
#[derive(Clone)]
8+
pub struct RawTable<V> {
9+
size: usize,
10+
val: V
11+
}
12+
13+
fn main() {}

0 commit comments

Comments
 (0)