From 17542d08b4316afd899dabc6c7fc4c66f257dacb Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 2 Dec 2020 17:00:48 +0100 Subject: Update/Fix tests --- crates/hir_def/src/body/tests.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'crates/hir_def/src/body/tests.rs') diff --git a/crates/hir_def/src/body/tests.rs b/crates/hir_def/src/body/tests.rs index baf1179f1..f2b57aebe 100644 --- a/crates/hir_def/src/body/tests.rs +++ b/crates/hir_def/src/body/tests.rs @@ -78,21 +78,32 @@ fn f() { fn macro_diag_builtin() { check_diagnostics( r#" +#[rustc_builtin_macro] +macro_rules! env {} + +#[rustc_builtin_macro] +macro_rules! include {} + +#[rustc_builtin_macro] +macro_rules! format_args { + () => {} +} + fn f() { // Test a handful of built-in (eager) macros: include!(invalid); - //^^^^^^^^^^^^^^^^^ failed to parse or resolve macro invocation + //^^^^^^^^^^^^^^^^^ could not convert tokens include!("does not exist"); - //^^^^^^^^^^^^^^^^^^^^^^^^^^ failed to parse or resolve macro invocation + //^^^^^^^^^^^^^^^^^^^^^^^^^^ could not convert tokens env!(invalid); - //^^^^^^^^^^^^^ failed to parse or resolve macro invocation + //^^^^^^^^^^^^^ could not convert tokens // Lazy: format_args!(); - //^^^^^^^^^^^^^^ failed to parse or resolve macro invocation + //^^^^^^^^^^^^^^ no rule matches input tokens } "#, ); -- cgit v1.2.3 From 4634bfb332897f8478ed885970e7cb21bb9c4fce Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 2 Dec 2020 17:03:18 +0100 Subject: Give better diagnostic if `OUT_DIR` is unset --- crates/hir_def/src/body/tests.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'crates/hir_def/src/body/tests.rs') diff --git a/crates/hir_def/src/body/tests.rs b/crates/hir_def/src/body/tests.rs index f2b57aebe..c7003f2a6 100644 --- a/crates/hir_def/src/body/tests.rs +++ b/crates/hir_def/src/body/tests.rs @@ -100,6 +100,9 @@ fn f() { env!(invalid); //^^^^^^^^^^^^^ could not convert tokens + env!("OUT_DIR"); + //^^^^^^^^^^^^^^^ `OUT_DIR` not set, enable "load out dirs from check" to fix + // Lazy: format_args!(); -- cgit v1.2.3 From 883c8d177d61d34d70d4fccef788fe4b35aaa7ea Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 3 Dec 2020 15:31:04 +0100 Subject: Make `compile_error!` lazy and emit a diagnostic --- crates/hir_def/src/body/tests.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'crates/hir_def/src/body/tests.rs') diff --git a/crates/hir_def/src/body/tests.rs b/crates/hir_def/src/body/tests.rs index c7003f2a6..7e78340ee 100644 --- a/crates/hir_def/src/body/tests.rs +++ b/crates/hir_def/src/body/tests.rs @@ -84,6 +84,9 @@ macro_rules! env {} #[rustc_builtin_macro] macro_rules! include {} +#[rustc_builtin_macro] +macro_rules! compile_error {} + #[rustc_builtin_macro] macro_rules! format_args { () => {} @@ -103,6 +106,9 @@ fn f() { env!("OUT_DIR"); //^^^^^^^^^^^^^^^ `OUT_DIR` not set, enable "load out dirs from check" to fix + compile_error!("compile_error works"); + //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `compile_error!` called: compile_error works + // Lazy: format_args!(); -- cgit v1.2.3