-
Notifications
You must be signed in to change notification settings - Fork 14k
Closed
Labels
A-lang-itemArea: Language itemsArea: Language itemsC-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Lines 79 to 89 in c0955a3
| #[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.
rust/src/librustc/hir/lowering.rs
Lines 3781 to 3809 in caed80b
| 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
rust/src/librustc/hir/lowering.rs
Line 4207 in caed80b
| let path = &["ops", "Try", "into_result"]; |
rust/src/librustc/hir/lowering.rs
Line 4809 in caed80b
| let path = &["ops", "Try", method]; |
rust/src/librustc/hir/lowering.rs
Line 3774 in caed80b
| let ty_path = P(self.std_path(e.span, &["ops", "RangeInclusive"], None, false)); |
They should probably be a lang item.
Metadata
Metadata
Assignees
Labels
A-lang-itemArea: Language itemsArea: Language itemsC-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.