aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/tests/regression.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-06-20 18:38:27 +0100
committerGitHub <[email protected]>2021-06-20 18:38:27 +0100
commit3898387f3bd579c0c5415ecb7c7b3d3923947f2f (patch)
treec30eec53f9330ac571e4f10e3191f7507b2b0fcf /crates/hir_ty/src/tests/regression.rs
parent8cc2b710db6ea851f0c4b636172861df98ba5ead (diff)
parenta1120b6879afe39f69a04eb0f6ee84d4cb4e03f6 (diff)
Merge #9346
9346: Refactor / clean up hir_ty tests r=flodiebold a=flodiebold Notable changes: - unify `check_types` and `check_mismatches` into `check`, which supports both kinds of annotations (`check_types` still exists because I didn't want to change all the annotations, but uses the same implementation) - because of that, `check_types` now fails on any type mismatches; also annotations always have to hit the exact range - there's also `check_no_mismatches` for when we explicitly just want to check that there are no type mismatches without giving any annotations (`check` will fail without annotations) - test annotations can now be overlapping (they point to the nearest line that has actual code in that range): ``` // ^^^^ annotation // ^^^^^^^^^ another annotation ``` Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/hir_ty/src/tests/regression.rs')
-rw-r--r--crates/hir_ty/src/tests/regression.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/crates/hir_ty/src/tests/regression.rs b/crates/hir_ty/src/tests/regression.rs
index 0f418ea49..8c5e8954c 100644
--- a/crates/hir_ty/src/tests/regression.rs
+++ b/crates/hir_ty/src/tests/regression.rs
@@ -1,6 +1,6 @@
1use expect_test::expect; 1use expect_test::expect;
2 2
3use super::{check_infer, check_types}; 3use super::{check_infer, check_no_mismatches, check_types};
4 4
5#[test] 5#[test]
6fn bug_484() { 6fn bug_484() {
@@ -422,20 +422,20 @@ fn issue_2683_chars_impl() {
422pub struct Chars<'a> {} 422pub struct Chars<'a> {}
423impl<'a> Iterator for Chars<'a> { 423impl<'a> Iterator for Chars<'a> {
424 type Item = char; 424 type Item = char;
425 fn next(&mut self) -> Option<char> {} 425 fn next(&mut self) -> Option<char> { loop {} }
426} 426}
427 427
428fn test() { 428fn test() {
429 let chars: Chars<'_>; 429 let chars: Chars<'_>;
430 (chars.next(), chars.nth(1)); 430 (chars.next(), chars.nth(1));
431} //^ (Option<char>, Option<char>) 431} //^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (Option<char>, Option<char>)
432"#, 432"#,
433 ); 433 );
434} 434}
435 435
436#[test] 436#[test]
437fn issue_3642_bad_macro_stackover() { 437fn issue_3642_bad_macro_stackover() {
438 check_types( 438 check_no_mismatches(
439 r#" 439 r#"
440#[macro_export] 440#[macro_export]
441macro_rules! match_ast { 441macro_rules! match_ast {
@@ -452,7 +452,6 @@ macro_rules! match_ast {
452 452
453fn main() { 453fn main() {
454 let anchor = match_ast! { 454 let anchor = match_ast! {
455 //^ ()
456 match parent { 455 match parent {
457 as => {}, 456 as => {},
458 _ => return None 457 _ => return None
@@ -956,7 +955,7 @@ trait IterTrait<'a, T: 'a>: Iterator<Item = &'a T> {
956 955
957fn clone_iter<T>(s: Iter<T>) { 956fn clone_iter<T>(s: Iter<T>) {
958 s.inner.clone_box(); 957 s.inner.clone_box();
959 //^^^^^^^^^^^^^^^^^^^ () 958 //^^^^^^^^^^^^^^^^^^^ ()
960} 959}
961"#, 960"#,
962 ) 961 )