aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty/src')
-rw-r--r--crates/ra_hir_ty/src/display.rs20
-rw-r--r--crates/ra_hir_ty/src/tests/coercion.rs8
-rw-r--r--crates/ra_hir_ty/src/tests/regression.rs2
-rw-r--r--crates/ra_hir_ty/src/tests/simple.rs6
-rw-r--r--crates/ra_hir_ty/src/tests/traits.rs12
5 files changed, 28 insertions, 20 deletions
diff --git a/crates/ra_hir_ty/src/display.rs b/crates/ra_hir_ty/src/display.rs
index 1f5168ee3..0e9313aa1 100644
--- a/crates/ra_hir_ty/src/display.rs
+++ b/crates/ra_hir_ty/src/display.rs
@@ -155,7 +155,11 @@ impl HirDisplay for ApplicationTy {
155 let sig = FnSig::from_fn_ptr_substs(&self.parameters); 155 let sig = FnSig::from_fn_ptr_substs(&self.parameters);
156 write!(f, "fn(")?; 156 write!(f, "fn(")?;
157 f.write_joined(sig.params(), ", ")?; 157 f.write_joined(sig.params(), ", ")?;
158 write!(f, ") -> {}", sig.ret().display(f.db))?; 158 write!(f, ")")?;
159 let ret = sig.ret();
160 if *ret != Ty::unit() {
161 write!(f, " -> {}", ret.display(f.db))?;
162 }
159 } 163 }
160 TypeCtor::FnDef(def) => { 164 TypeCtor::FnDef(def) => {
161 let sig = f.db.callable_item_signature(def).subst(&self.parameters); 165 let sig = f.db.callable_item_signature(def).subst(&self.parameters);
@@ -180,7 +184,11 @@ impl HirDisplay for ApplicationTy {
180 } 184 }
181 write!(f, "(")?; 185 write!(f, "(")?;
182 f.write_joined(sig.params(), ", ")?; 186 f.write_joined(sig.params(), ", ")?;
183 write!(f, ") -> {}", sig.ret().display(f.db))?; 187 write!(f, ")")?;
188 let ret = sig.ret();
189 if *ret != Ty::unit() {
190 write!(f, " -> {}", ret.display(f.db))?;
191 }
184 } 192 }
185 TypeCtor::Adt(def_id) => { 193 TypeCtor::Adt(def_id) => {
186 let name = match def_id { 194 let name = match def_id {
@@ -242,16 +250,16 @@ impl HirDisplay for ApplicationTy {
242 let sig = self.parameters[0] 250 let sig = self.parameters[0]
243 .callable_sig(f.db) 251 .callable_sig(f.db)
244 .expect("first closure parameter should contain signature"); 252 .expect("first closure parameter should contain signature");
245 let return_type_hint = sig.ret().display(f.db);
246 if sig.params().is_empty() { 253 if sig.params().is_empty() {
247 write!(f, "|| -> {}", return_type_hint)?; 254 write!(f, "||")?;
248 } else if f.omit_verbose_types() { 255 } else if f.omit_verbose_types() {
249 write!(f, "|{}| -> {}", TYPE_HINT_TRUNCATION, return_type_hint)?; 256 write!(f, "|{}|", TYPE_HINT_TRUNCATION)?;
250 } else { 257 } else {
251 write!(f, "|")?; 258 write!(f, "|")?;
252 f.write_joined(sig.params(), ", ")?; 259 f.write_joined(sig.params(), ", ")?;
253 write!(f, "| -> {}", return_type_hint)?; 260 write!(f, "|")?;
254 }; 261 };
262 write!(f, " -> {}", sig.ret().display(f.db))?;
255 } 263 }
256 } 264 }
257 Ok(()) 265 Ok(())
diff --git a/crates/ra_hir_ty/src/tests/coercion.rs b/crates/ra_hir_ty/src/tests/coercion.rs
index 3e3d55c04..b2c971f02 100644
--- a/crates/ra_hir_ty/src/tests/coercion.rs
+++ b/crates/ra_hir_ty/src/tests/coercion.rs
@@ -407,16 +407,16 @@ fn test() {
407 [30; 31) 'x': &Foo 407 [30; 31) 'x': &Foo
408 [39; 41) '{}': () 408 [39; 41) '{}': ()
409 [52; 133) '{ ...oo); }': () 409 [52; 133) '{ ...oo); }': ()
410 [58; 71) 'takes_ref_foo': fn takes_ref_foo(&Foo) -> () 410 [58; 71) 'takes_ref_foo': fn takes_ref_foo(&Foo)
411 [58; 77) 'takes_...(&Foo)': () 411 [58; 77) 'takes_...(&Foo)': ()
412 [72; 76) '&Foo': &Foo 412 [72; 76) '&Foo': &Foo
413 [73; 76) 'Foo': Foo 413 [73; 76) 'Foo': Foo
414 [83; 96) 'takes_ref_foo': fn takes_ref_foo(&Foo) -> () 414 [83; 96) 'takes_ref_foo': fn takes_ref_foo(&Foo)
415 [83; 103) 'takes_...&&Foo)': () 415 [83; 103) 'takes_...&&Foo)': ()
416 [97; 102) '&&Foo': &&Foo 416 [97; 102) '&&Foo': &&Foo
417 [98; 102) '&Foo': &Foo 417 [98; 102) '&Foo': &Foo
418 [99; 102) 'Foo': Foo 418 [99; 102) 'Foo': Foo
419 [109; 122) 'takes_ref_foo': fn takes_ref_foo(&Foo) -> () 419 [109; 122) 'takes_ref_foo': fn takes_ref_foo(&Foo)
420 [109; 130) 'takes_...&&Foo)': () 420 [109; 130) 'takes_...&&Foo)': ()
421 [123; 129) '&&&Foo': &&&Foo 421 [123; 129) '&&&Foo': &&&Foo
422 [124; 129) '&&Foo': &&Foo 422 [124; 129) '&&Foo': &&Foo
@@ -484,7 +484,7 @@ fn test() {
484 [171; 178) 'loop {}': ! 484 [171; 178) 'loop {}': !
485 [176; 178) '{}': () 485 [176; 178) '{}': ()
486 [191; 236) '{ ... }); }': () 486 [191; 236) '{ ... }); }': ()
487 [197; 210) 'takes_ref_str': fn takes_ref_str(&str) -> () 487 [197; 210) 'takes_ref_str': fn takes_ref_str(&str)
488 [197; 233) 'takes_...g() })': () 488 [197; 233) 'takes_...g() })': ()
489 [211; 232) '&{ ret...ng() }': &String 489 [211; 232) '&{ ret...ng() }': &String
490 [212; 232) '{ retu...ng() }': String 490 [212; 232) '{ retu...ng() }': String
diff --git a/crates/ra_hir_ty/src/tests/regression.rs b/crates/ra_hir_ty/src/tests/regression.rs
index 2ee9b8f10..3402e0cb5 100644
--- a/crates/ra_hir_ty/src/tests/regression.rs
+++ b/crates/ra_hir_ty/src/tests/regression.rs
@@ -376,7 +376,7 @@ fn issue_2669() {
376 ), 376 ),
377 @r###" 377 @r###"
378 [147; 262) '{ ... }': () 378 [147; 262) '{ ... }': ()
379 [161; 164) 'end': fn end<{unknown}>() -> () 379 [161; 164) 'end': fn end<{unknown}>()
380 [161; 166) 'end()': () 380 [161; 166) 'end()': ()
381 [199; 252) '{ ... }': () 381 [199; 252) '{ ... }': ()
382 [221; 223) '_x': ! 382 [221; 223) '_x': !
diff --git a/crates/ra_hir_ty/src/tests/simple.rs b/crates/ra_hir_ty/src/tests/simple.rs
index 141f0245a..c2f1ded2f 100644
--- a/crates/ra_hir_ty/src/tests/simple.rs
+++ b/crates/ra_hir_ty/src/tests/simple.rs
@@ -521,7 +521,7 @@ fn test() -> &mut &f64 {
521 [88; 89) 'a': u32 521 [88; 89) 'a': u32
522 [92; 108) 'unknow...nction': {unknown} 522 [92; 108) 'unknow...nction': {unknown}
523 [92; 110) 'unknow...tion()': u32 523 [92; 110) 'unknow...tion()': u32
524 [116; 125) 'takes_u32': fn takes_u32(u32) -> () 524 [116; 125) 'takes_u32': fn takes_u32(u32)
525 [116; 128) 'takes_u32(a)': () 525 [116; 128) 'takes_u32(a)': ()
526 [126; 127) 'a': u32 526 [126; 127) 'a': u32
527 [138; 139) 'b': i32 527 [138; 139) 'b': i32
@@ -1749,9 +1749,9 @@ fn main() {
1749 [67; 91) 'Vtable...| {} }': Vtable 1749 [67; 91) 'Vtable...| {} }': Vtable
1750 [84; 89) '|| {}': || -> () 1750 [84; 89) '|| {}': || -> ()
1751 [87; 89) '{}': () 1751 [87; 89) '{}': ()
1752 [101; 102) 'm': fn() -> () 1752 [101; 102) 'm': fn()
1753 [105; 111) 'vtable': Vtable 1753 [105; 111) 'vtable': Vtable
1754 [105; 118) 'vtable.method': fn() -> () 1754 [105; 118) 'vtable.method': fn()
1755 "### 1755 "###
1756 ); 1756 );
1757} 1757}
diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs
index f009a708c..081aa943a 100644
--- a/crates/ra_hir_ty/src/tests/traits.rs
+++ b/crates/ra_hir_ty/src/tests/traits.rs
@@ -263,7 +263,7 @@ fn test() {
263 [119; 120) 'S': S<u32>(u32) -> S<u32> 263 [119; 120) 'S': S<u32>(u32) -> S<u32>
264 [119; 129) 'S(unknown)': S<u32> 264 [119; 129) 'S(unknown)': S<u32>
265 [121; 128) 'unknown': u32 265 [121; 128) 'unknown': u32
266 [135; 138) 'foo': fn foo<S<u32>>(S<u32>) -> () 266 [135; 138) 'foo': fn foo<S<u32>>(S<u32>)
267 [135; 141) 'foo(s)': () 267 [135; 141) 'foo(s)': ()
268 [139; 140) 's': S<u32> 268 [139; 140) 's': S<u32>
269 "### 269 "###
@@ -962,7 +962,7 @@ fn test(x: impl Trait<u64>, y: &impl Trait<u32>) {
962 [224; 225) 'S': S<u16>(u16) -> S<u16> 962 [224; 225) 'S': S<u16>(u16) -> S<u16>
963 [224; 228) 'S(1)': S<u16> 963 [224; 228) 'S(1)': S<u16>
964 [226; 227) '1': u16 964 [226; 227) '1': u16
965 [234; 237) 'bar': fn bar(S<u16>) -> () 965 [234; 237) 'bar': fn bar(S<u16>)
966 [234; 240) 'bar(z)': () 966 [234; 240) 'bar(z)': ()
967 [238; 239) 'z': S<u16> 967 [238; 239) 'z': S<u16>
968 [246; 247) 'x': impl Trait<u64> 968 [246; 247) 'x': impl Trait<u64>
@@ -1108,8 +1108,8 @@ fn test() {
1108 [40; 47) 'loop {}': ! 1108 [40; 47) 'loop {}': !
1109 [45; 47) '{}': () 1109 [45; 47) '{}': ()
1110 [91; 124) '{ ...foo; }': () 1110 [91; 124) '{ ...foo; }': ()
1111 [101; 102) 'f': fn(S) -> () 1111 [101; 102) 'f': fn(S)
1112 [118; 121) 'foo': fn foo(S) -> () 1112 [118; 121) 'foo': fn foo(S)
1113 "### 1113 "###
1114 ); 1114 );
1115} 1115}
@@ -1962,7 +1962,7 @@ fn test() -> impl Trait<i32> {
1962 [229; 241) 'S(default())': S<u32> 1962 [229; 241) 'S(default())': S<u32>
1963 [231; 238) 'default': fn default<u32>() -> u32 1963 [231; 238) 'default': fn default<u32>() -> u32
1964 [231; 240) 'default()': u32 1964 [231; 240) 'default()': u32
1965 [247; 250) 'foo': fn foo(S<u32>) -> () 1965 [247; 250) 'foo': fn foo(S<u32>)
1966 [247; 254) 'foo(s1)': () 1966 [247; 254) 'foo(s1)': ()
1967 [251; 253) 's1': S<u32> 1967 [251; 253) 's1': S<u32>
1968 [264; 265) 'x': i32 1968 [264; 265) 'x': i32
@@ -2012,7 +2012,7 @@ fn main() {
2012 [147; 149) '_v': F 2012 [147; 149) '_v': F
2013 [192; 195) '{ }': () 2013 [192; 195) '{ }': ()
2014 [207; 238) '{ ... }); }': () 2014 [207; 238) '{ ... }); }': ()
2015 [213; 223) 'f::<(), _>': fn f<(), |&()| -> ()>(|&()| -> ()) -> () 2015 [213; 223) 'f::<(), _>': fn f<(), |&()| -> ()>(|&()| -> ())
2016 [213; 235) 'f::<()... z; })': () 2016 [213; 235) 'f::<()... z; })': ()
2017 [224; 234) '|z| { z; }': |&()| -> () 2017 [224; 234) '|z| { z; }': |&()| -> ()
2018 [225; 226) 'z': &() 2018 [225; 226) 'z': &()