From c82f5379de49344eb418cc6aaf5bf8c35bc4aaef Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 10 Jul 2020 18:30:32 +0200 Subject: Enable Chalk tracing in hir_ty tests --- crates/ra_hir_ty/src/tests/traits.rs | 93 +++++++++++++----------------------- 1 file changed, 34 insertions(+), 59 deletions(-) (limited to 'crates/ra_hir_ty/src/tests') diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs index 529d9e253..85bcd0050 100644 --- a/crates/ra_hir_ty/src/tests/traits.rs +++ b/crates/ra_hir_ty/src/tests/traits.rs @@ -3000,69 +3000,44 @@ fn infer_box_fn_arg() { #[test] fn infer_dyn_fn_output() { - assert_snapshot!( - infer( - r#" - //- /lib.rs deps:std - - #[lang = "fn_once"] - pub trait FnOnce { - type Output; - - extern "rust-call" fn call_once(self, args: Args) -> Self::Output; - } - - #[lang = "fn"] - pub trait Fn:FnOnce { - extern "rust-call" fn call(&self, args: Args) -> Self::Output; - } - - #[lang = "deref"] - pub trait Deref { - type Target: ?Sized; - - fn deref(&self) -> &Self::Target; - } + check_types( + r#" +//- /lib.rs +#[lang = "fn_once"] +pub trait FnOnce { + type Output; + extern "rust-call" fn call_once(self, args: Args) -> Self::Output; +} - #[lang = "owned_box"] - pub struct Box { - inner: *mut T, - } +#[lang = "fn"] +pub trait Fn: FnOnce { + extern "rust-call" fn call(&self, args: Args) -> Self::Output; +} - impl Deref for Box { - type Target = T; +fn foo() { + let f: &dyn Fn() -> i32; + f(); + //^^^ i32 +}"#, + ); +} - fn deref(&self) -> &T { - &self.inner - } - } +#[test] +fn infer_dyn_fn_once_output() { + check_types( + r#" +//- /lib.rs +#[lang = "fn_once"] +pub trait FnOnce { + type Output; + extern "rust-call" fn call_once(self, args: Args) -> Self::Output; +} - fn foo() { - let f: Box i32> = box(|| 5); - let x = f(); - } - "# - ), - @r###" - 100..104 'self': Self - 106..110 'args': Args - 219..223 'self': &Self - 225..229 'args': Args - 333..337 'self': &Self - 503..507 'self': &Box - 515..542 '{ ... }': &T - 525..536 '&self.inner': &*mut T - 526..530 'self': &Box - 526..536 'self.inner': *mut T - 555..620 '{ ...f(); }': () - 565..566 'f': Box> - 591..600 'box(|| 5)': Box<|| -> i32> - 595..599 '|| 5': || -> i32 - 598..599 '5': i32 - 610..611 'x': FnOnce::Output, ()> - 614..615 'f': Box> - 614..617 'f()': FnOnce::Output, ()> - "### +fn foo() { + let f: dyn FnOnce() -> i32; + f(); + //^^^ i32 +}"#, ); } -- cgit v1.2.3