From 0bb1f1bc90ee0f0f92f55823fc2e0c12c6acb680 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 15 Jun 2021 21:45:25 +0300 Subject: internal: add ranges to minicore --- crates/hir_ty/src/tests/simple.rs | 28 +------------------------- crates/test_utils/src/minicore.rs | 42 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 28 deletions(-) (limited to 'crates') 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() { 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, RangeTo, Range, RangeToInclusive, RangeInclusive) - -//- /core.rs crate:core -#[prelude_import] use prelude::*; -mod prelude {} - -pub mod ops { - pub struct Range { - pub start: Idx, - pub end: Idx, - } - pub struct RangeFrom { - pub start: Idx, - } - struct RangeFull; - pub struct RangeInclusive { - start: Idx, - end: Idx, - is_empty: u8, - } - pub struct RangeTo { - pub end: Idx, - } - pub struct RangeToInclusive { - pub end: Idx, - } -} "#, ); } 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 @@ //! Available flags: //! sized: //! slice: +//! range: //! unsize: sized //! deref: sized //! coerce_unsized: unsize @@ -62,13 +63,52 @@ pub mod ops { } pub use self::deref::Deref; // endregion:deref + + //region:range + mod range { + #[lang = "RangeFull"] + pub struct RangeFull; + + #[lang = "Range"] + pub struct Range { + pub start: Idx, + pub end: Idx, + } + + #[lang = "RangeFrom"] + pub struct RangeFrom { + pub start: Idx, + } + + #[lang = "RangeTo"] + pub struct RangeTo { + pub end: Idx, + } + + #[lang = "RangeInclusive"] + pub struct RangeInclusive { + pub(crate) start: Idx, + pub(crate) end: Idx, + pub(crate) exhausted: bool, + } + + #[lang = "RangeToInclusive"] + pub struct RangeToInclusive { + 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] { - pub fn len(&self) -> usize { loop {} } + pub fn len(&self) -> usize { + loop {} + } } } // endregion:slice -- cgit v1.2.3