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/body/tests.rs | 33 --------------------------------- 1 file changed, 33 deletions(-) (limited to 'crates/hir_def/src/body') diff --git a/crates/hir_def/src/body/tests.rs b/crates/hir_def/src/body/tests.rs index d4fae05a6..075dcc6d2 100644 --- a/crates/hir_def/src/body/tests.rs +++ b/crates/hir_def/src/body/tests.rs @@ -88,39 +88,6 @@ mod m { ); } -#[test] -fn cfg_diagnostics() { - check_diagnostics( - r" -fn f() { - // The three g̶e̶n̶d̶e̶r̶s̶ statements: - - #[cfg(a)] fn f() {} // Item statement - //^^^^^^^^^^^^^^^^^^^ InactiveCode - #[cfg(a)] {} // Expression statement - //^^^^^^^^^^^^ InactiveCode - #[cfg(a)] let x = 0; // let statement - //^^^^^^^^^^^^^^^^^^^^ InactiveCode - - abc(#[cfg(a)] 0); - //^^^^^^^^^^^ InactiveCode - let x = Struct { - #[cfg(a)] f: 0, - //^^^^^^^^^^^^^^ InactiveCode - }; - match () { - () => (), - #[cfg(a)] () => (), - //^^^^^^^^^^^^^^^^^^ InactiveCode - } - - #[cfg(a)] 0 // Trailing expression of block - //^^^^^^^^^^^ InactiveCode -} - ", - ); -} - #[test] fn macro_diag_builtin() { 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/body/tests.rs | 88 ---------------------------------------- 1 file changed, 88 deletions(-) (limited to 'crates/hir_def/src/body') diff --git a/crates/hir_def/src/body/tests.rs b/crates/hir_def/src/body/tests.rs index 075dcc6d2..0dccabcfd 100644 --- a/crates/hir_def/src/body/tests.rs +++ b/crates/hir_def/src/body/tests.rs @@ -88,67 +88,6 @@ mod m { ); } -#[test] -fn macro_diag_builtin() { - check_diagnostics( - r#" -#[rustc_builtin_macro] -macro_rules! env {} - -#[rustc_builtin_macro] -macro_rules! include {} - -#[rustc_builtin_macro] -macro_rules! compile_error {} - -#[rustc_builtin_macro] -macro_rules! format_args { - () => {} -} - -fn f() { - // Test a handful of built-in (eager) macros: - - include!(invalid); - //^^^^^^^^^^^^^^^^^ could not convert tokens - include!("does not exist"); - //^^^^^^^^^^^^^^^^^^^^^^^^^^ failed to load file `does not exist` - - env!(invalid); - //^^^^^^^^^^^^^ could not convert tokens - - env!("OUT_DIR"); - //^^^^^^^^^^^^^^^ `OUT_DIR` not set, enable "run build scripts" to fix - - compile_error!("compile_error works"); - //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ compile_error works - - // Lazy: - - format_args!(); - //^^^^^^^^^^^^^^ no rule matches input tokens -} - "#, - ); -} - -#[test] -fn macro_rules_diag() { - check_diagnostics( - r#" -macro_rules! m { - () => {}; -} -fn f() { - m!(); - - m!(hi); - //^^^^^^ leftover tokens -} - "#, - ); -} - #[test] fn unresolved_macro_diag() { check_diagnostics( @@ -161,30 +100,3 @@ fn f() { ); } -#[test] -fn dollar_crate_in_builtin_macro() { - check_diagnostics( - r#" -#[macro_export] -#[rustc_builtin_macro] -macro_rules! format_args {} - -#[macro_export] -macro_rules! arg { - () => {} -} - -#[macro_export] -macro_rules! outer { - () => { - $crate::format_args!( "", $crate::arg!(1) ) - }; -} - -fn f() { - outer!(); - //^^^^^^^^ leftover tokens -} - "#, - ) -} -- cgit v1.2.3 From 4af7a35197a1cb159458694e69e17bd83dc9edff Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 13 Jun 2021 18:45:38 +0300 Subject: internal: remove def-level diagnostics tests --- crates/hir_def/src/body/tests.rs | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) (limited to 'crates/hir_def/src/body') diff --git a/crates/hir_def/src/body/tests.rs b/crates/hir_def/src/body/tests.rs index 0dccabcfd..27d837d47 100644 --- a/crates/hir_def/src/body/tests.rs +++ b/crates/hir_def/src/body/tests.rs @@ -3,7 +3,7 @@ mod block; use base_db::{fixture::WithFixture, SourceDatabase}; use expect_test::Expect; -use crate::{test_db::TestDB, ModuleDefId}; +use crate::ModuleDefId; use super::*; @@ -28,11 +28,6 @@ fn lower(ra_fixture: &str) -> Arc { db.body(fn_def.unwrap().into()) } -fn check_diagnostics(ra_fixture: &str) { - let db: TestDB = TestDB::with_files(ra_fixture); - db.check_diagnostics(); -} - fn block_def_map_at(ra_fixture: &str) -> String { let (db, position) = crate::test_db::TestDB::with_position(ra_fixture); @@ -57,7 +52,7 @@ fn check_at(ra_fixture: &str, expect: Expect) { fn your_stack_belongs_to_me() { cov_mark::check!(your_stack_belongs_to_me); lower( - " + r#" macro_rules! n_nuple { ($e:tt) => (); ($($rest:tt)*) => {{ @@ -65,7 +60,7 @@ macro_rules! n_nuple { }}; } fn main() { n_nuple!(1,2,3); } -", +"#, ); } @@ -73,7 +68,7 @@ fn main() { n_nuple!(1,2,3); } fn macro_resolve() { // Regression test for a path resolution bug introduced with inner item handling. lower( - r" + r#" macro_rules! vec { () => { () }; ($elem:expr; $n:expr) => { () }; @@ -84,19 +79,6 @@ mod m { let _ = vec![FileSet::default(); self.len()]; } } - ", +"#, ); } - -#[test] -fn unresolved_macro_diag() { - check_diagnostics( - r#" -fn f() { - m!(); - //^^^^ UnresolvedMacroCall -} - "#, - ); -} - -- cgit v1.2.3