Skip to content

Commit c289cf0

Browse files
committed
remove range lang items
The range desugaring does not use the lang items. Hence I did not add lang items for inclusive ranges. This cleanup commit removes the old unused ones as well. Whether the desugaring _should_ use lang items is another question: see rust-lang#30809. But if we decide on a strategy there we can add back these lang items, and new ones for inclusive ranges. For stage0 we need to keep the attributes as the lang items still exist even if they are never used. This is surprisingly not a breaking change. Unused #[lang] attributes do not even trigger a lint (see rust-lang#30881).
1 parent f57b6db commit c289cf0

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/libcore/ops.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1465,7 +1465,7 @@ pub trait IndexMut<Idx: ?Sized>: Index<Idx> {
14651465

14661466
/// An unbounded range.
14671467
#[derive(Copy, Clone, PartialEq, Eq)]
1468-
#[lang = "range_full"]
1468+
#[cfg_attr(stage0, lang = "range_full")] // TODO remove attribute after next snapshot
14691469
#[stable(feature = "rust1", since = "1.0.0")]
14701470
pub struct RangeFull;
14711471

@@ -1478,7 +1478,7 @@ impl fmt::Debug for RangeFull {
14781478

14791479
/// A (half-open) range which is bounded at both ends.
14801480
#[derive(Clone, PartialEq, Eq)]
1481-
#[lang = "range"]
1481+
#[cfg_attr(stage0, lang = "range")] // TODO remove attribute after next snapshot
14821482
#[stable(feature = "rust1", since = "1.0.0")]
14831483
pub struct Range<Idx> {
14841484
/// The lower bound of the range (inclusive).
@@ -1498,7 +1498,7 @@ impl<Idx: fmt::Debug> fmt::Debug for Range<Idx> {
14981498

14991499
/// A range which is only bounded below.
15001500
#[derive(Clone, PartialEq, Eq)]
1501-
#[lang = "range_from"]
1501+
#[cfg_attr(stage0, lang = "range_from")] // TODO remove attribute after next snapshot
15021502
#[stable(feature = "rust1", since = "1.0.0")]
15031503
pub struct RangeFrom<Idx> {
15041504
/// The lower bound of the range (inclusive).
@@ -1515,7 +1515,7 @@ impl<Idx: fmt::Debug> fmt::Debug for RangeFrom<Idx> {
15151515

15161516
/// A range which is only bounded above.
15171517
#[derive(Copy, Clone, PartialEq, Eq)]
1518-
#[lang = "range_to"]
1518+
#[cfg_attr(stage0, lang = "range_to")] // TODO remove attribute after next snapshot
15191519
#[stable(feature = "rust1", since = "1.0.0")]
15201520
pub struct RangeTo<Idx> {
15211521
/// The upper bound of the range (exclusive).

src/librustc/middle/lang_items.rs

-4
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,6 @@ lets_do_this! {
301301
ShrAssignTraitLangItem, "shr_assign", shr_assign_trait;
302302
IndexTraitLangItem, "index", index_trait;
303303
IndexMutTraitLangItem, "index_mut", index_mut_trait;
304-
RangeStructLangItem, "range", range_struct;
305-
RangeFromStructLangItem, "range_from", range_from_struct;
306-
RangeToStructLangItem, "range_to", range_to_struct;
307-
RangeFullStructLangItem, "range_full", range_full_struct;
308304

309305
UnsafeCellTypeLangItem, "unsafe_cell", unsafe_cell_type;
310306

0 commit comments

Comments
 (0)