mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
internal: add ranges to minicore
This commit is contained in:
parent
f4b52682da
commit
0bb1f1bc90
2 changed files with 42 additions and 28 deletions
|
@ -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<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,
|
||||
}
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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<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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue