diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index 400a06c061e..cc04eb8eece 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -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); diff --git a/tests/run-pass/ice-3151.rs b/tests/run-pass/ice-3151.rs new file mode 100644 index 00000000000..5ee83dac7b3 --- /dev/null +++ b/tests/run-pass/ice-3151.rs @@ -0,0 +1,13 @@ +#[derive(Clone)] +pub struct HashMap { + hash_builder: S, + table: RawTable, +} + +#[derive(Clone)] +pub struct RawTable { + size: usize, + val: V +} + +fn main() {} \ No newline at end of file