From 7ebde241c00cd9eb816b1aa7cb212a946afb0d3e Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 9 Feb 2019 18:24:54 +0100 Subject: Fix two crashes found by running inference on all of rustc --- crates/ra_hir/src/ty/tests.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'crates/ra_hir/src/ty/tests.rs') diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 2621d1b55..3139eba0b 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -630,6 +630,39 @@ fn test() { ); } +#[test] +fn infer_std_crash_1() { + // caused stack overflow, taken from std + check_inference( + "infer_std_crash_1", + r#" +enum Maybe { + Real(T), + Fake, +} + +fn write() { + match something_unknown { + Maybe::Real(ref mut something) => (), + } +} +"#, + ); +} + +#[test] +fn infer_std_crash_2() { + // caused "equating two type variables, ...", taken from std + check_inference( + "infer_std_crash_2", + r#" +fn test_line_buffer() { + &[0, b'\n', 1, b'\n']; +} +"#, + ); +} + fn infer(content: &str) -> String { let (db, _, file_id) = MockDatabase::with_single_file(content); let source_file = db.parse(file_id); -- cgit v1.2.3