Skip to content

Commit

Permalink
fixes #3151 by skipping the lint instead of crashing
Browse files Browse the repository at this point in the history
  • Loading branch information
PSeitz committed Sep 8, 2018
1 parent fdd830f commit 43549eb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
9 changes: 6 additions & 3 deletions clippy_lints/src/types.rs
Expand Up @@ -1810,9 +1810,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImplicitHasher {

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

let mut ctr_vis = ImplicitHasherConstructorVisitor::new(cx, target);
Expand Down
13 changes: 13 additions & 0 deletions tests/run-pass/ice-3151.rs
@@ -0,0 +1,13 @@
#[derive(Clone)]
pub struct HashMap<V, S> {
hash_builder: S,
table: RawTable<V>,
}

#[derive(Clone)]
pub struct RawTable<V> {
size: usize,
val: V
}

fn main() {}

0 comments on commit 43549eb

Please sign in to comment.