aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/hover.rs99
1 files changed, 99 insertions, 0 deletions
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs
index d870e4cbc..9a88b4977 100644
--- a/crates/ra_ide/src/hover.rs
+++ b/crates/ra_ide/src/hover.rs
@@ -2410,4 +2410,103 @@ fn func(foo: i32) { if true { <|>foo; }; }
2410 ] 2410 ]
2411 "###); 2411 "###);
2412 } 2412 }
2413
2414 #[test]
2415 fn infer_closure_arg() {
2416 check_hover_result(
2417 r#"
2418 //- /lib.rs
2419
2420 enum Option<T> {
2421 None,
2422 Some(T)
2423 }
2424
2425 fn foo() {
2426 let s<|> = Option::None;
2427 let f = |x: Option<i32>| {};
2428 (&f)(s)
2429 }
2430 "#,
2431 &["Option<i32>"],
2432 );
2433 }
2434
2435 #[test]
2436 fn infer_fn_trait_arg() {
2437 check_hover_result(
2438 r#"
2439 //- /lib.rs deps:std
2440
2441 #[lang = "fn"]
2442 pub trait Fn<Args> {
2443 type Output;
2444
2445 extern "rust-call" fn call(&self, args: Args) -> Self::Output;
2446 }
2447
2448 enum Option<T> {
2449 None,
2450 Some(T)
2451 }
2452
2453 fn foo<F, T>(f: F) -> T
2454 where
2455 F: Fn(Option<i32>) -> T,
2456 {
2457 let s<|> = None;
2458 f(s)
2459 }
2460 "#,
2461 &["Option<i32>"],
2462 );
2463 }
2464
2465 #[test]
2466 fn infer_box_fn_arg() {
2467 check_hover_result(
2468 r#"
2469 //- /lib.rs deps:std
2470
2471 #[lang = "fn_once"]
2472 pub trait FnOnce<Args> {
2473 type Output;
2474
2475 extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
2476 }
2477
2478 #[lang = "deref"]
2479 pub trait Deref {
2480 type Target: ?Sized;
2481
2482 fn deref(&self) -> &Self::Target;
2483 }
2484
2485 #[lang = "owned_box"]
2486 pub struct Box<T: ?Sized> {
2487 inner: *mut T,
2488 }
2489
2490 impl<T: ?Sized> Deref for Box<T> {
2491 type Target = T;
2492
2493 fn deref(&self) -> &T {
2494 &self.inner
2495 }
2496 }
2497
2498 enum Option<T> {
2499 None,
2500 Some(T)
2501 }
2502
2503 fn foo() {
2504 let s<|> = Option::None;
2505 let f: Box<dyn FnOnce(&Option<i32>)> = box (|ps| {});
2506 f(&s)
2507 }
2508 "#,
2509 &["Option<i32>"],
2510 );
2511 }
2413} 2512}