]> git.lizzy.rs Git - rust.git/commitdiff
internal: add ranges to minicore
authorAleksey Kladov <aleksey.kladov@gmail.com>
Tue, 15 Jun 2021 18:45:25 +0000 (21:45 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Tue, 15 Jun 2021 18:45:25 +0000 (21:45 +0300)
crates/hir_ty/src/tests/simple.rs
crates/test_utils/src/minicore.rs

index 2687c6a44c39336bc5638ec136d6703ed41aa572..b63cda9124feb0983bd0b046c78f169751911313 100644 (file)
@@ -113,7 +113,7 @@ fn foo() {
 fn infer_ranges() {
     check_types(
         r#"
-//- /main.rs crate:main deps:core
+//- minicore: range
 fn test() {
     let a = ..;
     let b = 1..;
@@ -125,32 +125,6 @@ fn test() {
     let t = (a, b, c, d, e, f);
     t;
 } //^ (RangeFull, RangeFrom<i32>, RangeTo<u32>, Range<usize>, RangeToInclusive<i32>, RangeInclusive<char>)
-
-//- /core.rs crate:core
-#[prelude_import] use prelude::*;
-mod prelude {}
-
-pub mod ops {
-    pub struct Range<Idx> {
-        pub start: Idx,
-        pub end: Idx,
-    }
-    pub struct RangeFrom<Idx> {
-        pub start: Idx,
-    }
-    struct RangeFull;
-    pub struct RangeInclusive<Idx> {
-        start: Idx,
-        end: Idx,
-        is_empty: u8,
-    }
-    pub struct RangeTo<Idx> {
-        pub end: Idx,
-    }
-    pub struct RangeToInclusive<Idx> {
-        pub end: Idx,
-    }
-}
 "#,
     );
 }
index a61459f6d9318f66b63774f7b062ac64b391a2f7..f9f14b7dfa879e8b8fba0f42999b2751539d4f45 100644 (file)
@@ -10,6 +10,7 @@
 //! Available flags:
 //!     sized:
 //!     slice:
+//!     range:
 //!     unsize: sized
 //!     deref: sized
 //!     coerce_unsized: unsize
@@ -62,13 +63,52 @@ pub trait Deref {
     }
     pub use self::deref::Deref;
     // endregion:deref
+
+    //region:range
+    mod range {
+        #[lang = "RangeFull"]
+        pub struct RangeFull;
+
+        #[lang = "Range"]
+        pub struct Range<Idx> {
+            pub start: Idx,
+            pub end: Idx,
+        }
+
+        #[lang = "RangeFrom"]
+        pub struct RangeFrom<Idx> {
+            pub start: Idx,
+        }
+
+        #[lang = "RangeTo"]
+        pub struct RangeTo<Idx> {
+            pub end: Idx,
+        }
+
+        #[lang = "RangeInclusive"]
+        pub struct RangeInclusive<Idx> {
+            pub(crate) start: Idx,
+            pub(crate) end: Idx,
+            pub(crate) exhausted: bool,
+        }
+
+        #[lang = "RangeToInclusive"]
+        pub struct RangeToInclusive<Idx> {
+            pub end: Idx,
+        }
+    }
+    pub use self::range::{Range, RangeFrom, RangeFull, RangeTo};
+    pub use self::range::{RangeInclusive, RangeToInclusive};
+    //endregion:range
 }
 
 // region:slice
 pub mod slice {
     #[lang = "slice"]
     impl<T> [T] {
-        pub fn len(&self) -> usize { loop {} }
+        pub fn len(&self) -> usize {
+            loop {}
+        }
     }
 }
 // endregion:slice