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() {
|
fn infer_ranges() {
|
||||||
check_types(
|
check_types(
|
||||||
r#"
|
r#"
|
||||||
//- /main.rs crate:main deps:core
|
//- minicore: range
|
||||||
fn test() {
|
fn test() {
|
||||||
let a = ..;
|
let a = ..;
|
||||||
let b = 1..;
|
let b = 1..;
|
||||||
|
@ -125,32 +125,6 @@ fn test() {
|
||||||
let t = (a, b, c, d, e, f);
|
let t = (a, b, c, d, e, f);
|
||||||
t;
|
t;
|
||||||
} //^ (RangeFull, RangeFrom<i32>, RangeTo<u32>, Range<usize>, RangeToInclusive<i32>, RangeInclusive<char>)
|
} //^ (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:
|
//! Available flags:
|
||||||
//! sized:
|
//! sized:
|
||||||
//! slice:
|
//! slice:
|
||||||
|
//! range:
|
||||||
//! unsize: sized
|
//! unsize: sized
|
||||||
//! deref: sized
|
//! deref: sized
|
||||||
//! coerce_unsized: unsize
|
//! coerce_unsized: unsize
|
||||||
|
@ -62,13 +63,52 @@ pub mod ops {
|
||||||
}
|
}
|
||||||
pub use self::deref::Deref;
|
pub use self::deref::Deref;
|
||||||
// endregion: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
|
// region:slice
|
||||||
pub mod slice {
|
pub mod slice {
|
||||||
#[lang = "slice"]
|
#[lang = "slice"]
|
||||||
impl<T> [T] {
|
impl<T> [T] {
|
||||||
pub fn len(&self) -> usize { loop {} }
|
pub fn len(&self) -> usize {
|
||||||
|
loop {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// endregion:slice
|
// endregion:slice
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue