diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-08 19:09:25 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-08 19:09:25 +0100 |
commit | f9ec7cebef732fbc9d4849d87d325efef5faadea (patch) | |
tree | 4a40dbed04c432dee54f8a8d016c89c7411b1e6d /crates/ra_hir_ty/src/tests.rs | |
parent | f1fa9aa4c4d4fcfe7d6e90ba9cefca90bc7c4998 (diff) | |
parent | d0129c4ddba3b72e7b26e94e9c25546d37dbf166 (diff) |
Merge #4377
4377: Implement better handling of divergence r=matklad a=flodiebold
Divergence here means that for some reason, the end of a block will not be reached. We tried to model this just using the never type, but that doesn't work fully (e.g. in `let x = { loop {}; "foo" };` x should still have type `&str`); so this introduces a `diverges` flag that the type checker keeps track of, like rustc does. We also add some checking for `break`, but no support for break-with-value or labeled breaks yet.
Co-authored-by: Florian Diebold <[email protected]>
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty/src/tests.rs')
-rw-r--r-- | crates/ra_hir_ty/src/tests.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index d60732e19..5af88b368 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs | |||
@@ -518,3 +518,21 @@ fn missing_record_pat_field_no_diagnostic_if_not_exhaustive() { | |||
518 | 518 | ||
519 | assert_snapshot!(diagnostics, @""); | 519 | assert_snapshot!(diagnostics, @""); |
520 | } | 520 | } |
521 | |||
522 | #[test] | ||
523 | fn break_outside_of_loop() { | ||
524 | let diagnostics = TestDB::with_files( | ||
525 | r" | ||
526 | //- /lib.rs | ||
527 | fn foo() { | ||
528 | break; | ||
529 | } | ||
530 | ", | ||
531 | ) | ||
532 | .diagnostics() | ||
533 | .0; | ||
534 | |||
535 | assert_snapshot!(diagnostics, @r###""break": break outside of loop | ||
536 | "### | ||
537 | ); | ||
538 | } | ||