Skip to content

Commit a34d84c

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 7b76251 commit a34d84c

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
@@ -1468,7 +1468,7 @@ pub trait IndexMut<Idx: ?Sized>: Index<Idx> {
14681468

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

@@ -1481,7 +1481,7 @@ impl fmt::Debug for RangeFull {
14811481

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

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

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

src/librustc/middle/lang_items.rs

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

308304
UnsafeCellTypeLangItem, "unsafe_cell", unsafe_cell_type;
309305

0 commit comments

Comments
 (0)