From f85e383b94376d55bb5ee6be375ef3dc0006590f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 13 Jun 2021 17:29:25 +0300 Subject: internal: refactor inactive code diagnostics --- crates/hir_def/src/nameres/tests/diagnostics.rs | 42 ------------------------- 1 file changed, 42 deletions(-) (limited to 'crates/hir_def/src/nameres/tests') diff --git a/crates/hir_def/src/nameres/tests/diagnostics.rs b/crates/hir_def/src/nameres/tests/diagnostics.rs index 5a088b6e5..f1ee03d4d 100644 --- a/crates/hir_def/src/nameres/tests/diagnostics.rs +++ b/crates/hir_def/src/nameres/tests/diagnostics.rs @@ -12,48 +12,6 @@ fn check_no_diagnostics(ra_fixture: &str) { db.check_no_diagnostics(); } -#[test] -fn inactive_item() { - // Additional tests in `cfg` crate. This only tests disabled cfgs. - - check_diagnostics( - r#" - //- /lib.rs - #[cfg(no)] pub fn f() {} - //^^^^^^^^^^^^^^^^^^^^^^^^ UnconfiguredCode - - #[cfg(no)] #[cfg(no2)] mod m; - //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnconfiguredCode - - #[cfg(all(not(a), b))] enum E {} - //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnconfiguredCode - - #[cfg(feature = "std")] use std; - //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnconfiguredCode - "#, - ); -} - -/// Tests that `cfg` attributes behind `cfg_attr` is handled properly. -#[test] -fn inactive_via_cfg_attr() { - cov_mark::check!(cfg_attr_active); - check_diagnostics( - r#" - //- /lib.rs - #[cfg_attr(not(never), cfg(no))] fn f() {} - //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnconfiguredCode - - #[cfg_attr(not(never), cfg(not(no)))] fn f() {} - - #[cfg_attr(never, cfg(no))] fn g() {} - - #[cfg_attr(not(never), inline, cfg(no))] fn h() {} - //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnconfiguredCode - "#, - ); -} - #[test] fn builtin_macro_fails_expansion() { check_diagnostics( -- cgit v1.2.3 From 00303284b5cc3a82e32dc3ecbbcfeb2f99de6818 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 13 Jun 2021 18:41:04 +0300 Subject: internal: refactor macro error --- crates/hir_def/src/nameres/tests/diagnostics.rs | 76 ------------------------- 1 file changed, 76 deletions(-) delete mode 100644 crates/hir_def/src/nameres/tests/diagnostics.rs (limited to 'crates/hir_def/src/nameres/tests') 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 f1ee03d4d..000000000 --- a/crates/hir_def/src/nameres/tests/diagnostics.rs +++ /dev/null @@ -1,76 +0,0 @@ -use base_db::fixture::WithFixture; - -use crate::test_db::TestDB; - -fn check_diagnostics(ra_fixture: &str) { - let db: TestDB = TestDB::with_files(ra_fixture); - db.check_diagnostics(); -} - -fn check_no_diagnostics(ra_fixture: &str) { - let db: TestDB = TestDB::with_files(ra_fixture); - db.check_no_diagnostics(); -} - -#[test] -fn builtin_macro_fails_expansion() { - check_diagnostics( - r#" - //- /lib.rs - #[rustc_builtin_macro] - macro_rules! include { () => {} } - - include!("doesntexist"); - //^^^^^^^^^^^^^^^^^^^^^^^^ failed to load file `doesntexist` - "#, - ); -} - -#[test] -fn include_macro_should_allow_empty_content() { - check_no_diagnostics( - r#" - //- /lib.rs - #[rustc_builtin_macro] - macro_rules! include { () => {} } - - include!("bar.rs"); - //- /bar.rs - // empty - "#, - ); -} - -#[test] -fn good_out_dir_diagnostic() { - check_diagnostics( - r#" - #[rustc_builtin_macro] - macro_rules! include { () => {} } - #[rustc_builtin_macro] - macro_rules! env { () => {} } - #[rustc_builtin_macro] - macro_rules! concat { () => {} } - - include!(concat!(env!("OUT_DIR"), "/out.rs")); - //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `OUT_DIR` not set, enable "run build scripts" to fix - "#, - ); -} - -#[test] -fn register_attr_and_tool() { - cov_mark::check!(register_attr); - cov_mark::check!(register_tool); - check_no_diagnostics( - r#" -#![register_tool(tool)] -#![register_attr(attr)] - -#[tool::path] -#[attr] -struct S; - "#, - ); - // NB: we don't currently emit diagnostics here -} -- cgit v1.2.3