|
#[doc(alias = "..")] |
|
#[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186 |
|
#[stable(feature = "rust1", since = "1.0.0")] |
|
pub struct Range<Idx> { |
|
/// The lower bound of the range (inclusive). |
|
#[stable(feature = "rust1", since = "1.0.0")] |
|
pub start: Idx, |
|
/// The upper bound of the range (exclusive). |
|
#[stable(feature = "rust1", since = "1.0.0")] |
|
pub end: Idx, |
|
} |
Rustc always lowers it to ::ops::Range.
|
ExprKind::Range(ref e1, ref e2, lims) => { |
|
use syntax::ast::RangeLimits::*; |
|
|
|
let path = match (e1, e2, lims) { |
|
(&None, &None, HalfOpen) => "RangeFull", |
|
(&Some(..), &None, HalfOpen) => "RangeFrom", |
|
(&None, &Some(..), HalfOpen) => "RangeTo", |
|
(&Some(..), &Some(..), HalfOpen) => "Range", |
|
(&None, &Some(..), Closed) => "RangeToInclusive", |
|
(&Some(..), &Some(..), Closed) => unreachable!(), |
|
(_, &None, Closed) => self.diagnostic() |
|
.span_fatal(e.span, "inclusive range with no end") |
|
.raise(), |
|
}; |
|
|
|
let fields = e1.iter() |
|
.map(|e| ("start", e)) |
|
.chain(e2.iter().map(|e| ("end", e))) |
|
.map(|(s, e)| { |
|
let expr = P(self.lower_expr(&e)); |
|
let ident = Ident::new(Symbol::intern(s), e.span); |
|
self.field(ident, expr, e.span) |
|
}) |
|
.collect::<P<[hir::Field]>>(); |
|
|
|
let is_unit = fields.is_empty(); |
|
let struct_path = iter::once("ops") |
|
.chain(iter::once(path)) |
|
.collect::<Vec<_>>(); |
Found some more lowerings like this
|
let path = &["ops", "Try", "into_result"]; |
|
let path = &["ops", "Try", method]; |
|
let ty_path = P(self.std_path(e.span, &["ops", "RangeInclusive"], None, false)); |
They should probably be a lang item.
rust/src/libcore/ops/range.rs
Lines 79 to 89 in c0955a3
Rustc always lowers it to
::ops::Range.rust/src/librustc/hir/lowering.rs
Lines 3781 to 3809 in caed80b
Found some more lowerings like this
rust/src/librustc/hir/lowering.rs
Line 4207 in caed80b
rust/src/librustc/hir/lowering.rs
Line 4809 in caed80b
rust/src/librustc/hir/lowering.rs
Line 3774 in caed80b
They should probably be a lang item.