aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-06-14 20:55:05 +0100
committerAleksey Kladov <[email protected]>2021-06-15 09:46:47 +0100
commit3f4ad44082abe7256825f6fc692c1455a1eb28bb (patch)
tree2cd099af0420486014a40d730ac492a6686418b7
parentc2015e7d182f3cb2cebe686127dd6a3e683df9e6 (diff)
internal: document that we don't #[ignore] tests
-rw-r--r--crates/hir_def/src/nameres/collector.rs21
-rw-r--r--crates/hir_ty/src/tests/coercion.rs35
-rw-r--r--crates/hir_ty/src/tests/traits.rs1
-rw-r--r--crates/ide/src/doc_links.rs18
-rw-r--r--crates/ide/src/hover.rs5
-rw-r--r--crates/ide_assists/src/handlers/fix_visibility.rs32
-rw-r--r--crates/ide_diagnostics/src/handlers/incorrect_case.rs38
-rw-r--r--docs/dev/style.md7
8 files changed, 86 insertions, 71 deletions
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs
index 6fab58f15..4ae02e576 100644
--- a/crates/hir_def/src/nameres/collector.rs
+++ b/crates/hir_def/src/nameres/collector.rs
@@ -1992,8 +1992,8 @@ mod tests {
1992 collector.def_map 1992 collector.def_map
1993 } 1993 }
1994 1994
1995 fn do_resolve(code: &str) -> DefMap { 1995 fn do_resolve(not_ra_fixture: &str) -> DefMap {
1996 let (db, _file_id) = TestDB::with_single_file(code); 1996 let (db, _file_id) = TestDB::with_single_file(not_ra_fixture);
1997 let krate = db.test_crate(); 1997 let krate = db.test_crate();
1998 1998
1999 let edition = db.crate_graph()[krate].edition; 1999 let edition = db.crate_graph()[krate].edition;
@@ -2013,16 +2013,21 @@ mod tests {
2013 ); 2013 );
2014 } 2014 }
2015 2015
2016 #[ignore] // this test does succeed, but takes quite a while :/ 2016 #[ignore]
2017 #[test] 2017 #[test]
2018 fn test_macro_expand_will_stop_2() { 2018 fn test_macro_expand_will_stop_2() {
2019 // FIXME: this test does succeed, but takes quite a while: 90 seconds in
2020 // the release mode. That's why the argument is not an ra_fixture --
2021 // otherwise injection highlighting gets stuck.
2022 //
2023 // We need to find a way to fail this faster.
2019 do_resolve( 2024 do_resolve(
2020 r#" 2025 r#"
2021 macro_rules! foo { 2026macro_rules! foo {
2022 ($($ty:ty)*) => { foo!($($ty)* $($ty)*); } 2027 ($($ty:ty)*) => { foo!($($ty)* $($ty)*); }
2023 } 2028}
2024 foo!(KABOOM); 2029foo!(KABOOM);
2025 "#, 2030"#,
2026 ); 2031 );
2027 } 2032 }
2028} 2033}
diff --git a/crates/hir_ty/src/tests/coercion.rs b/crates/hir_ty/src/tests/coercion.rs
index 71047703d..4f859fc85 100644
--- a/crates/hir_ty/src/tests/coercion.rs
+++ b/crates/hir_ty/src/tests/coercion.rs
@@ -741,10 +741,24 @@ fn coerce_unsize_trait_object_simple() {
741} 741}
742 742
743#[test] 743#[test]
744// The rust reference says this should be possible, but rustc doesn't implement
745// it. We used to support it, but Chalk doesn't.
746#[ignore]
747fn coerce_unsize_trait_object_to_trait_object() { 744fn coerce_unsize_trait_object_to_trait_object() {
745 // FIXME: The rust reference says this should be possible, but rustc doesn't
746 // implement it. We used to support it, but Chalk doesn't. Here's the
747 // correct expect:
748 //
749 // 424..609 '{ ...bj2; }': ()
750 // 434..437 'obj': &dyn Baz<i8, i16>
751 // 459..461 '&S': &S<i8, i16>
752 // 460..461 'S': S<i8, i16>
753 // 471..474 'obj': &dyn Bar<usize, i8, i16>
754 // 496..499 'obj': &dyn Baz<i8, i16>
755 // 509..512 'obj': &dyn Foo<i8, usize>
756 // 531..534 'obj': &dyn Bar<usize, i8, i16>
757 // 544..548 'obj2': &dyn Baz<i8, i16>
758 // 570..572 '&S': &S<i8, i16>
759 // 571..572 'S': S<i8, i16>
760 // 582..583 '_': &dyn Foo<i8, usize>
761 // 602..606 'obj2': &dyn Baz<i8, i16>
748 check_infer_with_mismatches( 762 check_infer_with_mismatches(
749 r#" 763 r#"
750 #[lang = "sized"] 764 #[lang = "sized"]
@@ -773,21 +787,24 @@ fn coerce_unsize_trait_object_to_trait_object() {
773 let _: &dyn Foo<_, _> = obj2; 787 let _: &dyn Foo<_, _> = obj2;
774 } 788 }
775 "#, 789 "#,
776 expect![[r" 790 expect![[r#"
777 424..609 '{ ...bj2; }': () 791 424..609 '{ ...bj2; }': ()
778 434..437 'obj': &dyn Baz<i8, i16> 792 434..437 'obj': &dyn Baz<i8, i16>
779 459..461 '&S': &S<i8, i16> 793 459..461 '&S': &S<i8, i16>
780 460..461 'S': S<i8, i16> 794 460..461 'S': S<i8, i16>
781 471..474 'obj': &dyn Bar<usize, i8, i16> 795 471..474 'obj': &dyn Bar<{unknown}, {unknown}, {unknown}>
782 496..499 'obj': &dyn Baz<i8, i16> 796 496..499 'obj': &dyn Baz<i8, i16>
783 509..512 'obj': &dyn Foo<i8, usize> 797 509..512 'obj': &dyn Foo<{unknown}, {unknown}>
784 531..534 'obj': &dyn Bar<usize, i8, i16> 798 531..534 'obj': &dyn Bar<{unknown}, {unknown}, {unknown}>
785 544..548 'obj2': &dyn Baz<i8, i16> 799 544..548 'obj2': &dyn Baz<i8, i16>
786 570..572 '&S': &S<i8, i16> 800 570..572 '&S': &S<i8, i16>
787 571..572 'S': S<i8, i16> 801 571..572 'S': S<i8, i16>
788 582..583 '_': &dyn Foo<i8, usize> 802 582..583 '_': &dyn Foo<{unknown}, {unknown}>
789 602..606 'obj2': &dyn Baz<i8, i16> 803 602..606 'obj2': &dyn Baz<i8, i16>
790 "]], 804 496..499: expected &dyn Bar<{unknown}, {unknown}, {unknown}>, got &dyn Baz<i8, i16>
805 531..534: expected &dyn Foo<{unknown}, {unknown}>, got &dyn Bar<{unknown}, {unknown}, {unknown}>
806 602..606: expected &dyn Foo<{unknown}, {unknown}>, got &dyn Baz<i8, i16>
807 "#]],
791 ); 808 );
792} 809}
793 810
diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs
index 6bcede4c4..c830e576e 100644
--- a/crates/hir_ty/src/tests/traits.rs
+++ b/crates/hir_ty/src/tests/traits.rs
@@ -1475,7 +1475,6 @@ fn test(
1475} 1475}
1476 1476
1477#[test] 1477#[test]
1478#[ignore]
1479fn error_bound_chalk() { 1478fn error_bound_chalk() {
1480 check_types( 1479 check_types(
1481 r#" 1480 r#"
diff --git a/crates/ide/src/doc_links.rs b/crates/ide/src/doc_links.rs
index 57ae9455b..7ac0118fe 100644
--- a/crates/ide/src/doc_links.rs
+++ b/crates/ide/src/doc_links.rs
@@ -241,6 +241,10 @@ fn get_doc_link(db: &RootDatabase, definition: Definition) -> Option<String> {
241 Definition::ModuleDef(ModuleDef::Module(module)) => module.krate(), 241 Definition::ModuleDef(ModuleDef::Module(module)) => module.krate(),
242 _ => definition.module(db)?.krate(), 242 _ => definition.module(db)?.krate(),
243 }; 243 };
244 // FIXME: using import map doesn't make sense here. What we want here is
245 // canonical path. What import map returns is the shortest path suitable for
246 // import. See this test:
247 cov_mark::hit!(test_reexport_order);
244 let import_map = db.import_map(krate.into()); 248 let import_map = db.import_map(krate.into());
245 249
246 let mut base = krate.display_name(db)?.to_string(); 250 let mut base = krate.display_name(db)?.to_string();
@@ -642,13 +646,15 @@ pub mod foo {
642 ) 646 )
643 } 647 }
644 648
645 // FIXME: ImportMap will return re-export paths instead of public module
646 // paths. The correct path to documentation will never be a re-export.
647 // This problem stops us from resolving stdlib items included in the prelude
648 // such as `Option::Some` correctly.
649 #[ignore = "ImportMap may return re-exports"]
650 #[test] 649 #[test]
651 fn test_reexport_order() { 650 fn test_reexport_order() {
651 cov_mark::check!(test_reexport_order);
652 // FIXME: This should return
653 //
654 // https://docs.rs/test/*/test/wrapper/modulestruct.Item.html
655 //
656 // That is, we should point inside the module, rather than at the
657 // re-export.
652 check( 658 check(
653 r#" 659 r#"
654pub mod wrapper { 660pub mod wrapper {
@@ -663,7 +669,7 @@ fn foo() {
663 let bar: wrapper::It$0em; 669 let bar: wrapper::It$0em;
664} 670}
665 "#, 671 "#,
666 expect![[r#"https://docs.rs/test/*/test/wrapper/module/struct.Item.html"#]], 672 expect![[r#"https://docs.rs/test/*/test/wrapper/struct.Item.html"#]],
667 ) 673 )
668 } 674 }
669} 675}
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs
index c08516805..afeded315 100644
--- a/crates/ide/src/hover.rs
+++ b/crates/ide/src/hover.rs
@@ -1821,9 +1821,10 @@ pub struct B$0ar
1821 ); 1821 );
1822 } 1822 }
1823 1823
1824 #[ignore = "path based links currently only support documentation on ModuleDef items"]
1825 #[test] 1824 #[test]
1826 fn test_hover_path_link_field() { 1825 fn test_hover_path_link_field() {
1826 // FIXME: Should be
1827 // [Foo](https://docs.rs/test/*/test/struct.Foo.html)
1827 check( 1828 check(
1828 r#" 1829 r#"
1829pub struct Foo; 1830pub struct Foo;
@@ -1845,7 +1846,7 @@ pub struct Bar {
1845 1846
1846 --- 1847 ---
1847 1848
1848 [Foo](https://docs.rs/test/*/test/struct.Foo.html) 1849 [Foo](struct.Foo.html)
1849 "#]], 1850 "#]],
1850 ); 1851 );
1851 } 1852 }
diff --git a/crates/ide_assists/src/handlers/fix_visibility.rs b/crates/ide_assists/src/handlers/fix_visibility.rs
index 9b432e92f..2f2b605fc 100644
--- a/crates/ide_assists/src/handlers/fix_visibility.rs
+++ b/crates/ide_assists/src/handlers/fix_visibility.rs
@@ -583,25 +583,25 @@ pub struct Foo { pub(crate) bar: () }
583 } 583 }
584 584
585 #[test] 585 #[test]
586 #[ignore]
587 // FIXME handle reexports properly
588 fn fix_visibility_of_reexport() { 586 fn fix_visibility_of_reexport() {
587 // FIXME: broken test, this should fix visibility of the re-export
588 // rather than the struct.
589 check_assist( 589 check_assist(
590 fix_visibility, 590 fix_visibility,
591 r" 591 r#"
592 mod foo { 592mod foo {
593 use bar::Baz; 593 use bar::Baz;
594 mod bar { pub(super) struct Baz; } 594 mod bar { pub(super) struct Baz; }
595 } 595}
596 foo::Baz$0 596foo::Baz$0
597 ", 597"#,
598 r" 598 r#"
599 mod foo { 599mod foo {
600 $0pub(crate) use bar::Baz; 600 use bar::Baz;
601 mod bar { pub(super) struct Baz; } 601 mod bar { $0pub(crate) struct Baz; }
602 } 602}
603 foo::Baz 603foo::Baz
604 ", 604"#,
605 ) 605 )
606 } 606 }
607} 607}
diff --git a/crates/ide_diagnostics/src/handlers/incorrect_case.rs b/crates/ide_diagnostics/src/handlers/incorrect_case.rs
index 72f251961..68f25f284 100644
--- a/crates/ide_diagnostics/src/handlers/incorrect_case.rs
+++ b/crates/ide_diagnostics/src/handlers/incorrect_case.rs
@@ -341,43 +341,27 @@ mod F {
341 } 341 }
342 342
343 #[test] 343 #[test]
344 #[ignore] 344 fn complex_ignore() {
345 fn bug_trait_inside_fn() { 345 // FIXME: this should trigger errors for the second case.
346 // FIXME:
347 // This is broken, and in fact, should not even be looked at by this
348 // lint in the first place. There's weird stuff going on in the
349 // collection phase.
350 // It's currently being brought in by:
351 // * validate_func on `a` recursing into modules
352 // * then it finds the trait and then the function while iterating
353 // through modules
354 // * then validate_func is called on Dirty
355 // * ... which then proceeds to look at some unknown module taking no
356 // attrs from either the impl or the fn a, and then finally to the root
357 // module
358 //
359 // It should find the attribute on the trait, but it *doesn't even see
360 // the trait* as far as I can tell.
361
362 check_diagnostics( 346 check_diagnostics(
363 r#" 347 r#"
364trait T { fn a(); } 348trait T { fn a(); }
365struct U {} 349struct U {}
366impl T for U { 350impl T for U {
367 fn a() { 351 fn a() {
368 // this comes out of bitflags, mostly
369 #[allow(non_snake_case)] 352 #[allow(non_snake_case)]
370 trait __BitFlags { 353 trait __BitFlagsOk {
371 const HiImAlsoBad: u8 = 2; 354 const HiImAlsoBad: u8 = 2;
372 #[inline] 355 fn Dirty(&self) -> bool { false }
373 fn Dirty(&self) -> bool {
374 false
375 }
376 } 356 }
377 357
358 trait __BitFlagsBad {
359 const HiImAlsoBad: u8 = 2;
360 fn Dirty(&self) -> bool { false }
361 }
378 } 362 }
379} 363}
380 "#, 364"#,
381 ); 365 );
382 } 366 }
383 367
@@ -414,18 +398,14 @@ extern {
414 } 398 }
415 399
416 #[test] 400 #[test]
417 #[ignore]
418 fn bug_traits_arent_checked() { 401 fn bug_traits_arent_checked() {
419 // FIXME: Traits and functions in traits aren't currently checked by 402 // FIXME: Traits and functions in traits aren't currently checked by
420 // r-a, even though rustc will complain about them. 403 // r-a, even though rustc will complain about them.
421 check_diagnostics( 404 check_diagnostics(
422 r#" 405 r#"
423trait BAD_TRAIT { 406trait BAD_TRAIT {
424 // ^^^^^^^^^ 💡 weak: Trait `BAD_TRAIT` should have CamelCase name, e.g. `BadTrait`
425 fn BAD_FUNCTION(); 407 fn BAD_FUNCTION();
426 // ^^^^^^^^^^^^ 💡 weak: Function `BAD_FUNCTION` should have snake_case name, e.g. `bad_function`
427 fn BadFunction(); 408 fn BadFunction();
428 // ^^^^^^^^^^^^ 💡 weak: Function `BadFunction` should have snake_case name, e.g. `bad_function`
429} 409}
430 "#, 410 "#,
431 ); 411 );
diff --git a/docs/dev/style.md b/docs/dev/style.md
index 96dd684b3..84485ea28 100644
--- a/docs/dev/style.md
+++ b/docs/dev/style.md
@@ -174,6 +174,13 @@ Instead, explicitly check for `None`, `Err`, etc.
174`rust-analyzer` is not a library, we don't need to test for API misuse, and we have to handle any user input without panics. 174`rust-analyzer` is not a library, we don't need to test for API misuse, and we have to handle any user input without panics.
175Panic messages in the logs from the `#[should_panic]` tests are confusing. 175Panic messages in the logs from the `#[should_panic]` tests are confusing.
176 176
177## `#[ignore]`
178
179Do not `#[ignore]` tests.
180If the test currently does not work, assert the wrong behavior and add a fixme explaining why it is wrong.
181
182**Rationale:** noticing when the behavior is fixed, making sure that even the wrong behavior is acceptable (ie, not a panic).
183
177## Function Preconditions 184## Function Preconditions
178 185
179Express function preconditions in types and force the caller to provide them (rather than checking in callee): 186Express function preconditions in types and force the caller to provide them (rather than checking in callee):