diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-12-03 16:55:15 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-12-03 16:55:15 +0000 |
commit | d46fce88f5af1a97888edf91df2cb51ff5bfd61c (patch) | |
tree | 1f0351e895fa8b24ae4fa5a1854fb6c4285efcd2 /crates/hir_def/src/body | |
parent | 74de29b223c2e6f01d1ed0912d72787c202bb225 (diff) | |
parent | bca1e5fcb825c6c4e09ec197513b5568fce3d985 (diff) |
Merge #6700
6700: More macro diagnostics improvements r=jonas-schievink a=jonas-schievink
This threads macro expansion errors through `eager.rs` and the `AsMacroCall` trait, improving macro diagnostics emitted during body lowering.
Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/hir_def/src/body')
-rw-r--r-- | crates/hir_def/src/body/tests.rs | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/crates/hir_def/src/body/tests.rs b/crates/hir_def/src/body/tests.rs index baf1179f1..7e78340ee 100644 --- a/crates/hir_def/src/body/tests.rs +++ b/crates/hir_def/src/body/tests.rs | |||
@@ -78,21 +78,41 @@ fn f() { | |||
78 | fn macro_diag_builtin() { | 78 | fn macro_diag_builtin() { |
79 | check_diagnostics( | 79 | check_diagnostics( |
80 | r#" | 80 | r#" |
81 | #[rustc_builtin_macro] | ||
82 | macro_rules! env {} | ||
83 | |||
84 | #[rustc_builtin_macro] | ||
85 | macro_rules! include {} | ||
86 | |||
87 | #[rustc_builtin_macro] | ||
88 | macro_rules! compile_error {} | ||
89 | |||
90 | #[rustc_builtin_macro] | ||
91 | macro_rules! format_args { | ||
92 | () => {} | ||
93 | } | ||
94 | |||
81 | fn f() { | 95 | fn f() { |
82 | // Test a handful of built-in (eager) macros: | 96 | // Test a handful of built-in (eager) macros: |
83 | 97 | ||
84 | include!(invalid); | 98 | include!(invalid); |
85 | //^^^^^^^^^^^^^^^^^ failed to parse or resolve macro invocation | 99 | //^^^^^^^^^^^^^^^^^ could not convert tokens |
86 | include!("does not exist"); | 100 | include!("does not exist"); |
87 | //^^^^^^^^^^^^^^^^^^^^^^^^^^ failed to parse or resolve macro invocation | 101 | //^^^^^^^^^^^^^^^^^^^^^^^^^^ could not convert tokens |
88 | 102 | ||
89 | env!(invalid); | 103 | env!(invalid); |
90 | //^^^^^^^^^^^^^ failed to parse or resolve macro invocation | 104 | //^^^^^^^^^^^^^ could not convert tokens |
105 | |||
106 | env!("OUT_DIR"); | ||
107 | //^^^^^^^^^^^^^^^ `OUT_DIR` not set, enable "load out dirs from check" to fix | ||
108 | |||
109 | compile_error!("compile_error works"); | ||
110 | //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `compile_error!` called: compile_error works | ||
91 | 111 | ||
92 | // Lazy: | 112 | // Lazy: |
93 | 113 | ||
94 | format_args!(); | 114 | format_args!(); |
95 | //^^^^^^^^^^^^^^ failed to parse or resolve macro invocation | 115 | //^^^^^^^^^^^^^^ no rule matches input tokens |
96 | } | 116 | } |
97 | "#, | 117 | "#, |
98 | ); | 118 | ); |