aboutsummaryrefslogtreecommitdiff
path: root/crates/completion/src/lib.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-01-22 16:16:22 +0000
committerGitHub <[email protected]>2021-01-22 16:16:22 +0000
commite73cc8b4abed6e6f5d801d0032070fa9fc662ec3 (patch)
tree36ded65537cecddefb5ef91962e9770243d44f4b /crates/completion/src/lib.rs
parentb16add934d3cb4817ec0f20b8697a4d9701fce4e (diff)
parent96197e08730a74bb8d5c724968c99d22aa0ca17a (diff)
Merge #7396
7396: More annoying asserts r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/completion/src/lib.rs')
-rw-r--r--crates/completion/src/lib.rs91
1 files changed, 40 insertions, 51 deletions
diff --git a/crates/completion/src/lib.rs b/crates/completion/src/lib.rs
index 2c4e54524..db8bfbbc3 100644
--- a/crates/completion/src/lib.rs
+++ b/crates/completion/src/lib.rs
@@ -209,25 +209,24 @@ mod tests {
209 fn test_completion_detail_from_macro_generated_struct_fn_doc_attr() { 209 fn test_completion_detail_from_macro_generated_struct_fn_doc_attr() {
210 check_detail_and_documentation( 210 check_detail_and_documentation(
211 r#" 211 r#"
212 //- /lib.rs 212macro_rules! bar {
213 macro_rules! bar { 213 () => {
214 () => { 214 struct Bar;
215 struct Bar; 215 impl Bar {
216 impl Bar { 216 #[doc = "Do the foo"]
217 #[doc = "Do the foo"] 217 fn foo(&self) {}
218 fn foo(&self) {} 218 }
219 } 219 }
220 } 220}
221 }
222 221
223 bar!(); 222bar!();
224 223
225 fn foo() { 224fn foo() {
226 let bar = Bar; 225 let bar = Bar;
227 bar.fo$0; 226 bar.fo$0;
228 } 227}
229 "#, 228"#,
230 DetailAndDocumentation { detail: "fn foo(&self)", documentation: "Do the foo" }, 229 DetailAndDocumentation { detail: "-> ()", documentation: "Do the foo" },
231 ); 230 );
232 } 231 }
233 232
@@ -235,52 +234,42 @@ mod tests {
235 fn test_completion_detail_from_macro_generated_struct_fn_doc_comment() { 234 fn test_completion_detail_from_macro_generated_struct_fn_doc_comment() {
236 check_detail_and_documentation( 235 check_detail_and_documentation(
237 r#" 236 r#"
238 //- /lib.rs 237macro_rules! bar {
239 macro_rules! bar { 238 () => {
240 () => { 239 struct Bar;
241 struct Bar; 240 impl Bar {
242 impl Bar { 241 /// Do the foo
243 /// Do the foo 242 fn foo(&self) {}
244 fn foo(&self) {} 243 }
245 } 244 }
246 } 245}
247 }
248 246
249 bar!(); 247bar!();
250 248
251 fn foo() { 249fn foo() {
252 let bar = Bar; 250 let bar = Bar;
253 bar.fo$0; 251 bar.fo$0;
254 } 252}
255 "#, 253"#,
256 DetailAndDocumentation { detail: "fn foo(&self)", documentation: " Do the foo" }, 254 DetailAndDocumentation { detail: "-> ()", documentation: " Do the foo" },
257 ); 255 );
258 } 256 }
259 257
260 #[test] 258 #[test]
261 fn test_no_completions_required() { 259 fn test_no_completions_required() {
262 // There must be no hint for 'in' keyword. 260 // There must be no hint for 'in' keyword.
263 check_no_completion( 261 check_no_completion(r#"fn foo() { for i i$0 }"#);
264 r#"
265 fn foo() {
266 for i i$0
267 }
268 "#,
269 );
270 // After 'in' keyword hints may be spawned. 262 // After 'in' keyword hints may be spawned.
271 check_detail_and_documentation( 263 check_detail_and_documentation(
272 r#" 264 r#"
273 /// Do the foo 265/// Do the foo
274 fn foo() -> &'static str { "foo" } 266fn foo() -> &'static str { "foo" }
275 267
276 fn bar() { 268fn bar() {
277 for c in fo$0 269 for c in fo$0
278 } 270}
279 "#, 271"#,
280 DetailAndDocumentation { 272 DetailAndDocumentation { detail: "-> &str", documentation: "Do the foo" },
281 detail: "fn foo() -> &'static str",
282 documentation: "Do the foo",
283 },
284 ); 273 );
285 } 274 }
286} 275}