aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/completion/src/completions/dot.rs22
-rw-r--r--crates/completion/src/completions/flyimport.rs16
-rw-r--r--crates/completion/src/completions/qualified_path.rs54
-rw-r--r--crates/completion/src/completions/trait_impl.rs5
-rw-r--r--crates/completion/src/completions/unqualified_path.rs50
-rw-r--r--crates/completion/src/item.rs3
-rw-r--r--crates/completion/src/lib.rs91
-rw-r--r--crates/completion/src/render.rs12
-rw-r--r--crates/completion/src/render/function.rs7
-rw-r--r--crates/rust-analyzer/src/bin/main.rs7
10 files changed, 128 insertions, 139 deletions
diff --git a/crates/completion/src/completions/dot.rs b/crates/completion/src/completions/dot.rs
index d04eef65a..0880a3830 100644
--- a/crates/completion/src/completions/dot.rs
+++ b/crates/completion/src/completions/dot.rs
@@ -83,7 +83,7 @@ fn foo(s: S) { s.$0 }
83"#, 83"#,
84 expect![[r#" 84 expect![[r#"
85 fd foo u32 85 fd foo u32
86 me bar() fn bar(&self) 86 me bar() -> ()
87 "#]], 87 "#]],
88 ); 88 );
89 } 89 }
@@ -99,7 +99,7 @@ impl S {
99"#, 99"#,
100 expect![[r#" 100 expect![[r#"
101 fd the_field (u32,) 101 fd the_field (u32,)
102 me foo() fn foo(self) 102 me foo() -> ()
103 "#]], 103 "#]],
104 ) 104 )
105 } 105 }
@@ -115,7 +115,7 @@ impl A {
115"#, 115"#,
116 expect![[r#" 116 expect![[r#"
117 fd the_field (u32, i32) 117 fd the_field (u32, i32)
118 me foo() fn foo(&self) 118 me foo() -> ()
119 "#]], 119 "#]],
120 ) 120 )
121 } 121 }
@@ -165,7 +165,7 @@ mod m {
165fn foo(a: A) { a.$0 } 165fn foo(a: A) { a.$0 }
166"#, 166"#,
167 expect![[r#" 167 expect![[r#"
168 me the_method() pub(crate) fn the_method(&self) 168 me the_method() -> ()
169 "#]], 169 "#]],
170 ); 170 );
171 } 171 }
@@ -198,7 +198,7 @@ impl A<i32> {
198fn foo(a: A<u32>) { a.$0 } 198fn foo(a: A<u32>) { a.$0 }
199"#, 199"#,
200 expect![[r#" 200 expect![[r#"
201 me the_method() fn the_method(&self) 201 me the_method() -> ()
202 "#]], 202 "#]],
203 ) 203 )
204 } 204 }
@@ -213,7 +213,7 @@ impl Trait for A {}
213fn foo(a: A) { a.$0 } 213fn foo(a: A) { a.$0 }
214"#, 214"#,
215 expect![[r#" 215 expect![[r#"
216 me the_method() fn the_method(&self) 216 me the_method() -> ()
217 "#]], 217 "#]],
218 ); 218 );
219 } 219 }
@@ -228,7 +228,7 @@ impl<T> Trait for T {}
228fn foo(a: &A) { a.$0 } 228fn foo(a: &A) { a.$0 }
229", 229",
230 expect![[r#" 230 expect![[r#"
231 me the_method() fn the_method(&self) 231 me the_method() -> ()
232 "#]], 232 "#]],
233 ); 233 );
234 } 234 }
@@ -246,7 +246,7 @@ impl Trait for A {}
246fn foo(a: A) { a.$0 } 246fn foo(a: A) { a.$0 }
247", 247",
248 expect![[r#" 248 expect![[r#"
249 me the_method() fn the_method(&self) 249 me the_method() -> ()
250 "#]], 250 "#]],
251 ); 251 );
252 } 252 }
@@ -300,7 +300,7 @@ impl T {
300} 300}
301"#, 301"#,
302 expect![[r#" 302 expect![[r#"
303 me blah() pub fn blah(&self) 303 me blah() -> ()
304 "#]], 304 "#]],
305 ); 305 );
306 } 306 }
@@ -409,7 +409,7 @@ fn foo() {
409} 409}
410"#, 410"#,
411 expect![[r#" 411 expect![[r#"
412 me the_method() pub fn the_method(&self) 412 me the_method() -> ()
413 "#]], 413 "#]],
414 ); 414 );
415 } 415 }
@@ -424,7 +424,7 @@ macro_rules! make_s { () => { S }; }
424fn main() { make_s!().f$0; } 424fn main() { make_s!().f$0; }
425"#, 425"#,
426 expect![[r#" 426 expect![[r#"
427 me foo() fn foo(&self) 427 me foo() -> ()
428 "#]], 428 "#]],
429 ) 429 )
430 } 430 }
diff --git a/crates/completion/src/completions/flyimport.rs b/crates/completion/src/completions/flyimport.rs
index dc0b38a16..6591127b1 100644
--- a/crates/completion/src/completions/flyimport.rs
+++ b/crates/completion/src/completions/flyimport.rs
@@ -366,8 +366,8 @@ fn main() {
366 check( 366 check(
367 fixture, 367 fixture,
368 expect![[r#" 368 expect![[r#"
369 fn weird_function() (dep::test_mod::TestTrait) fn weird_function() 369 fn weird_function() (dep::test_mod::TestTrait) -> ()
370 "#]], 370 "#]],
371 ); 371 );
372 372
373 check_edit( 373 check_edit(
@@ -459,8 +459,8 @@ fn main() {
459 check( 459 check(
460 fixture, 460 fixture,
461 expect![[r#" 461 expect![[r#"
462 me random_method() (dep::test_mod::TestTrait) fn random_method(&self) 462 me random_method() (dep::test_mod::TestTrait) -> ()
463 "#]], 463 "#]],
464 ); 464 );
465 465
466 check_edit( 466 check_edit(
@@ -629,8 +629,8 @@ fn main() {
629} 629}
630 "#, 630 "#,
631 expect![[r#" 631 expect![[r#"
632 me random_method() (dep::test_mod::TestTrait) fn random_method(&self) DEPRECATED 632 me random_method() (dep::test_mod::TestTrait) -> () DEPRECATED
633 "#]], 633 "#]],
634 ); 634 );
635 635
636 check( 636 check(
@@ -660,8 +660,8 @@ fn main() {
660"#, 660"#,
661 expect![[r#" 661 expect![[r#"
662 ct SPECIAL_CONST (dep::test_mod::TestTrait) DEPRECATED 662 ct SPECIAL_CONST (dep::test_mod::TestTrait) DEPRECATED
663 fn weird_function() (dep::test_mod::TestTrait) fn weird_function() DEPRECATED 663 fn weird_function() (dep::test_mod::TestTrait) -> () DEPRECATED
664 "#]], 664 "#]],
665 ); 665 );
666 } 666 }
667} 667}
diff --git a/crates/completion/src/completions/qualified_path.rs b/crates/completion/src/completions/qualified_path.rs
index 33df26761..bbeaab496 100644
--- a/crates/completion/src/completions/qualified_path.rs
+++ b/crates/completion/src/completions/qualified_path.rs
@@ -359,8 +359,8 @@ impl S {
359fn foo() { let _ = S::$0 } 359fn foo() { let _ = S::$0 }
360"#, 360"#,
361 expect![[r#" 361 expect![[r#"
362 fn a() fn a() 362 fn a() -> ()
363 me b(…) fn b(&self) 363 me b(…) -> ()
364 ct C const C: i32 = 42; 364 ct C const C: i32 = 42;
365 ta T type T = i32; 365 ta T type T = i32;
366 "#]], 366 "#]],
@@ -387,7 +387,7 @@ mod m {
387fn foo() { let _ = S::$0 } 387fn foo() { let _ = S::$0 }
388"#, 388"#,
389 expect![[r#" 389 expect![[r#"
390 fn public_method() pub(crate) fn public_method() 390 fn public_method() -> ()
391 ct PUBLIC_CONST pub(crate) const PUBLIC_CONST: u32 = 1; 391 ct PUBLIC_CONST pub(crate) const PUBLIC_CONST: u32 = 1;
392 ta PublicType pub(crate) type PublicType = u32; 392 ta PublicType pub(crate) type PublicType = u32;
393 "#]], 393 "#]],
@@ -404,7 +404,7 @@ impl E { fn m() { } }
404fn foo() { let _ = E::$0 } 404fn foo() { let _ = E::$0 }
405 "#, 405 "#,
406 expect![[r#" 406 expect![[r#"
407 fn m() fn m() 407 fn m() -> ()
408 "#]], 408 "#]],
409 ); 409 );
410 } 410 }
@@ -419,7 +419,7 @@ impl U { fn m() { } }
419fn foo() { let _ = U::$0 } 419fn foo() { let _ = U::$0 }
420"#, 420"#,
421 expect![[r#" 421 expect![[r#"
422 fn m() fn m() 422 fn m() -> ()
423 "#]], 423 "#]],
424 ); 424 );
425 } 425 }
@@ -449,7 +449,7 @@ trait Trait { fn m(); }
449fn foo() { let _ = Trait::$0 } 449fn foo() { let _ = Trait::$0 }
450"#, 450"#,
451 expect![[r#" 451 expect![[r#"
452 fn m() fn m() 452 fn m() -> ()
453 "#]], 453 "#]],
454 ); 454 );
455 } 455 }
@@ -466,7 +466,7 @@ impl Trait for S {}
466fn foo() { let _ = S::$0 } 466fn foo() { let _ = S::$0 }
467"#, 467"#,
468 expect![[r#" 468 expect![[r#"
469 fn m() fn m() 469 fn m() -> ()
470 "#]], 470 "#]],
471 ); 471 );
472 } 472 }
@@ -483,7 +483,7 @@ impl Trait for S {}
483fn foo() { let _ = <S as Trait>::$0 } 483fn foo() { let _ = <S as Trait>::$0 }
484"#, 484"#,
485 expect![[r#" 485 expect![[r#"
486 fn m() fn m() 486 fn m() -> ()
487 "#]], 487 "#]],
488 ); 488 );
489 } 489 }
@@ -512,11 +512,11 @@ fn foo<T: Sub>() { T::$0 }
512 ta SubTy type SubTy; 512 ta SubTy type SubTy;
513 ta Ty type Ty; 513 ta Ty type Ty;
514 ct C2 const C2: (); 514 ct C2 const C2: ();
515 fn subfunc() fn subfunc() 515 fn subfunc() -> ()
516 me submethod(…) fn submethod(&self) 516 me submethod(…) -> ()
517 ct CONST const CONST: u8; 517 ct CONST const CONST: u8;
518 fn func() fn func() 518 fn func() -> ()
519 me method(…) fn method(&self) 519 me method(…) -> ()
520 "#]], 520 "#]],
521 ); 521 );
522 } 522 }
@@ -552,11 +552,11 @@ impl<T> Sub for Wrap<T> {
552 ta SubTy type SubTy; 552 ta SubTy type SubTy;
553 ta Ty type Ty; 553 ta Ty type Ty;
554 ct CONST const CONST: u8 = 0; 554 ct CONST const CONST: u8 = 0;
555 fn func() fn func() 555 fn func() -> ()
556 me method(…) fn method(&self) 556 me method(…) -> ()
557 ct C2 const C2: () = (); 557 ct C2 const C2: () = ();
558 fn subfunc() fn subfunc() 558 fn subfunc() -> ()
559 me submethod(…) fn submethod(&self) 559 me submethod(…) -> ()
560 "#]], 560 "#]],
561 ); 561 );
562 } 562 }
@@ -573,8 +573,8 @@ impl T { fn bar() {} }
573fn main() { T::$0; } 573fn main() { T::$0; }
574"#, 574"#,
575 expect![[r#" 575 expect![[r#"
576 fn foo() fn foo() 576 fn foo() -> ()
577 fn bar() fn bar() 577 fn bar() -> ()
578 "#]], 578 "#]],
579 ); 579 );
580 } 580 }
@@ -589,7 +589,7 @@ macro_rules! foo { () => {} }
589fn main() { let _ = crate::$0 } 589fn main() { let _ = crate::$0 }
590 "#, 590 "#,
591 expect![[r##" 591 expect![[r##"
592 fn main() fn main() 592 fn main() -> ()
593 ma foo!(…) #[macro_export] macro_rules! foo 593 ma foo!(…) #[macro_export] macro_rules! foo
594 "##]], 594 "##]],
595 ); 595 );
@@ -633,7 +633,7 @@ mod p {
633"#, 633"#,
634 expect![[r#" 634 expect![[r#"
635 ct RIGHT_CONST 635 ct RIGHT_CONST
636 fn right_fn() fn wrong_fn() 636 fn right_fn() -> ()
637 st RightType 637 st RightType
638 "#]], 638 "#]],
639 ); 639 );
@@ -680,8 +680,8 @@ fn main() { m!(self::f$0); }
680fn foo() {} 680fn foo() {}
681"#, 681"#,
682 expect![[r#" 682 expect![[r#"
683 fn main() fn main() 683 fn main() -> ()
684 fn foo() fn foo() 684 fn foo() -> ()
685 "#]], 685 "#]],
686 ); 686 );
687 } 687 }
@@ -699,7 +699,7 @@ mod m {
699"#, 699"#,
700 expect![[r#" 700 expect![[r#"
701 md z 701 md z
702 fn z() pub fn z() 702 fn z() -> ()
703 "#]], 703 "#]],
704 ); 704 );
705 } 705 }
@@ -719,7 +719,7 @@ fn foo() {
719} 719}
720"#, 720"#,
721 expect![[r#" 721 expect![[r#"
722 fn new() pub fn new() -> HashMap<K, V, RandomState> 722 fn new() -> HashMap<K, V, RandomState>
723 "#]], 723 "#]],
724 ); 724 );
725 } 725 }
@@ -752,8 +752,8 @@ fn main() {
752} 752}
753"#, 753"#,
754 expect![[r#" 754 expect![[r#"
755 fn main() fn main() 755 fn main() -> ()
756 fn foo(…) fn foo(a: i32, b: i32) 756 fn foo(…) -> ()
757 "#]], 757 "#]],
758 ); 758 );
759 } 759 }
@@ -776,7 +776,7 @@ impl Foo {
776 expect![[r#" 776 expect![[r#"
777 ev Bar () 777 ev Bar ()
778 ev Baz () 778 ev Baz ()
779 me foo(…) fn foo(self) 779 me foo(…) -> ()
780 "#]], 780 "#]],
781 ); 781 );
782 } 782 }
diff --git a/crates/completion/src/completions/trait_impl.rs b/crates/completion/src/completions/trait_impl.rs
index f258ad9c3..b999540b8 100644
--- a/crates/completion/src/completions/trait_impl.rs
+++ b/crates/completion/src/completions/trait_impl.rs
@@ -679,11 +679,6 @@ impl Test for () {
679 #[test] 679 #[test]
680 fn complete_without_name() { 680 fn complete_without_name() {
681 let test = |completion: &str, hint: &str, completed: &str, next_sibling: &str| { 681 let test = |completion: &str, hint: &str, completed: &str, next_sibling: &str| {
682 println!(
683 "completion='{}', hint='{}', next_sibling='{}'",
684 completion, hint, next_sibling
685 );
686
687 check_edit( 682 check_edit(
688 completion, 683 completion,
689 &format!( 684 &format!(
diff --git a/crates/completion/src/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs
index a289efc34..5d62fab97 100644
--- a/crates/completion/src/completions/unqualified_path.rs
+++ b/crates/completion/src/completions/unqualified_path.rs
@@ -167,7 +167,7 @@ fn quux(x: i32) {
167 expect![[r#" 167 expect![[r#"
168 lc y i32 168 lc y i32
169 lc x i32 169 lc x i32
170 fn quux(…) fn quux(x: i32) 170 fn quux(…) -> ()
171 "#]], 171 "#]],
172 ); 172 );
173 } 173 }
@@ -189,7 +189,7 @@ fn quux() {
189 expect![[r#" 189 expect![[r#"
190 lc b i32 190 lc b i32
191 lc a 191 lc a
192 fn quux() fn quux() 192 fn quux() -> ()
193 "#]], 193 "#]],
194 ); 194 );
195 } 195 }
@@ -204,7 +204,7 @@ fn quux() {
204"#, 204"#,
205 expect![[r#" 205 expect![[r#"
206 lc x 206 lc x
207 fn quux() fn quux() 207 fn quux() -> ()
208 "#]], 208 "#]],
209 ); 209 );
210 } 210 }
@@ -235,14 +235,14 @@ fn main() {
235 r#"fn quux<T>() { $0 }"#, 235 r#"fn quux<T>() { $0 }"#,
236 expect![[r#" 236 expect![[r#"
237 tp T 237 tp T
238 fn quux() fn quux<T>() 238 fn quux() -> ()
239 "#]], 239 "#]],
240 ); 240 );
241 check( 241 check(
242 r#"fn quux<const C: usize>() { $0 }"#, 242 r#"fn quux<const C: usize>() { $0 }"#,
243 expect![[r#" 243 expect![[r#"
244 cp C 244 cp C
245 fn quux() fn quux<const C: usize>() 245 fn quux() -> ()
246 "#]], 246 "#]],
247 ); 247 );
248 } 248 }
@@ -253,7 +253,7 @@ fn main() {
253 check( 253 check(
254 r#"fn quux<'a>() { $0 }"#, 254 r#"fn quux<'a>() { $0 }"#,
255 expect![[r#" 255 expect![[r#"
256 fn quux() fn quux<'a>() 256 fn quux() -> ()
257 "#]], 257 "#]],
258 ); 258 );
259 } 259 }
@@ -291,7 +291,7 @@ fn quux() { $0 }
291"#, 291"#,
292 expect![[r#" 292 expect![[r#"
293 st S 293 st S
294 fn quux() fn quux() 294 fn quux() -> ()
295 en E 295 en E
296 "#]], 296 "#]],
297 ); 297 );
@@ -344,7 +344,7 @@ mod m {
344} 344}
345"#, 345"#,
346 expect![[r#" 346 expect![[r#"
347 fn quux() fn quux() 347 fn quux() -> ()
348 st Bar 348 st Bar
349 "#]], 349 "#]],
350 ); 350 );
@@ -359,7 +359,7 @@ fn x() -> $0
359"#, 359"#,
360 expect![[r#" 360 expect![[r#"
361 st Foo 361 st Foo
362 fn x() fn x() 362 fn x() -> ()
363 "#]], 363 "#]],
364 ); 364 );
365 } 365 }
@@ -380,7 +380,7 @@ fn foo() {
380 expect![[r#" 380 expect![[r#"
381 lc bar i32 381 lc bar i32
382 lc bar i32 382 lc bar i32
383 fn foo() fn foo() 383 fn foo() -> ()
384 "#]], 384 "#]],
385 ); 385 );
386 } 386 }
@@ -410,7 +410,7 @@ use prelude::*;
410mod prelude { struct Option; } 410mod prelude { struct Option; }
411"#, 411"#,
412 expect![[r#" 412 expect![[r#"
413 fn foo() fn foo() 413 fn foo() -> ()
414 md std 414 md std
415 st Option 415 st Option
416 "#]], 416 "#]],
@@ -440,7 +440,7 @@ mod macros {
440} 440}
441"#, 441"#,
442 expect![[r##" 442 expect![[r##"
443 fn f() fn f() 443 fn f() -> ()
444 ma concat!(…) #[macro_export] macro_rules! concat 444 ma concat!(…) #[macro_export] macro_rules! concat
445 md std 445 md std
446 "##]], 446 "##]],
@@ -467,7 +467,7 @@ use prelude::*;
467mod prelude { struct String; } 467mod prelude { struct String; }
468"#, 468"#,
469 expect![[r#" 469 expect![[r#"
470 fn foo() fn foo() 470 fn foo() -> ()
471 md std 471 md std
472 md core 472 md core
473 st String 473 st String
@@ -498,7 +498,7 @@ fn main() { let v = $0 }
498 expect![[r##" 498 expect![[r##"
499 md m1 499 md m1
500 ma baz!(…) #[macro_export] macro_rules! baz 500 ma baz!(…) #[macro_export] macro_rules! baz
501 fn main() fn main() 501 fn main() -> ()
502 md m2 502 md m2
503 ma bar!(…) macro_rules! bar 503 ma bar!(…) macro_rules! bar
504 ma foo!(…) macro_rules! foo 504 ma foo!(…) macro_rules! foo
@@ -514,7 +514,7 @@ macro_rules! foo { () => {} }
514fn foo() { $0 } 514fn foo() { $0 }
515"#, 515"#,
516 expect![[r#" 516 expect![[r#"
517 fn foo() fn foo() 517 fn foo() -> ()
518 ma foo!(…) macro_rules! foo 518 ma foo!(…) macro_rules! foo
519 "#]], 519 "#]],
520 ); 520 );
@@ -528,7 +528,7 @@ macro_rules! foo { () => {} }
528fn main() { let x: $0 } 528fn main() { let x: $0 }
529"#, 529"#,
530 expect![[r#" 530 expect![[r#"
531 fn main() fn main() 531 fn main() -> ()
532 ma foo!(…) macro_rules! foo 532 ma foo!(…) macro_rules! foo
533 "#]], 533 "#]],
534 ); 534 );
@@ -542,7 +542,7 @@ macro_rules! foo { () => {} }
542fn main() { $0 } 542fn main() { $0 }
543"#, 543"#,
544 expect![[r#" 544 expect![[r#"
545 fn main() fn main() 545 fn main() -> ()
546 ma foo!(…) macro_rules! foo 546 ma foo!(…) macro_rules! foo
547 "#]], 547 "#]],
548 ); 548 );
@@ -558,8 +558,8 @@ fn main() {
558} 558}
559"#, 559"#,
560 expect![[r#" 560 expect![[r#"
561 fn frobnicate() fn frobnicate() 561 fn frobnicate() -> ()
562 fn main() fn main() 562 fn main() -> ()
563 "#]], 563 "#]],
564 ); 564 );
565 } 565 }
@@ -577,7 +577,7 @@ fn quux(x: i32) {
577 expect![[r#" 577 expect![[r#"
578 lc y i32 578 lc y i32
579 lc x i32 579 lc x i32
580 fn quux(…) fn quux(x: i32) 580 fn quux(…) -> ()
581 ma m!(…) macro_rules! m 581 ma m!(…) macro_rules! m
582 "#]], 582 "#]],
583 ); 583 );
@@ -596,7 +596,7 @@ fn quux(x: i32) {
596 expect![[r#" 596 expect![[r#"
597 lc y i32 597 lc y i32
598 lc x i32 598 lc x i32
599 fn quux(…) fn quux(x: i32) 599 fn quux(…) -> ()
600 ma m!(…) macro_rules! m 600 ma m!(…) macro_rules! m
601 "#]], 601 "#]],
602 ); 602 );
@@ -615,7 +615,7 @@ fn quux(x: i32) {
615 expect![[r#" 615 expect![[r#"
616 lc y i32 616 lc y i32
617 lc x i32 617 lc x i32
618 fn quux(…) fn quux(x: i32) 618 fn quux(…) -> ()
619 ma m!(…) macro_rules! m 619 ma m!(…) macro_rules! m
620 "#]], 620 "#]],
621 ); 621 );
@@ -630,7 +630,7 @@ use spam::Quux;
630fn main() { $0 } 630fn main() { $0 }
631"#, 631"#,
632 expect![[r#" 632 expect![[r#"
633 fn main() fn main() 633 fn main() -> ()
634 ?? Quux 634 ?? Quux
635 "#]], 635 "#]],
636 ); 636 );
@@ -708,7 +708,7 @@ fn main() { let foo: Foo = Q$0 }
708 ev Foo::Baz () 708 ev Foo::Baz ()
709 ev Foo::Quux () 709 ev Foo::Quux ()
710 en Foo 710 en Foo
711 fn main() fn main() 711 fn main() -> ()
712 "#]], 712 "#]],
713 ) 713 )
714 } 714 }
@@ -723,7 +723,7 @@ fn f() -> m::E { V$0 }
723 expect![[r#" 723 expect![[r#"
724 ev m::E::V () 724 ev m::E::V ()
725 md m 725 md m
726 fn f() fn f() -> m::E 726 fn f() -> E
727 "#]], 727 "#]],
728 ) 728 )
729 } 729 }
diff --git a/crates/completion/src/item.rs b/crates/completion/src/item.rs
index d2e6a6aeb..eeb952ec3 100644
--- a/crates/completion/src/item.rs
+++ b/crates/completion/src/item.rs
@@ -398,14 +398,13 @@ impl Builder {
398 self.insert_text_format = InsertTextFormat::Snippet; 398 self.insert_text_format = InsertTextFormat::Snippet;
399 self.text_edit(edit) 399 self.text_edit(edit)
400 } 400 }
401 #[allow(unused)]
402 pub(crate) fn detail(self, detail: impl Into<String>) -> Builder { 401 pub(crate) fn detail(self, detail: impl Into<String>) -> Builder {
403 self.set_detail(Some(detail)) 402 self.set_detail(Some(detail))
404 } 403 }
405 pub(crate) fn set_detail(mut self, detail: Option<impl Into<String>>) -> Builder { 404 pub(crate) fn set_detail(mut self, detail: Option<impl Into<String>>) -> Builder {
406 self.detail = detail.map(Into::into); 405 self.detail = detail.map(Into::into);
407 if let Some(detail) = &self.detail { 406 if let Some(detail) = &self.detail {
408 if assert_never!(detail.contains('\n'), "multiline detail: {}", detail) { 407 if assert_never!(detail.contains('\n'), "multiline detail:\n{}", detail) {
409 self.detail = Some(detail.splitn(2, '\n').next().unwrap().to_string()); 408 self.detail = Some(detail.splitn(2, '\n').next().unwrap().to_string());
410 } 409 }
411 } 410 }
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}
diff --git a/crates/completion/src/render.rs b/crates/completion/src/render.rs
index fa594b5e5..6eb20df2b 100644
--- a/crates/completion/src/render.rs
+++ b/crates/completion/src/render.rs
@@ -523,7 +523,7 @@ fn main() { let _: m::Spam = S$0 }
523 Function, 523 Function,
524 ), 524 ),
525 lookup: "main", 525 lookup: "main",
526 detail: "fn main()", 526 detail: "-> ()",
527 }, 527 },
528 ] 528 ]
529 "#]], 529 "#]],
@@ -552,7 +552,7 @@ fn main() { som$0 }
552 Function, 552 Function,
553 ), 553 ),
554 lookup: "main", 554 lookup: "main",
555 detail: "fn main()", 555 detail: "-> ()",
556 }, 556 },
557 CompletionItem { 557 CompletionItem {
558 label: "something_deprecated()", 558 label: "something_deprecated()",
@@ -563,7 +563,7 @@ fn main() { som$0 }
563 Function, 563 Function,
564 ), 564 ),
565 lookup: "something_deprecated", 565 lookup: "something_deprecated",
566 detail: "fn something_deprecated()", 566 detail: "-> ()",
567 deprecated: true, 567 deprecated: true,
568 }, 568 },
569 CompletionItem { 569 CompletionItem {
@@ -575,7 +575,7 @@ fn main() { som$0 }
575 Function, 575 Function,
576 ), 576 ),
577 lookup: "something_else_deprecated", 577 lookup: "something_else_deprecated",
578 detail: "fn something_else_deprecated()", 578 detail: "-> ()",
579 deprecated: true, 579 deprecated: true,
580 }, 580 },
581 ] 581 ]
@@ -626,7 +626,7 @@ impl S {
626 insert: "bar()$0", 626 insert: "bar()$0",
627 kind: Method, 627 kind: Method,
628 lookup: "bar", 628 lookup: "bar",
629 detail: "fn bar(self)", 629 detail: "-> ()",
630 documentation: Documentation( 630 documentation: Documentation(
631 "Method docs", 631 "Method docs",
632 ), 632 ),
@@ -726,7 +726,7 @@ fn foo(s: S) { s.$0 }
726 insert: "the_method()$0", 726 insert: "the_method()$0",
727 kind: Method, 727 kind: Method,
728 lookup: "the_method", 728 lookup: "the_method",
729 detail: "fn the_method(&self)", 729 detail: "-> ()",
730 }, 730 },
731 ] 731 ]
732 "#]], 732 "#]],
diff --git a/crates/completion/src/render/function.rs b/crates/completion/src/render/function.rs
index 2d616b1fb..e46e21d24 100644
--- a/crates/completion/src/render/function.rs
+++ b/crates/completion/src/render/function.rs
@@ -1,8 +1,8 @@
1//! Renderer for function calls. 1//! Renderer for function calls.
2 2
3use hir::{HasSource, Type}; 3use hir::{HasSource, HirDisplay, Type};
4use ide_db::SymbolKind; 4use ide_db::SymbolKind;
5use syntax::{ast::Fn, display::function_declaration}; 5use syntax::ast::Fn;
6use test_utils::mark; 6use test_utils::mark;
7 7
8use crate::{ 8use crate::{
@@ -55,7 +55,8 @@ impl<'a> FunctionRender<'a> {
55 } 55 }
56 56
57 fn detail(&self) -> String { 57 fn detail(&self) -> String {
58 function_declaration(&self.ast_node) 58 let ty = self.func.ret_type(self.ctx.db());
59 format!("-> {}", ty.display(self.ctx.db()))
59 } 60 }
60 61
61 fn add_arg(&self, arg: &str, ty: &Type) -> String { 62 fn add_arg(&self, arg: &str, ty: &Type) -> String {
diff --git a/crates/rust-analyzer/src/bin/main.rs b/crates/rust-analyzer/src/bin/main.rs
index 2f7f94a39..1d6e5478b 100644
--- a/crates/rust-analyzer/src/bin/main.rs
+++ b/crates/rust-analyzer/src/bin/main.rs
@@ -76,7 +76,12 @@ fn setup_logging(log_file: Option<PathBuf>) -> Result<()> {
76 profile::init(); 76 profile::init();
77 77
78 if !cfg!(debug_assertions) { 78 if !cfg!(debug_assertions) {
79 stdx::set_assert_hook(|loc, args| log::error!("assertion failed at {}: {}", loc, args)); 79 stdx::set_assert_hook(|loc, args| {
80 if env::var("RA_PROFILE").is_ok() {
81 panic!("assertion failed at {}: {}", loc, args)
82 }
83 log::error!("assertion failed at {}: {}", loc, args)
84 });
80 } 85 }
81 86
82 Ok(()) 87 Ok(())