diff options
author | Aleksey Kladov <[email protected]> | 2021-06-13 16:41:04 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-06-13 16:41:04 +0100 |
commit | 00303284b5cc3a82e32dc3ecbbcfeb2f99de6818 (patch) | |
tree | 685e3f21289eaeb25df597413528f25c6239813f /crates/hir_def/src/body/tests.rs | |
parent | 1e4aaee7bbc1d56698e70158aa35f578422623d9 (diff) |
internal: refactor macro error
Diffstat (limited to 'crates/hir_def/src/body/tests.rs')
-rw-r--r-- | crates/hir_def/src/body/tests.rs | 88 |
1 files changed, 0 insertions, 88 deletions
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 | |||
@@ -89,67 +89,6 @@ mod m { | |||
89 | } | 89 | } |
90 | 90 | ||
91 | #[test] | 91 | #[test] |
92 | fn macro_diag_builtin() { | ||
93 | check_diagnostics( | ||
94 | r#" | ||
95 | #[rustc_builtin_macro] | ||
96 | macro_rules! env {} | ||
97 | |||
98 | #[rustc_builtin_macro] | ||
99 | macro_rules! include {} | ||
100 | |||
101 | #[rustc_builtin_macro] | ||
102 | macro_rules! compile_error {} | ||
103 | |||
104 | #[rustc_builtin_macro] | ||
105 | macro_rules! format_args { | ||
106 | () => {} | ||
107 | } | ||
108 | |||
109 | fn f() { | ||
110 | // Test a handful of built-in (eager) macros: | ||
111 | |||
112 | include!(invalid); | ||
113 | //^^^^^^^^^^^^^^^^^ could not convert tokens | ||
114 | include!("does not exist"); | ||
115 | //^^^^^^^^^^^^^^^^^^^^^^^^^^ failed to load file `does not exist` | ||
116 | |||
117 | env!(invalid); | ||
118 | //^^^^^^^^^^^^^ could not convert tokens | ||
119 | |||
120 | env!("OUT_DIR"); | ||
121 | //^^^^^^^^^^^^^^^ `OUT_DIR` not set, enable "run build scripts" to fix | ||
122 | |||
123 | compile_error!("compile_error works"); | ||
124 | //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ compile_error works | ||
125 | |||
126 | // Lazy: | ||
127 | |||
128 | format_args!(); | ||
129 | //^^^^^^^^^^^^^^ no rule matches input tokens | ||
130 | } | ||
131 | "#, | ||
132 | ); | ||
133 | } | ||
134 | |||
135 | #[test] | ||
136 | fn macro_rules_diag() { | ||
137 | check_diagnostics( | ||
138 | r#" | ||
139 | macro_rules! m { | ||
140 | () => {}; | ||
141 | } | ||
142 | fn f() { | ||
143 | m!(); | ||
144 | |||
145 | m!(hi); | ||
146 | //^^^^^^ leftover tokens | ||
147 | } | ||
148 | "#, | ||
149 | ); | ||
150 | } | ||
151 | |||
152 | #[test] | ||
153 | fn unresolved_macro_diag() { | 92 | fn unresolved_macro_diag() { |
154 | check_diagnostics( | 93 | check_diagnostics( |
155 | r#" | 94 | r#" |
@@ -161,30 +100,3 @@ fn f() { | |||
161 | ); | 100 | ); |
162 | } | 101 | } |
163 | 102 | ||
164 | #[test] | ||
165 | fn dollar_crate_in_builtin_macro() { | ||
166 | check_diagnostics( | ||
167 | r#" | ||
168 | #[macro_export] | ||
169 | #[rustc_builtin_macro] | ||
170 | macro_rules! format_args {} | ||
171 | |||
172 | #[macro_export] | ||
173 | macro_rules! arg { | ||
174 | () => {} | ||
175 | } | ||
176 | |||
177 | #[macro_export] | ||
178 | macro_rules! outer { | ||
179 | () => { | ||
180 | $crate::format_args!( "", $crate::arg!(1) ) | ||
181 | }; | ||
182 | } | ||
183 | |||
184 | fn f() { | ||
185 | outer!(); | ||
186 | //^^^^^^^^ leftover tokens | ||
187 | } | ||
188 | "#, | ||
189 | ) | ||
190 | } | ||