Skip to content

Commit

Permalink
Auto merge of #49101 - mark-i-m:stabilize_i128, r=nagisa
Browse files Browse the repository at this point in the history
Stabilize 128-bit integers 🎉

cc #35118

EDIT: This should be merged only after the following have been merged:
- [x] rust-lang/compiler-builtins#236
- [x] rust-lang/book#1230
  • Loading branch information
bors committed Mar 26, 2018
2 parents ab8b961 + 140bf94 commit 188e693
Show file tree
Hide file tree
Showing 60 changed files with 106 additions and 301 deletions.
25 changes: 0 additions & 25 deletions src/doc/unstable-book/src/language-features/i128-type.md

This file was deleted.

18 changes: 18 additions & 0 deletions src/doc/unstable-book/src/language-features/repr128.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# `repr128`

The tracking issue for this feature is: [#35118]

[#35118]: https://github.com/rust-lang/rust/issues/35118

------------------------

The `repr128` feature adds support for `#[repr(u128)]` on `enum`s.

```rust
#![feature(repr128)]

#[repr(u128)]
enum Foo {
Bar(u64),
}
```
2 changes: 1 addition & 1 deletion src/liballoc/benches/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#![deny(warnings)]

#![feature(i128_type)]
#![cfg_attr(stage0, feature(i128_type))]
#![feature(rand)]
#![feature(repr_simd)]
#![feature(test)]
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
#![feature(from_ref)]
#![feature(fundamental)]
#![feature(generic_param_attrs)]
#![feature(i128_type)]
#![cfg_attr(stage0, feature(i128_type))]
#![feature(iter_rfold)]
#![feature(lang_items)]
#![feature(needs_allocator)]
Expand Down
2 changes: 1 addition & 1 deletion src/libcompiler_builtins
4 changes: 2 additions & 2 deletions src/libcore/hash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ pub trait Hasher {
}
/// Writes a single `u128` into this hasher.
#[inline]
#[unstable(feature = "i128", issue = "35118")]
#[stable(feature = "i128", since = "1.26.0")]
fn write_u128(&mut self, i: u128) {
self.write(&unsafe { mem::transmute::<_, [u8; 16]>(i) })
}
Expand Down Expand Up @@ -348,7 +348,7 @@ pub trait Hasher {
}
/// Writes a single `i128` into this hasher.
#[inline]
#[unstable(feature = "i128", issue = "35118")]
#[stable(feature = "i128", since = "1.26.0")]
fn write_i128(&mut self, i: i128) {
self.write_u128(i as u128)
}
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
#![feature(doc_spotlight)]
#![feature(fn_must_use)]
#![feature(fundamental)]
#![feature(i128_type)]
#![cfg_attr(stage0, feature(i128_type))]
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
#![feature(intrinsics)]
#![feature(iterator_flatten)]
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/num/i128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
//!
//! *[See also the `i128` primitive type](../../std/primitive.i128.html).*
#![unstable(feature = "i128", issue="35118")]
#![stable(feature = "i128", since = "1.26.0")]

int_module! { i128, #[unstable(feature = "i128", issue="35118")] }
int_module! { i128, #[stable(feature = "i128", since="1.26.0")] }
45 changes: 15 additions & 30 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,8 @@ nonzero_integers! {
NonZeroU16(u16); NonZeroI16(i16);
NonZeroU32(u32); NonZeroI32(i32);
NonZeroU64(u64); NonZeroI64(i64);
NonZeroUsize(usize); NonZeroIsize(isize);
}

nonzero_integers! {
// Change this to `#[unstable(feature = "i128", issue = "35118")]`
// if other NonZero* integer types are stabilizied before 128-bit integers
#[unstable(feature = "nonzero", issue = "49137")]
NonZeroU128(u128); NonZeroI128(i128);
NonZeroUsize(usize); NonZeroIsize(isize);
}

/// Provides intentionally-wrapped arithmetic on `T`.
Expand Down Expand Up @@ -1635,11 +1629,7 @@ impl i64 {
#[lang = "i128"]
impl i128 {
int_impl! { i128, i128, u128, 128, -170141183460469231731687303715884105728,
170141183460469231731687303715884105727, "#![feature(i128_type)]
#![feature(i128)]
# fn main() {
", "
# }" }
170141183460469231731687303715884105727, "", "" }
}

#[cfg(target_pointer_width = "16")]
Expand Down Expand Up @@ -3493,12 +3483,7 @@ impl u64 {

#[lang = "u128"]
impl u128 {
uint_impl! { u128, u128, 128, 340282366920938463463374607431768211455, "#![feature(i128_type)]
#![feature(i128)]
# fn main() {
", "
# }" }
uint_impl! { u128, u128, 128, 340282366920938463463374607431768211455, "", "" }
}

#[cfg(target_pointer_width = "16")]
Expand Down Expand Up @@ -4055,39 +4040,39 @@ macro_rules! impl_from {
impl_from! { u8, u16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
impl_from! { u8, u32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
impl_from! { u8, u64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
impl_from! { u8, u128, #[unstable(feature = "i128", issue = "35118")] }
impl_from! { u8, u128, #[stable(feature = "i128", since = "1.26.0")] }
impl_from! { u8, usize, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
impl_from! { u16, u32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
impl_from! { u16, u64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
impl_from! { u16, u128, #[unstable(feature = "i128", issue = "35118")] }
impl_from! { u16, u128, #[stable(feature = "i128", since = "1.26.0")] }
impl_from! { u32, u64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
impl_from! { u32, u128, #[unstable(feature = "i128", issue = "35118")] }
impl_from! { u64, u128, #[unstable(feature = "i128", issue = "35118")] }
impl_from! { u32, u128, #[stable(feature = "i128", since = "1.26.0")] }
impl_from! { u64, u128, #[stable(feature = "i128", since = "1.26.0")] }

// Signed -> Signed
impl_from! { i8, i16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
impl_from! { i8, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
impl_from! { i8, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
impl_from! { i8, i128, #[unstable(feature = "i128", issue = "35118")] }
impl_from! { i8, i128, #[stable(feature = "i128", since = "1.26.0")] }
impl_from! { i8, isize, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
impl_from! { i16, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
impl_from! { i16, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
impl_from! { i16, i128, #[unstable(feature = "i128", issue = "35118")] }
impl_from! { i16, i128, #[stable(feature = "i128", since = "1.26.0")] }
impl_from! { i32, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
impl_from! { i32, i128, #[unstable(feature = "i128", issue = "35118")] }
impl_from! { i64, i128, #[unstable(feature = "i128", issue = "35118")] }
impl_from! { i32, i128, #[stable(feature = "i128", since = "1.26.0")] }
impl_from! { i64, i128, #[stable(feature = "i128", since = "1.26.0")] }

// Unsigned -> Signed
impl_from! { u8, i16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
impl_from! { u8, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
impl_from! { u8, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
impl_from! { u8, i128, #[unstable(feature = "i128", issue = "35118")] }
impl_from! { u8, i128, #[stable(feature = "i128", since = "1.26.0")] }
impl_from! { u16, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
impl_from! { u16, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
impl_from! { u16, i128, #[unstable(feature = "i128", issue = "35118")] }
impl_from! { u16, i128, #[stable(feature = "i128", since = "1.26.0")] }
impl_from! { u32, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
impl_from! { u32, i128, #[unstable(feature = "i128", issue = "35118")] }
impl_from! { u64, i128, #[unstable(feature = "i128", issue = "35118")] }
impl_from! { u32, i128, #[stable(feature = "i128", since = "1.26.0")] }
impl_from! { u64, i128, #[stable(feature = "i128", since = "1.26.0")] }

// Note: integers can only be represented with full precision in a float if
// they fit in the significand, which is 24 bits in f32 and 53 bits in f64.
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/num/u128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
//!
//! *[See also the `u128` primitive type](../../std/primitive.u128.html).*
#![unstable(feature = "i128", issue="35118")]
uint_module! { u128, #[unstable(feature = "i128", issue="35118")] }
#![stable(feature = "i128", since = "1.26.0")]
uint_module! { u128, #[stable(feature = "i128", since="1.26.0")] }
2 changes: 1 addition & 1 deletion src/libcore/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#![feature(fmt_internals)]
#![feature(hashmap_internals)]
#![feature(iterator_step_by)]
#![feature(i128_type)]
#![cfg_attr(stage0, feature(i128_type))]
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
#![feature(iterator_try_fold)]
#![feature(iterator_flatten)]
Expand Down
2 changes: 1 addition & 1 deletion src/libproc_macro/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
test(no_crate_inject, attr(deny(warnings))),
test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))]

#![feature(i128_type)]
#![cfg_attr(stage0, feature(i128_type))]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(lang_items)]
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
#![feature(entry_or_default)]
#![feature(from_ref)]
#![feature(fs_read_write)]
#![feature(i128)]
#![feature(i128_type)]
#![cfg_attr(stage0, feature(i128_type, i128))]
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
#![cfg_attr(windows, feature(libc))]
#![feature(match_default_bindings)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_apfloat/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
#![deny(warnings)]
#![forbid(unsafe_code)]

#![feature(i128_type)]
#![cfg_attr(stage0, feature(slice_patterns))]
#![cfg_attr(stage0, feature(i128_type))]
#![feature(try_from)]

// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_apfloat/tests/ieee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(i128_type)]
#![cfg_attr(stage0, feature(i128_type))]

#[macro_use]
extern crate rustc_apfloat;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_const_eval/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(macro_lifetime_matcher)]
#![feature(i128_type)]
#![cfg_attr(stage0, feature(i128_type))]
#![feature(from_ref)]

extern crate arena;
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_const_math/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]

#![feature(i128)]
#![feature(i128_type)]
#![cfg_attr(stage0, feature(i128_type, i128))]

extern crate rustc_apfloat;

Expand Down
3 changes: 1 addition & 2 deletions src/librustc_data_structures/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
#![feature(unboxed_closures)]
#![feature(fn_traits)]
#![feature(unsize)]
#![feature(i128_type)]
#![feature(i128)]
#![cfg_attr(stage0, feature(conservative_impl_trait))]
#![cfg_attr(stage0, feature(i128_type, i128))]
#![feature(specialization)]
#![feature(optin_builtin_traits)]
#![feature(underscore_lifetimes)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_errors/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#![feature(range_contains)]
#![cfg_attr(unix, feature(libc))]
#![cfg_attr(stage0, feature(conservative_impl_trait))]
#![feature(i128_type)]
#![cfg_attr(stage0, feature(i128_type))]
#![feature(optin_builtin_traits)]

extern crate atty;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_incremental/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#![cfg_attr(stage0, feature(conservative_impl_trait))]
#![feature(fs_read_write)]
#![feature(i128_type)]
#![cfg_attr(stage0, feature(i128_type))]
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
#![feature(specialization)]

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#![cfg_attr(test, feature(test))]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(i128_type)]
#![cfg_attr(stage0, feature(i128_type))]
#![feature(macro_vis_matcher)]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#![feature(box_patterns)]
#![cfg_attr(stage0, feature(conservative_impl_trait))]
#![feature(fs_read_write)]
#![feature(i128_type)]
#![cfg_attr(stage0, feature(i128_type))]
#![feature(libc)]
#![feature(macro_lifetime_matcher)]
#![feature(proc_macro_internals)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
#![feature(decl_macro)]
#![feature(dyn_trait)]
#![feature(fs_read_write)]
#![feature(i128_type)]
#![cfg_attr(stage0, feature(i128_type))]
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
#![feature(macro_vis_matcher)]
#![feature(match_default_bindings)]
Expand Down
13 changes: 1 addition & 12 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ use syntax::ast::{FnDecl, ForeignItem, ForeignItemKind, GenericParam, Generics};
use syntax::ast::{Item, ItemKind, ImplItem, ImplItemKind};
use syntax::ast::{Label, Local, Mutability, Pat, PatKind, Path};
use syntax::ast::{QSelf, TraitItemKind, TraitRef, Ty, TyKind};
use syntax::feature_gate::{feature_err, emit_feature_err, GateIssue};
use syntax::feature_gate::{feature_err, GateIssue};
use syntax::parse::token;
use syntax::ptr::P;

Expand Down Expand Up @@ -3172,17 +3172,6 @@ impl<'a> Resolver<'a> {
self.primitive_type_table.primitive_types
.contains_key(&path[0].node.name) => {
let prim = self.primitive_type_table.primitive_types[&path[0].node.name];
match prim {
TyUint(UintTy::U128) | TyInt(IntTy::I128) => {
if !self.session.features_untracked().i128_type {
emit_feature_err(&self.session.parse_sess,
"i128_type", span, GateIssue::Language,
"128-bit type is unstable");

}
}
_ => {}
}
PathResolution::with_unresolved_segments(Def::PrimTy(prim), path.len() - 1)
}
PathResult::Module(module) => PathResolution::new(module.def().unwrap()),
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_trans/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
#![feature(custom_attribute)]
#![feature(fs_read_write)]
#![allow(unused_attributes)]
#![feature(i128_type)]
#![feature(i128)]
#![cfg_attr(stage0, feature(i128_type, i128))]
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
#![feature(libc)]
#![feature(quote)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans_utils/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#![feature(box_syntax)]
#![feature(custom_attribute)]
#![allow(unused_attributes)]
#![feature(i128_type)]
#![cfg_attr(stage0, feature(i128_type))]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
#![cfg_attr(stage0, feature(conservative_impl_trait))]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ This API is completely unstable and subject to change.
#![feature(refcell_replace_swap)]
#![feature(rustc_diagnostic_macros)]
#![feature(slice_patterns)]
#![feature(i128_type)]
#![cfg_attr(stage0, feature(i128_type))]
#![cfg_attr(stage0, feature(never_type))]

#[macro_use] extern crate log;
Expand Down
2 changes: 1 addition & 1 deletion src/libserialize/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Core encoding and decoding interfaces.

#![feature(box_syntax)]
#![feature(core_intrinsics)]
#![feature(i128_type)]
#![cfg_attr(stage0, feature(i128_type))]
#![feature(specialization)]
#![cfg_attr(test, feature(test))]

Expand Down
Loading

0 comments on commit 188e693

Please sign in to comment.