From: Aleksey Kladov Date: Tue, 15 Jun 2021 18:45:25 +0000 (+0300) Subject: internal: add ranges to minicore X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=0bb1f1bc90ee0f0f92f55823fc2e0c12c6acb680;p=rust.git internal: add ranges to minicore --- diff --git a/crates/hir_ty/src/tests/simple.rs b/crates/hir_ty/src/tests/simple.rs index 2687c6a44c3..b63cda9124f 100644 --- a/crates/hir_ty/src/tests/simple.rs +++ b/crates/hir_ty/src/tests/simple.rs @@ -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, 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 a61459f6d93..f9f14b7dfa8 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 trait Deref { } 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