aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/nameres/tests
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-06-13 16:46:09 +0100
committerGitHub <[email protected]>2021-06-13 16:46:09 +0100
commit7bff76d8ae1e8c3fbada1ade9ccf5111a1c0547e (patch)
tree1e85ed9c3fdf144469d9766c43c5362f5a31530b /crates/hir_def/src/nameres/tests
parent3d8df2aef87bca7ec3f0994d799462f08d1ad449 (diff)
parent4af7a35197a1cb159458694e69e17bd83dc9edff (diff)
Merge #9249
9249: internal: remove def-level diagnostics tests r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/hir_def/src/nameres/tests')
-rw-r--r--crates/hir_def/src/nameres/tests/diagnostics.rs118
1 files changed, 0 insertions, 118 deletions
diff --git a/crates/hir_def/src/nameres/tests/diagnostics.rs b/crates/hir_def/src/nameres/tests/diagnostics.rs
deleted file mode 100644
index 5a088b6e5..000000000
--- a/crates/hir_def/src/nameres/tests/diagnostics.rs
+++ /dev/null
@@ -1,118 +0,0 @@
1use base_db::fixture::WithFixture;
2
3use crate::test_db::TestDB;
4
5fn check_diagnostics(ra_fixture: &str) {
6 let db: TestDB = TestDB::with_files(ra_fixture);
7 db.check_diagnostics();
8}
9
10fn check_no_diagnostics(ra_fixture: &str) {
11 let db: TestDB = TestDB::with_files(ra_fixture);
12 db.check_no_diagnostics();
13}
14
15#[test]
16fn inactive_item() {
17 // Additional tests in `cfg` crate. This only tests disabled cfgs.
18
19 check_diagnostics(
20 r#"
21 //- /lib.rs
22 #[cfg(no)] pub fn f() {}
23 //^^^^^^^^^^^^^^^^^^^^^^^^ UnconfiguredCode
24
25 #[cfg(no)] #[cfg(no2)] mod m;
26 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnconfiguredCode
27
28 #[cfg(all(not(a), b))] enum E {}
29 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnconfiguredCode
30
31 #[cfg(feature = "std")] use std;
32 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnconfiguredCode
33 "#,
34 );
35}
36
37/// Tests that `cfg` attributes behind `cfg_attr` is handled properly.
38#[test]
39fn inactive_via_cfg_attr() {
40 cov_mark::check!(cfg_attr_active);
41 check_diagnostics(
42 r#"
43 //- /lib.rs
44 #[cfg_attr(not(never), cfg(no))] fn f() {}
45 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnconfiguredCode
46
47 #[cfg_attr(not(never), cfg(not(no)))] fn f() {}
48
49 #[cfg_attr(never, cfg(no))] fn g() {}
50
51 #[cfg_attr(not(never), inline, cfg(no))] fn h() {}
52 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnconfiguredCode
53 "#,
54 );
55}
56
57#[test]
58fn builtin_macro_fails_expansion() {
59 check_diagnostics(
60 r#"
61 //- /lib.rs
62 #[rustc_builtin_macro]
63 macro_rules! include { () => {} }
64
65 include!("doesntexist");
66 //^^^^^^^^^^^^^^^^^^^^^^^^ failed to load file `doesntexist`
67 "#,
68 );
69}
70
71#[test]
72fn include_macro_should_allow_empty_content() {
73 check_no_diagnostics(
74 r#"
75 //- /lib.rs
76 #[rustc_builtin_macro]
77 macro_rules! include { () => {} }
78
79 include!("bar.rs");
80 //- /bar.rs
81 // empty
82 "#,
83 );
84}
85
86#[test]
87fn good_out_dir_diagnostic() {
88 check_diagnostics(
89 r#"
90 #[rustc_builtin_macro]
91 macro_rules! include { () => {} }
92 #[rustc_builtin_macro]
93 macro_rules! env { () => {} }
94 #[rustc_builtin_macro]
95 macro_rules! concat { () => {} }
96
97 include!(concat!(env!("OUT_DIR"), "/out.rs"));
98 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `OUT_DIR` not set, enable "run build scripts" to fix
99 "#,
100 );
101}
102
103#[test]
104fn register_attr_and_tool() {
105 cov_mark::check!(register_attr);
106 cov_mark::check!(register_tool);
107 check_no_diagnostics(
108 r#"
109#![register_tool(tool)]
110#![register_attr(attr)]
111
112#[tool::path]
113#[attr]
114struct S;
115 "#,
116 );
117 // NB: we don't currently emit diagnostics here
118}