aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-06-15 19:45:25 +0100
committerAleksey Kladov <[email protected]>2021-06-15 19:45:25 +0100
commit0bb1f1bc90ee0f0f92f55823fc2e0c12c6acb680 (patch)
treef1aca0344f6da61352d822bba49b92202919abec
parentf4b52682dad6dbf31fb17beb645e362e359ee119 (diff)
internal: add ranges to minicore
-rw-r--r--crates/hir_ty/src/tests/simple.rs28
-rw-r--r--crates/test_utils/src/minicore.rs42
2 files changed, 42 insertions, 28 deletions
diff --git a/crates/hir_ty/src/tests/simple.rs b/crates/hir_ty/src/tests/simple.rs
index 2687c6a44..b63cda912 100644
--- a/crates/hir_ty/src/tests/simple.rs
+++ b/crates/hir_ty/src/tests/simple.rs
@@ -113,7 +113,7 @@ fn type_alias_in_struct_lit() {
113fn infer_ranges() { 113fn infer_ranges() {
114 check_types( 114 check_types(
115 r#" 115 r#"
116//- /main.rs crate:main deps:core 116//- minicore: range
117fn test() { 117fn test() {
118 let a = ..; 118 let a = ..;
119 let b = 1..; 119 let b = 1..;
@@ -125,32 +125,6 @@ fn test() {
125 let t = (a, b, c, d, e, f); 125 let t = (a, b, c, d, e, f);
126 t; 126 t;
127} //^ (RangeFull, RangeFrom<i32>, RangeTo<u32>, Range<usize>, RangeToInclusive<i32>, RangeInclusive<char>) 127} //^ (RangeFull, RangeFrom<i32>, RangeTo<u32>, Range<usize>, RangeToInclusive<i32>, RangeInclusive<char>)
128
129//- /core.rs crate:core
130#[prelude_import] use prelude::*;
131mod prelude {}
132
133pub mod ops {
134 pub struct Range<Idx> {
135 pub start: Idx,
136 pub end: Idx,
137 }
138 pub struct RangeFrom<Idx> {
139 pub start: Idx,
140 }
141 struct RangeFull;
142 pub struct RangeInclusive<Idx> {
143 start: Idx,
144 end: Idx,
145 is_empty: u8,
146 }
147 pub struct RangeTo<Idx> {
148 pub end: Idx,
149 }
150 pub struct RangeToInclusive<Idx> {
151 pub end: Idx,
152 }
153}
154"#, 128"#,
155 ); 129 );
156} 130}
diff --git a/crates/test_utils/src/minicore.rs b/crates/test_utils/src/minicore.rs
index a61459f6d..f9f14b7df 100644
--- a/crates/test_utils/src/minicore.rs
+++ b/crates/test_utils/src/minicore.rs
@@ -10,6 +10,7 @@
10//! Available flags: 10//! Available flags:
11//! sized: 11//! sized:
12//! slice: 12//! slice:
13//! range:
13//! unsize: sized 14//! unsize: sized
14//! deref: sized 15//! deref: sized
15//! coerce_unsized: unsize 16//! coerce_unsized: unsize
@@ -62,13 +63,52 @@ pub mod ops {
62 } 63 }
63 pub use self::deref::Deref; 64 pub use self::deref::Deref;
64 // endregion:deref 65 // endregion:deref
66
67 //region:range
68 mod range {
69 #[lang = "RangeFull"]
70 pub struct RangeFull;
71
72 #[lang = "Range"]
73 pub struct Range<Idx> {
74 pub start: Idx,
75 pub end: Idx,
76 }
77
78 #[lang = "RangeFrom"]
79 pub struct RangeFrom<Idx> {
80 pub start: Idx,
81 }
82
83 #[lang = "RangeTo"]
84 pub struct RangeTo<Idx> {
85 pub end: Idx,
86 }
87
88 #[lang = "RangeInclusive"]
89 pub struct RangeInclusive<Idx> {
90 pub(crate) start: Idx,
91 pub(crate) end: Idx,
92 pub(crate) exhausted: bool,
93 }
94
95 #[lang = "RangeToInclusive"]
96 pub struct RangeToInclusive<Idx> {
97 pub end: Idx,
98 }
99 }
100 pub use self::range::{Range, RangeFrom, RangeFull, RangeTo};
101 pub use self::range::{RangeInclusive, RangeToInclusive};
102 //endregion:range
65} 103}
66 104
67// region:slice 105// region:slice
68pub mod slice { 106pub mod slice {
69 #[lang = "slice"] 107 #[lang = "slice"]
70 impl<T> [T] { 108 impl<T> [T] {
71 pub fn len(&self) -> usize { loop {} } 109 pub fn len(&self) -> usize {
110 loop {}
111 }
72 } 112 }
73} 113}
74// endregion:slice 114// endregion:slice