Skip to content

Commit ad7a32a

Browse files
committed
Restore unstable module level constants to avoid ICE #28586
1 parent 2865d65 commit ad7a32a

File tree

9 files changed

+46
-24
lines changed

9 files changed

+46
-24
lines changed

src/libcollections/enum_set.rs

-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ pub trait CLike {
8989
}
9090

9191
fn bit<E:CLike>(e: &E) -> usize {
92-
use core::usize;
9392
let value = e.to_usize();
9493
assert!(value < usize::BITS,
9594
"EnumSet only supports up to {} variants.", usize::BITS - 1);

src/libcollections/vec_deque.rs

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use core::mem;
2525
use core::ops::{Index, IndexMut};
2626
use core::ptr;
2727
use core::slice;
28-
use core::usize;
2928

3029
use core::hash::{Hash, Hasher};
3130
use core::cmp;

src/libcore/num/int_macros.rs

+15
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@
1212

1313
macro_rules! int_module { ($T:ty, $bits:expr) => (
1414

15+
// FIXME(#11621): Should be deprecated once CTFE is implemented in favour of
16+
// calling the `mem::size_of` function.
17+
#[unstable(feature = "num_bits_bytes",
18+
reason = "may want to be an associated function",
19+
issue = "27753")]
20+
#[allow(missing_docs)]
21+
pub const BITS : usize = $bits;
22+
// FIXME(#11621): Should be deprecated once CTFE is implemented in favour of
23+
// calling the `mem::size_of` function.
24+
#[unstable(feature = "num_bits_bytes",
25+
reason = "may want to be an associated function",
26+
issue = "27753")]
27+
#[allow(missing_docs)]
28+
pub const BYTES : usize = ($bits / 8);
29+
1530
// FIXME(#11621): Should be deprecated once CTFE is implemented in favour of
1631
// calling the `Bounded::min_value` function.
1732
#[stable(feature = "rust1", since = "1.0.0")]

src/libcore/num/mod.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ unsafe fn bswap8(x: u8) -> u8 { x }
115115

116116
// `Int` + `SignedInt` implemented for signed integers
117117
macro_rules! int_impl {
118-
($ActualT:ty, $UnsignedT:ty, $BITS:expr,
118+
($SelfT:ty, $ActualT:ty, $UnsignedT:ty, $BITS:expr,
119119
$add_with_overflow:path,
120120
$sub_with_overflow:path,
121121
$mul_with_overflow:path) => {
@@ -139,13 +139,13 @@ macro_rules! int_impl {
139139
// calling the `Bounded::min_value` function.
140140
#[stable(feature = "rust1", since = "1.0.0")]
141141
#[allow(missing_docs)]
142-
pub const MIN: $ActualT = (-1 as $ActualT) << ($BITS - 1);
142+
pub const MIN: $SelfT = (-1 as $SelfT) << ($BITS - 1);
143143
// FIXME(#9837): Compute MIN like this so the high bits that shouldn't exist are 0.
144144
// FIXME(#11621): Should be deprecated once CTFE is implemented in favour of
145145
// calling the `Bounded::max_value` function.
146146
#[stable(feature = "rust1", since = "1.0.0")]
147147
#[allow(missing_docs)]
148-
pub const MAX: $ActualT = !<$ActualT>::MIN;
148+
pub const MAX: $SelfT = !<$SelfT>::MIN;
149149

150150
/// Returns the smallest value that can be represented by this integer type.
151151
#[stable(feature = "rust1", since = "1.0.0")]
@@ -639,31 +639,31 @@ macro_rules! int_impl {
639639

640640
#[lang = "i8"]
641641
impl i8 {
642-
int_impl! { i8, u8, 8,
642+
int_impl! { i8, i8, u8, 8,
643643
intrinsics::i8_add_with_overflow,
644644
intrinsics::i8_sub_with_overflow,
645645
intrinsics::i8_mul_with_overflow }
646646
}
647647

648648
#[lang = "i16"]
649649
impl i16 {
650-
int_impl! { i16, u16, 16,
650+
int_impl! { i16, i16, u16, 16,
651651
intrinsics::i16_add_with_overflow,
652652
intrinsics::i16_sub_with_overflow,
653653
intrinsics::i16_mul_with_overflow }
654654
}
655655

656656
#[lang = "i32"]
657657
impl i32 {
658-
int_impl! { i32, u32, 32,
658+
int_impl! { i32, i32, u32, 32,
659659
intrinsics::i32_add_with_overflow,
660660
intrinsics::i32_sub_with_overflow,
661661
intrinsics::i32_mul_with_overflow }
662662
}
663663

664664
#[lang = "i64"]
665665
impl i64 {
666-
int_impl! { i64, u64, 64,
666+
int_impl! { i64, i64, u64, 64,
667667
intrinsics::i64_add_with_overflow,
668668
intrinsics::i64_sub_with_overflow,
669669
intrinsics::i64_mul_with_overflow }
@@ -672,7 +672,7 @@ impl i64 {
672672
#[cfg(target_pointer_width = "32")]
673673
#[lang = "isize"]
674674
impl isize {
675-
int_impl! { i32, u32, 32,
675+
int_impl! { isize, i32, u32, 32,
676676
intrinsics::i32_add_with_overflow,
677677
intrinsics::i32_sub_with_overflow,
678678
intrinsics::i32_mul_with_overflow }
@@ -681,15 +681,15 @@ impl isize {
681681
#[cfg(target_pointer_width = "64")]
682682
#[lang = "isize"]
683683
impl isize {
684-
int_impl! { i64, u64, 64,
684+
int_impl! { isize, i64, u64, 64,
685685
intrinsics::i64_add_with_overflow,
686686
intrinsics::i64_sub_with_overflow,
687687
intrinsics::i64_mul_with_overflow }
688688
}
689689

690690
// `Int` + `UnsignedInt` implemented for signed integers
691691
macro_rules! uint_impl {
692-
($ActualT:ty, $BITS:expr,
692+
($SelfT:ty, $ActualT:ty, $BITS:expr,
693693
$ctpop:path,
694694
$ctlz:path,
695695
$cttz:path,
@@ -711,10 +711,10 @@ macro_rules! uint_impl {
711711

712712
#[stable(feature = "rust1", since = "1.0.0")]
713713
#[allow(missing_docs)]
714-
pub const MIN: $ActualT = 0 as $ActualT;
714+
pub const MIN: $SelfT = 0 as $SelfT;
715715
#[stable(feature = "rust1", since = "1.0.0")]
716716
#[allow(missing_docs)]
717-
pub const MAX: $ActualT = !0 as $ActualT;
717+
pub const MAX: $SelfT = !0 as $SelfT;
718718

719719
/// Returns the smallest value that can be represented by this integer type.
720720
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1210,7 +1210,7 @@ macro_rules! uint_impl {
12101210

12111211
#[lang = "u8"]
12121212
impl u8 {
1213-
uint_impl! { u8, 8,
1213+
uint_impl! { u8, u8, 8,
12141214
intrinsics::ctpop8,
12151215
intrinsics::ctlz8,
12161216
intrinsics::cttz8,
@@ -1222,7 +1222,7 @@ impl u8 {
12221222

12231223
#[lang = "u16"]
12241224
impl u16 {
1225-
uint_impl! { u16, 16,
1225+
uint_impl! { u16, u16, 16,
12261226
intrinsics::ctpop16,
12271227
intrinsics::ctlz16,
12281228
intrinsics::cttz16,
@@ -1234,7 +1234,7 @@ impl u16 {
12341234

12351235
#[lang = "u32"]
12361236
impl u32 {
1237-
uint_impl! { u32, 32,
1237+
uint_impl! { u32, u32, 32,
12381238
intrinsics::ctpop32,
12391239
intrinsics::ctlz32,
12401240
intrinsics::cttz32,
@@ -1247,7 +1247,7 @@ impl u32 {
12471247

12481248
#[lang = "u64"]
12491249
impl u64 {
1250-
uint_impl! { u64, 64,
1250+
uint_impl! { u64, u64, 64,
12511251
intrinsics::ctpop64,
12521252
intrinsics::ctlz64,
12531253
intrinsics::cttz64,
@@ -1260,7 +1260,7 @@ impl u64 {
12601260
#[cfg(target_pointer_width = "32")]
12611261
#[lang = "usize"]
12621262
impl usize {
1263-
uint_impl! { u32, 32,
1263+
uint_impl! { usize, u32, 32,
12641264
intrinsics::ctpop32,
12651265
intrinsics::ctlz32,
12661266
intrinsics::cttz32,
@@ -1273,7 +1273,7 @@ impl usize {
12731273
#[cfg(target_pointer_width = "64")]
12741274
#[lang = "usize"]
12751275
impl usize {
1276-
uint_impl! { u64, 64,
1276+
uint_impl! { usize, u64, 64,
12771277
intrinsics::ctpop64,
12781278
intrinsics::ctlz64,
12791279
intrinsics::cttz64,

src/libcore/num/uint_macros.rs

+11
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@
1212

1313
macro_rules! uint_module { ($T:ty, $T_SIGNED:ty, $bits:expr) => (
1414

15+
#[unstable(feature = "num_bits_bytes",
16+
reason = "may want to be an associated function",
17+
issue = "27753")]
18+
#[allow(missing_docs)]
19+
pub const BITS : usize = $bits;
20+
#[unstable(feature = "num_bits_bytes",
21+
reason = "may want to be an associated function",
22+
issue = "27753")]
23+
#[allow(missing_docs)]
24+
pub const BYTES : usize = ($bits / 8);
25+
1526
#[stable(feature = "rust1", since = "1.0.0")]
1627
#[allow(missing_docs)]
1728
pub const MIN: $T = 0 as $T;

src/libcore/num/usize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
1515
#![stable(feature = "rust1", since = "1.0.0")]
1616

17-
uint_module! { usize, isize, ::isize::BITS }
17+
uint_module! { usize, isize, isize::BITS }

src/librustc/middle/dataflow.rs

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use middle::cfg;
2020
use middle::cfg::CFGIndex;
2121
use middle::ty;
2222
use std::io;
23-
use std::usize;
2423
use syntax::ast;
2524
use syntax::ast_util::IdRange;
2625
use syntax::print::pp;

src/librustc_lint/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use lint::{LateContext, LintContext, LintArray};
1919
use lint::{LintPass, LateLintPass};
2020

2121
use std::cmp;
22-
use std::{i8, i16, i32, i64, u8, u16, u32, u64, f32, f64};
22+
use std::{f32, f64};
2323

2424
use syntax::{abi, ast};
2525
use syntax::attr::{self, AttrMetaMethods};

src/libserialize/collection_impls.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
//! Implementations of serialization for structures found in libcollections
1212
13-
use std::usize;
1413
use std::default::Default;
1514
use std::hash::Hash;
1615
use std::collections::hash_state::HashState;

0 commit comments

Comments
 (0)