diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-12-02 14:03:57 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-12-02 14:03:57 +0000 |
commit | a3043cf53feffef3f69f25c2617801d2fc66ce75 (patch) | |
tree | d24e5b50266d80394153eaa9bd3b4dcbdd47120b /crates/hir_def/src | |
parent | 3e1fb112af3968110704125301646d6a3fc20c8c (diff) | |
parent | f4866bb05cca51b4c50ae8fdcd07dc71543d56c7 (diff) |
Merge #6699
6699: Test macro diagnostics in body lowering r=jonas-schievink a=jonas-schievink
bors r+
Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/hir_def/src')
-rw-r--r-- | crates/hir_def/src/body/tests.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/crates/hir_def/src/body/tests.rs b/crates/hir_def/src/body/tests.rs index f07df5cee..baf1179f1 100644 --- a/crates/hir_def/src/body/tests.rs +++ b/crates/hir_def/src/body/tests.rs | |||
@@ -73,3 +73,44 @@ fn f() { | |||
73 | ", | 73 | ", |
74 | ); | 74 | ); |
75 | } | 75 | } |
76 | |||
77 | #[test] | ||
78 | fn macro_diag_builtin() { | ||
79 | check_diagnostics( | ||
80 | r#" | ||
81 | fn f() { | ||
82 | // Test a handful of built-in (eager) macros: | ||
83 | |||
84 | include!(invalid); | ||
85 | //^^^^^^^^^^^^^^^^^ failed to parse or resolve macro invocation | ||
86 | include!("does not exist"); | ||
87 | //^^^^^^^^^^^^^^^^^^^^^^^^^^ failed to parse or resolve macro invocation | ||
88 | |||
89 | env!(invalid); | ||
90 | //^^^^^^^^^^^^^ failed to parse or resolve macro invocation | ||
91 | |||
92 | // Lazy: | ||
93 | |||
94 | format_args!(); | ||
95 | //^^^^^^^^^^^^^^ failed to parse or resolve macro invocation | ||
96 | } | ||
97 | "#, | ||
98 | ); | ||
99 | } | ||
100 | |||
101 | #[test] | ||
102 | fn macro_rules_diag() { | ||
103 | check_diagnostics( | ||
104 | r#" | ||
105 | macro_rules! m { | ||
106 | () => {}; | ||
107 | } | ||
108 | fn f() { | ||
109 | m!(); | ||
110 | |||
111 | m!(hi); | ||
112 | //^^^^^^ leftover tokens | ||
113 | } | ||
114 | "#, | ||
115 | ); | ||
116 | } | ||