diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-09-12 11:53:29 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-09-12 11:53:29 +0100 |
commit | a1261631a89f7169a3f84dec33aff61758c601e3 (patch) | |
tree | 773c687fe89b8cec009de17142b3a59e80468b21 /crates/ra_hir/src/ty/tests.rs | |
parent | 561e7aea5bdaf6c51e0a87da9ff1d73e2df52be1 (diff) | |
parent | 8c078a01641518a6b093922d4b1d27d1a98bad08 (diff) |
Merge #1818
1818: Infer box expression r=matklad a=uHOOCCOOHu
Infer `box e` to be `std::boxed::Box<T>` where `e: T`
Co-authored-by: uHOOCCOOHu <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 869ae13f1..9a5f6949d 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -56,6 +56,37 @@ mod future { | |||
56 | } | 56 | } |
57 | 57 | ||
58 | #[test] | 58 | #[test] |
59 | fn infer_box() { | ||
60 | let (mut db, pos) = MockDatabase::with_position( | ||
61 | r#" | ||
62 | //- /main.rs | ||
63 | |||
64 | fn test() { | ||
65 | let x = box 1; | ||
66 | let t = (x, box x, box &1, box [1]); | ||
67 | t<|>; | ||
68 | } | ||
69 | |||
70 | //- /std.rs | ||
71 | #[prelude_import] use prelude::*; | ||
72 | mod prelude {} | ||
73 | |||
74 | mod boxed { | ||
75 | pub struct Box<T: ?Sized> { | ||
76 | inner: *mut T, | ||
77 | } | ||
78 | } | ||
79 | |||
80 | "#, | ||
81 | ); | ||
82 | db.set_crate_graph_from_fixture(crate_graph! { | ||
83 | "main": ("/main.rs", ["std"]), | ||
84 | "std": ("/std.rs", []), | ||
85 | }); | ||
86 | assert_eq!("(Box<i32>, Box<Box<i32>>, Box<&i32>, Box<[i32;_]>)", type_at_pos(&db, pos)); | ||
87 | } | ||
88 | |||
89 | #[test] | ||
59 | fn infer_try() { | 90 | fn infer_try() { |
60 | let (mut db, pos) = MockDatabase::with_position( | 91 | let (mut db, pos) = MockDatabase::with_position( |
61 | r#" | 92 | r#" |