From d414a3919740726e18897b6e39f66e8a25f00a5c Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 13 Feb 2015 15:48:05 +0100 Subject: Re-tag `slicing_syntax` as `Accepted`. Rollup merge (373cbab5b08d6630da58f28d2166c19afc327fa6) of PR #20723 accidentally reverted a portion of commit 8327bcc167661c26ca5c6b967309ff745d302329 which shifted `slicing_syntax` from Active to Accepted. --- src/libsyntax/feature_gate.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index ca7ae32f09e..d7cc4adaa57 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -79,7 +79,7 @@ static KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[ ("tuple_indexing", "1.0.0", Accepted), ("associated_types", "1.0.0", Accepted), ("visible_private_types", "1.0.0", Active), - ("slicing_syntax", "1.0.0", Active), + ("slicing_syntax", "1.0.0", Accepted), ("box_syntax", "1.0.0", Active), ("on_unimplemented", "1.0.0", Active), ("simd_ffi", "1.0.0", Active), -- cgit 1.4.1-3-g733a5 From a7d5c3f682002157c9d74cce773fb792d92333e1 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 13 Feb 2015 16:42:22 +0100 Subject: Added all active features to the list in reference.md. Added a second note about keeping the reference.md list up-to-date to the bottom of the list, since not everyone (including me) reads the big comment at the top of it. :) Ensured that the feature gate list in reference.md is kept in alphabetical order. --- src/doc/reference.md | 62 ++++++++++++++++++++++++++++++++++++------- src/libsyntax/feature_gate.rs | 1 + 2 files changed, 53 insertions(+), 10 deletions(-) (limited to 'src/libsyntax') diff --git a/src/doc/reference.md b/src/doc/reference.md index 9c51f6bad6f..18fdf38ffd5 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -2377,21 +2377,33 @@ considered off, and using the features will result in a compiler error. The currently implemented features of the reference compiler are: +* `advanced_slice_patterns` - see the [match expressions](#match-expressions) + section for discussion; the exact semantics of + slice patterns are subject to change. + * `asm` - The `asm!` macro provides a means for inline assembly. This is often useful, but the exact syntax for this feature along with its semantics are likely to change, so this macro usage must be opted into. +* `associated_types` - Allows type aliases in traits. Experimental. + +* `box_patterns` - Allows `box` patterns, the exact semantics of which + is subject to change. + +* `box_syntax` - Allows use of `box` expressions, the exact semantics of which + is subject to change. + * `concat_idents` - Allows use of the `concat_idents` macro, which is in many ways insufficient for concatenating identifiers, and may be removed entirely for something more wholesome. -* `default_type_params` - Allows use of default type parameters. The future of - this feature is uncertain. - * `intrinsics` - Allows use of the "rust-intrinsics" ABI. Compiler intrinsics are inherently unstable and no promise about them is made. +* `int_uint` - Allows the use of the `int` and `uint` types, which are deprecated. + Use `isize` and `usize` instead. + * `lang_items` - Allows use of the `#[lang]` attribute. Like `intrinsics`, lang items are inherently unstable and no promise about them is made. @@ -2410,12 +2422,33 @@ The currently implemented features of the reference compiler are: * `log_syntax` - Allows use of the `log_syntax` macro attribute, which is a nasty hack that will certainly be removed. +* `main` - Allows use of the `#[main]` attribute, which changes the entry point + into a Rust program. This capabiilty is subject to change. + +* `macro_reexport` - Allows macros to be re-exported from one crate after being imported + from another. This feature was originally designed with the sole + use case of the Rust standard library in mind, and is subject to + change. + * `non_ascii_idents` - The compiler supports the use of non-ascii identifiers, but the implementation is a little rough around the edges, so this can be seen as an experimental feature for now until the specification of identifiers is fully fleshed out. +* `no_std` - Allows the `#![no_std]` crate attribute, which disables the implicit + `extern crate std`. This typically requires use of the unstable APIs + behind the libstd "facade", such as libcore and libcollections. It + may also cause problems when using syntax extensions, including + `#[derive]`. + +* `on_unimplemented` - Allows the `#[rustc_on_unimplemented]` attribute, which allows + trait definitions to add specialized notes to error messages + when an implementation was expected but not found. + +* `optin_builtin_traits` - Allows the definition of default and negative trait + implementations. Experimental. + * `plugin` - Usage of [compiler plugins][plugin] for custom lints or syntax extensions. These depend on compiler internals and are subject to change. @@ -2431,8 +2464,15 @@ The currently implemented features of the reference compiler are: * `simd` - Allows use of the `#[simd]` attribute, which is overly simple and not the SIMD interface we want to expose in the long term. +* `simd_ffi` - Allows use of SIMD vectors in signatures for foreign functions. + The SIMD interface is subject to change. + * `staged_api` - Allows usage of stability markers and `#![staged_api]` in a crate +* `start` - Allows use of the `#[start]` attribute, which changes the entry point + into a Rust program. This capabiilty, especially the signature for the + annotated function, is subject to change. + * `struct_inherit` - Allows using struct inheritance, which is barely implemented and will probably be removed. Don't use this. @@ -2460,18 +2500,20 @@ The currently implemented features of the reference compiler are: which is considered wildly unsafe and will be obsoleted by language improvements. +* `unsafe_no_drop_flag` - Allows use of the `#[unsafe_no_drop_flag]` attribute, + which removes hidden flag added to a type that + implements the `Drop` trait. The design for the + `Drop` flag is subject to change, and this feature + may be removed in the future. + * `unmarked_api` - Allows use of items within a `#![staged_api]` crate which have not been marked with a stability marker. Such items should not be allowed by the compiler to exist, so if you need this there probably is a compiler bug. -* `associated_types` - Allows type aliases in traits. Experimental. - -* `no_std` - Allows the `#![no_std]` crate attribute, which disables the implicit - `extern crate std`. This typically requires use of the unstable APIs - behind the libstd "facade", such as libcore and libcollections. It - may also cause problems when using syntax extensions, including - `#[derive]`. +* `visible_private_types` - Allows public APIs to expose otherwise private + types, e.g. as the return type of a public function. + This capability may be removed in the future. If a feature is promoted to a language feature, then all existing programs will start to receive compilation warnings about #[feature] directives which enabled diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index ca7ae32f09e..12965863b22 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -134,6 +134,7 @@ static KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[ // switch to Accepted; see RFC 320) ("unsafe_no_drop_flag", "1.0.0", Active), ]; +// (changing above list without updating src/doc/reference.md makes @cmr sad) enum Status { /// Represents an active feature that is currently being implemented or -- cgit 1.4.1-3-g733a5 From 228603d9d210d121599ca384d2a66a90ba4299e1 Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Fri, 13 Feb 2015 12:52:33 -0800 Subject: Parse `pub` in the expansion of a method macro Fixes #17436. --- src/libsyntax/ext/tt/macro_rules.rs | 3 +-- src/test/run-pass/pub-method-inside-macro.rs | 29 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 src/test/run-pass/pub-method-inside-macro.rs (limited to 'src/libsyntax') diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index de61bdefa5d..f322cf8bad0 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -89,8 +89,7 @@ impl<'a> MacResult for ParserAnyMacro<'a> { match parser.token { token::Eof => break, _ => { - let attrs = parser.parse_outer_attributes(); - ret.push(parser.parse_method(attrs, ast::Inherited)) + ret.push(parser.parse_method_with_outer_attributes()); } } } diff --git a/src/test/run-pass/pub-method-inside-macro.rs b/src/test/run-pass/pub-method-inside-macro.rs new file mode 100644 index 00000000000..af2f217c1fb --- /dev/null +++ b/src/test/run-pass/pub-method-inside-macro.rs @@ -0,0 +1,29 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Issue #17436 + +mod bleh { + macro_rules! foo { + () => { + pub fn bar(&self) { } + } + } + + pub struct S; + + impl S { + foo!(); + } +} + +fn main() { + bleh::S.bar(); +} -- cgit 1.4.1-3-g733a5 From dcd4cef119dc2fdac43b86cfb3694756d8c23f9f Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Thu, 12 Feb 2015 20:43:57 -0800 Subject: Forbid `pub mymacro!();` It's not clear what this means, because a macro in item position can expand to zero or more items. For now we disallow it, which is technically a [breaking-change] but is landing without an RFC. The `pub` keyword previously had no effect, which seems quite unintended. Fixes #18317. Fixes #14660. --- src/libsyntax/parse/parser.rs | 18 ++++++++++++++++ src/test/compile-fail/pub-item-macro.rs | 28 ++++++++++++++++++++++++ src/test/compile-fail/pub-method-macro.rs | 34 ++++++++++++++++++++++++++++++ src/test/run-pass/pub-item-inside-macro.rs | 25 ++++++++++++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 src/test/compile-fail/pub-item-macro.rs create mode 100644 src/test/compile-fail/pub-method-macro.rs create mode 100644 src/test/run-pass/pub-item-inside-macro.rs (limited to 'src/libsyntax') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index fd2f0685cab..b1d0922cc84 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4621,6 +4621,17 @@ impl<'a> Parser<'a> { self.parse_method(attrs, visa) } + fn complain_if_pub_macro(&mut self, visa: Visibility, span: Span) { + match visa { + Public => { + self.span_err(span, "can't qualify macro invocation with `pub`"); + self.span_help(span, "try adjusting the macro to put `pub` inside \ + the invocation"); + } + Inherited => (), + } + } + /// Parse a method in a trait impl, starting with `attrs` attributes. pub fn parse_method(&mut self, attrs: Vec, @@ -4635,6 +4646,10 @@ impl<'a> Parser<'a> { && (self.look_ahead(2, |t| *t == token::OpenDelim(token::Paren)) || self.look_ahead(2, |t| *t == token::OpenDelim(token::Brace))) { // method macro. + + let last_span = self.last_span; + self.complain_if_pub_macro(visa, last_span); + let pth = self.parse_path(NoTypesAllowed); self.expect(&token::Not); @@ -5838,6 +5853,9 @@ impl<'a> Parser<'a> { || self.look_ahead(2, |t| *t == token::OpenDelim(token::Brace))) { // MACRO INVOCATION ITEM + let last_span = self.last_span; + self.complain_if_pub_macro(visibility, last_span); + // item macro. let pth = self.parse_path(NoTypesAllowed); self.expect(&token::Not); diff --git a/src/test/compile-fail/pub-item-macro.rs b/src/test/compile-fail/pub-item-macro.rs new file mode 100644 index 00000000000..8809e9a257d --- /dev/null +++ b/src/test/compile-fail/pub-item-macro.rs @@ -0,0 +1,28 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Issue #14660 + +macro_rules! priv_x { () => { + static x: u32 = 0; +}} + +macro_rules! pub_x { () => { + pub priv_x!(); //~ ERROR can't qualify macro invocation with `pub` + //~^ HELP try adjusting the macro to put `pub` inside the invocation +}} + +mod foo { + pub_x!(); +} + +fn main() { + let y: u32 = foo::x; +} diff --git a/src/test/compile-fail/pub-method-macro.rs b/src/test/compile-fail/pub-method-macro.rs new file mode 100644 index 00000000000..aa890550f1c --- /dev/null +++ b/src/test/compile-fail/pub-method-macro.rs @@ -0,0 +1,34 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Issue #18317 + +mod bleh { + macro_rules! defn { + ($n:ident) => ( + fn $n (&self) -> i32 { + println!("{}", stringify!($n)); + 1 + } + ) + } + + #[derive(Copy)] + pub struct S; + + impl S { + pub defn!(f); //~ ERROR can't qualify macro invocation with `pub` + //~^ HELP try adjusting the macro to put `pub` inside the invocation + } +} + +fn main() { + bleh::S.f(); +} diff --git a/src/test/run-pass/pub-item-inside-macro.rs b/src/test/run-pass/pub-item-inside-macro.rs new file mode 100644 index 00000000000..442eea13d6b --- /dev/null +++ b/src/test/run-pass/pub-item-inside-macro.rs @@ -0,0 +1,25 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Issue #14660 + +mod bleh { + macro_rules! foo { + () => { + pub fn bar() { } + } + } + + foo!(); +} + +fn main() { + bleh::bar(); +} -- cgit 1.4.1-3-g733a5 From b1cd76906a4c7e40e3eb3569450d2dbd3be9fcab Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 15 Feb 2015 00:10:19 +0300 Subject: Fix the fallout --- src/libcore/fmt/float.rs | 10 +++++----- src/libcore/num/mod.rs | 8 ++++---- src/libfmt_macros/lib.rs | 2 +- src/libstd/num/f32.rs | 14 +++++++------- src/libstd/num/f64.rs | 14 +++++++------- src/libstd/num/strconv.rs | 14 +++++++------- src/libsyntax/parse/lexer/mod.rs | 2 +- src/libterm/terminfo/parm.rs | 2 +- src/test/run-pass/exponential-notation.rs | 10 +++++----- 9 files changed, 38 insertions(+), 38 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libcore/fmt/float.rs b/src/libcore/fmt/float.rs index 25bb959b9b3..8e09e52daee 100644 --- a/src/libcore/fmt/float.rs +++ b/src/libcore/fmt/float.rs @@ -53,7 +53,7 @@ pub enum SignFormat { SignNeg } -static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11; +static DIGIT_E_RADIX: u32 = ('e' as u32) - ('a' as u32) + 11; /// Converts a number to its string representation as a byte vector. /// This is meant to be a common base implementation for all numeric string @@ -87,7 +87,7 @@ static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11; /// between digit and exponent sign `'p'`. pub fn float_to_str_bytes_common( num: T, - radix: uint, + radix: u32, negative_zero: bool, sign: SignFormat, digits: SignificantDigits, @@ -156,7 +156,7 @@ pub fn float_to_str_bytes_common( deccum = deccum / radix_gen; deccum = deccum.trunc(); - let c = char::from_digit(current_digit.to_int().unwrap() as uint, radix); + let c = char::from_digit(current_digit.to_int().unwrap() as u32, radix); buf[end] = c.unwrap() as u8; end += 1; @@ -211,7 +211,7 @@ pub fn float_to_str_bytes_common( // See note in first loop. let current_digit = deccum.trunc().abs(); - let c = char::from_digit(current_digit.to_int().unwrap() as uint, + let c = char::from_digit(current_digit.to_int().unwrap() as u32, radix); buf[end] = c.unwrap() as u8; end += 1; @@ -228,7 +228,7 @@ pub fn float_to_str_bytes_common( let ascii2value = |chr: u8| { (chr as char).to_digit(radix).unwrap() }; - let value2ascii = |val: uint| { + let value2ascii = |val: u32| { char::from_digit(val, radix).unwrap() as u8 }; diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index b7c5c6640ce..d6c01ddc74a 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -1432,12 +1432,12 @@ pub trait Float #[unstable(feature = "core", reason = "needs reevaluation")] pub trait FromStrRadix { type Err; - fn from_str_radix(str: &str, radix: uint) -> Result; + fn from_str_radix(str: &str, radix: u32) -> Result; } /// A utility function that just calls FromStrRadix::from_str_radix. #[unstable(feature = "core", reason = "needs reevaluation")] -pub fn from_str_radix(str: &str, radix: uint) +pub fn from_str_radix(str: &str, radix: u32) -> Result { FromStrRadix::from_str_radix(str, radix) } @@ -1501,7 +1501,7 @@ macro_rules! from_str_radix_float_impl { /// `None` if the string did not represent a valid number. /// Otherwise, `Some(n)` where `n` is the floating-point number /// represented by `src`. - fn from_str_radix(src: &str, radix: uint) + fn from_str_radix(src: &str, radix: u32) -> Result<$T, ParseFloatError> { use self::FloatErrorKind::*; use self::ParseFloatError as PFE; @@ -1661,7 +1661,7 @@ macro_rules! from_str_radix_int_impl { #[stable(feature = "rust1", since = "1.0.0")] impl FromStrRadix for $T { type Err = ParseIntError; - fn from_str_radix(src: &str, radix: uint) + fn from_str_radix(src: &str, radix: u32) -> Result<$T, ParseIntError> { use self::IntErrorKind::*; use self::ParseIntError as PIE; diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index fc8d18df815..baad31a61e1 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -422,7 +422,7 @@ impl<'a> Parser<'a> { Some((_, c)) => { match c.to_digit(10) { Some(i) => { - cur = cur * 10 + i; + cur = cur * 10 + i as usize; found = true; self.cur.next(); } diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index 58b93665fe1..62ed824c3ba 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -369,7 +369,7 @@ impl Float for f32 { #[unstable(feature = "std_misc", reason = "may be removed or relocated")] pub fn to_string(num: f32) -> String { let (r, _) = strconv::float_to_str_common( - num, 10u, true, SignNeg, DigAll, ExpNone, false); + num, 10, true, SignNeg, DigAll, ExpNone, false); r } @@ -382,7 +382,7 @@ pub fn to_string(num: f32) -> String { #[unstable(feature = "std_misc", reason = "may be removed or relocated")] pub fn to_str_hex(num: f32) -> String { let (r, _) = strconv::float_to_str_common( - num, 16u, true, SignNeg, DigAll, ExpNone, false); + num, 16, true, SignNeg, DigAll, ExpNone, false); r } @@ -395,7 +395,7 @@ pub fn to_str_hex(num: f32) -> String { /// * radix - The base to use #[inline] #[unstable(feature = "std_misc", reason = "may be removed or relocated")] -pub fn to_str_radix_special(num: f32, rdx: uint) -> (String, bool) { +pub fn to_str_radix_special(num: f32, rdx: u32) -> (String, bool) { strconv::float_to_str_common(num, rdx, true, SignNeg, DigAll, ExpNone, false) } @@ -410,7 +410,7 @@ pub fn to_str_radix_special(num: f32, rdx: uint) -> (String, bool) { #[unstable(feature = "std_misc", reason = "may be removed or relocated")] pub fn to_str_exact(num: f32, dig: uint) -> String { let (r, _) = strconv::float_to_str_common( - num, 10u, true, SignNeg, DigExact(dig), ExpNone, false); + num, 10, true, SignNeg, DigExact(dig), ExpNone, false); r } @@ -425,7 +425,7 @@ pub fn to_str_exact(num: f32, dig: uint) -> String { #[unstable(feature = "std_misc", reason = "may be removed or relocated")] pub fn to_str_digits(num: f32, dig: uint) -> String { let (r, _) = strconv::float_to_str_common( - num, 10u, true, SignNeg, DigMax(dig), ExpNone, false); + num, 10, true, SignNeg, DigMax(dig), ExpNone, false); r } @@ -441,7 +441,7 @@ pub fn to_str_digits(num: f32, dig: uint) -> String { #[unstable(feature = "std_misc", reason = "may be removed or relocated")] pub fn to_str_exp_exact(num: f32, dig: uint, upper: bool) -> String { let (r, _) = strconv::float_to_str_common( - num, 10u, true, SignNeg, DigExact(dig), ExpDec, upper); + num, 10, true, SignNeg, DigExact(dig), ExpDec, upper); r } @@ -457,7 +457,7 @@ pub fn to_str_exp_exact(num: f32, dig: uint, upper: bool) -> String { #[unstable(feature = "std_misc", reason = "may be removed or relocated")] pub fn to_str_exp_digits(num: f32, dig: uint, upper: bool) -> String { let (r, _) = strconv::float_to_str_common( - num, 10u, true, SignNeg, DigMax(dig), ExpDec, upper); + num, 10, true, SignNeg, DigMax(dig), ExpDec, upper); r } diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index 8b17feeb70c..0e2ac97ca01 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -378,7 +378,7 @@ impl Float for f64 { #[unstable(feature = "std_misc", reason = "may be removed or relocated")] pub fn to_string(num: f64) -> String { let (r, _) = strconv::float_to_str_common( - num, 10u, true, SignNeg, DigAll, ExpNone, false); + num, 10, true, SignNeg, DigAll, ExpNone, false); r } @@ -391,7 +391,7 @@ pub fn to_string(num: f64) -> String { #[unstable(feature = "std_misc", reason = "may be removed or relocated")] pub fn to_str_hex(num: f64) -> String { let (r, _) = strconv::float_to_str_common( - num, 16u, true, SignNeg, DigAll, ExpNone, false); + num, 16, true, SignNeg, DigAll, ExpNone, false); r } @@ -404,7 +404,7 @@ pub fn to_str_hex(num: f64) -> String { /// * radix - The base to use #[inline] #[unstable(feature = "std_misc", reason = "may be removed or relocated")] -pub fn to_str_radix_special(num: f64, rdx: uint) -> (String, bool) { +pub fn to_str_radix_special(num: f64, rdx: u32) -> (String, bool) { strconv::float_to_str_common(num, rdx, true, SignNeg, DigAll, ExpNone, false) } @@ -419,7 +419,7 @@ pub fn to_str_radix_special(num: f64, rdx: uint) -> (String, bool) { #[unstable(feature = "std_misc", reason = "may be removed or relocated")] pub fn to_str_exact(num: f64, dig: uint) -> String { let (r, _) = strconv::float_to_str_common( - num, 10u, true, SignNeg, DigExact(dig), ExpNone, false); + num, 10, true, SignNeg, DigExact(dig), ExpNone, false); r } @@ -434,7 +434,7 @@ pub fn to_str_exact(num: f64, dig: uint) -> String { #[unstable(feature = "std_misc", reason = "may be removed or relocated")] pub fn to_str_digits(num: f64, dig: uint) -> String { let (r, _) = strconv::float_to_str_common( - num, 10u, true, SignNeg, DigMax(dig), ExpNone, false); + num, 10, true, SignNeg, DigMax(dig), ExpNone, false); r } @@ -450,7 +450,7 @@ pub fn to_str_digits(num: f64, dig: uint) -> String { #[unstable(feature = "std_misc", reason = "may be removed or relocated")] pub fn to_str_exp_exact(num: f64, dig: uint, upper: bool) -> String { let (r, _) = strconv::float_to_str_common( - num, 10u, true, SignNeg, DigExact(dig), ExpDec, upper); + num, 10, true, SignNeg, DigExact(dig), ExpDec, upper); r } @@ -466,7 +466,7 @@ pub fn to_str_exp_exact(num: f64, dig: uint, upper: bool) -> String { #[unstable(feature = "std_misc", reason = "may be removed or relocated")] pub fn to_str_exp_digits(num: f64, dig: uint, upper: bool) -> String { let (r, _) = strconv::float_to_str_common( - num, 10u, true, SignNeg, DigMax(dig), ExpDec, upper); + num, 10, true, SignNeg, DigMax(dig), ExpDec, upper); r } diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index 4ae7d3437fd..cf5e1eb0eb7 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -182,7 +182,7 @@ fn int_to_str_bytes_common(num: T, radix: uint, sign: SignFormat, mut f: F /// - Panics if `radix` > 25 and `exp_format` is `ExpBin` due to conflict /// between digit and exponent sign `'p'`. pub fn float_to_str_bytes_common( - num: T, radix: uint, negative_zero: bool, + num: T, radix: u32, negative_zero: bool, sign: SignFormat, digits: SignificantDigits, exp_format: ExponentFormat, exp_upper: bool ) -> (Vec, bool) { assert!(2 <= radix && radix <= 36); @@ -253,7 +253,7 @@ pub fn float_to_str_bytes_common( deccum = deccum / radix_gen; deccum = deccum.trunc(); - buf.push(char::from_digit(current_digit.to_int().unwrap() as uint, radix) + buf.push(char::from_digit(current_digit.to_int().unwrap() as u32, radix) .unwrap() as u8); // No more digits to calculate for the non-fractional part -> break @@ -310,7 +310,7 @@ pub fn float_to_str_bytes_common( let current_digit = deccum.trunc().abs(); buf.push(char::from_digit( - current_digit.to_int().unwrap() as uint, radix).unwrap() as u8); + current_digit.to_int().unwrap() as u32, radix).unwrap() as u8); // Decrease the deccumulator one fractional digit at a time deccum = deccum.fract(); @@ -324,7 +324,7 @@ pub fn float_to_str_bytes_common( let ascii2value = |chr: u8| { (chr as char).to_digit(radix).unwrap() }; - let value2ascii = |val: uint| { + let value2ascii = |val: u32| { char::from_digit(val, radix).unwrap() as u8 }; @@ -412,7 +412,7 @@ pub fn float_to_str_bytes_common( /// `to_str_bytes_common()`, for details see there. #[inline] pub fn float_to_str_common( - num: T, radix: uint, negative_zero: bool, + num: T, radix: u32, negative_zero: bool, sign: SignFormat, digits: SignificantDigits, exp_format: ExponentFormat, exp_capital: bool ) -> (String, bool) { let (bytes, special) = float_to_str_bytes_common(num, radix, @@ -422,8 +422,8 @@ pub fn float_to_str_common( // Some constants for from_str_bytes_common's input validation, // they define minimum radix values for which the character is a valid digit. -static DIGIT_P_RADIX: uint = ('p' as uint) - ('a' as uint) + 11u; -static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11u; +static DIGIT_P_RADIX: u32 = ('p' as u32) - ('a' as u32) + 11; +static DIGIT_E_RADIX: u32 = ('e' as u32) - ('a' as u32) + 11; #[cfg(test)] mod tests { diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index ecc39925a40..cfd80b6755c 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -645,7 +645,7 @@ impl<'a> StringReader<'a> { /// Scan through any digits (base `radix`) or underscores, and return how /// many digits there were. - fn scan_digits(&mut self, radix: usize) -> usize { + fn scan_digits(&mut self, radix: u32) -> usize { let mut len = 0; loop { let c = self.curr; diff --git a/src/libterm/terminfo/parm.rs b/src/libterm/terminfo/parm.rs index 016dc84b23b..82b5ec11d95 100644 --- a/src/libterm/terminfo/parm.rs +++ b/src/libterm/terminfo/parm.rs @@ -297,7 +297,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables) PushParam => { // params are 1-indexed stack.push(mparams[match cur.to_digit(10) { - Some(d) => d - 1, + Some(d) => d as usize - 1, None => return Err("bad param number".to_string()) }].clone()); }, diff --git a/src/test/run-pass/exponential-notation.rs b/src/test/run-pass/exponential-notation.rs index 1fb434f7d76..bfe22712de8 100644 --- a/src/test/run-pass/exponential-notation.rs +++ b/src/test/run-pass/exponential-notation.rs @@ -19,18 +19,18 @@ macro_rules! t { pub fn main() { // Basic usage - t!(to_string(1.2345678e-5f64, 10u, true, SignNeg, DigMax(6), ExpDec, false), + t!(to_string(1.2345678e-5f64, 10, true, SignNeg, DigMax(6), ExpDec, false), "1.234568e-5"); // Hexadecimal output - t!(to_string(7.281738281250e+01f64, 16u, true, SignAll, DigMax(6), ExpBin, false), + t!(to_string(7.281738281250e+01f64, 16, true, SignAll, DigMax(6), ExpBin, false), "+1.2345p+6"); - t!(to_string(-1.777768135071e-02f64, 16u, true, SignAll, DigMax(6), ExpBin, false), + t!(to_string(-1.777768135071e-02f64, 16, true, SignAll, DigMax(6), ExpBin, false), "-1.2345p-6"); // Some denormals - t!(to_string(4.9406564584124654e-324f64, 10u, true, SignNeg, DigMax(6), ExpBin, false), + t!(to_string(4.9406564584124654e-324f64, 10, true, SignNeg, DigMax(6), ExpBin, false), "1p-1074"); - t!(to_string(2.2250738585072009e-308f64, 10u, true, SignNeg, DigMax(6), ExpBin, false), + t!(to_string(2.2250738585072009e-308f64, 10, true, SignNeg, DigMax(6), ExpBin, false), "1p-1022"); } -- cgit 1.4.1-3-g733a5 From f0f8be2a2e0aab2efef42208e19886790a0742f5 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Sun, 15 Feb 2015 19:07:14 +0530 Subject: Fix rollup (remove slicing_syntax) --- src/compiletest/compiletest.rs | 2 +- src/libcollections/lib.rs | 1 - src/libcollections/slice.rs | 1 - src/libcore/lib.rs | 2 +- src/libcoretest/lib.rs | 2 +- src/libfmt_macros/lib.rs | 1 - src/libgetopts/lib.rs | 1 - src/libgraphviz/lib.rs | 1 - src/liblog/lib.rs | 1 - src/librbml/lib.rs | 1 - src/librustc/lib.rs | 2 +- src/librustc_driver/lib.rs | 2 +- src/librustc_resolve/lib.rs | 1 - src/librustc_trans/lib.rs | 2 +- src/librustc_typeck/lib.rs | 2 +- src/librustdoc/lib.rs | 1 - src/libserialize/lib.rs | 1 - src/libstd/old_io/net/udp.rs | 1 - src/libsyntax/lib.rs | 1 - src/libterm/lib.rs | 1 - src/libtest/lib.rs | 2 +- src/libunicode/lib.rs | 1 - src/rustbook/main.rs | 2 +- src/test/run-pass/ranges-precedence.rs | 1 - 24 files changed, 9 insertions(+), 24 deletions(-) (limited to 'src/libsyntax') diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index 385f1b9e791..6b6251a96c9 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -16,7 +16,7 @@ #![feature(io)] #![feature(path)] #![feature(rustc_private)] -#![feature(slicing_syntax, unboxed_closures)] +#![feature(unboxed_closures)] #![feature(std_misc)] #![feature(test)] #![feature(unicode)] diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index 460c897b6ad..8325e7247d5 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -27,7 +27,6 @@ #![feature(box_patterns)] #![feature(core)] #![feature(hash)] -#![feature(slicing_syntax)] #![feature(staged_api)] #![feature(unboxed_closures)] #![feature(unicode)] diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index b3f398b9cdf..924589eb44c 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -52,7 +52,6 @@ //! interval `[a, b)`: //! //! ```rust -//! #![feature(slicing_syntax)] //! fn main() { //! let numbers = [0, 1, 2]; //! let last_numbers = &numbers[1..3]; diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index a122bcb2c7a..7243bd4f0cb 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -64,7 +64,7 @@ #![feature(int_uint)] #![feature(intrinsics, lang_items)] #![feature(on_unimplemented)] -#![feature(simd, unsafe_destructor, slicing_syntax)] +#![feature(simd, unsafe_destructor)] #![feature(staged_api)] #![feature(unboxed_closures)] diff --git a/src/libcoretest/lib.rs b/src/libcoretest/lib.rs index 50066ab07f5..2dfd81f32c2 100644 --- a/src/libcoretest/lib.rs +++ b/src/libcoretest/lib.rs @@ -11,7 +11,7 @@ #![feature(box_syntax)] #![feature(int_uint)] #![feature(unboxed_closures)] -#![feature(unsafe_destructor, slicing_syntax)] +#![feature(unsafe_destructor)] #![allow(deprecated)] // rand extern crate core; diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index baad31a61e1..1c7e97d784c 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -25,7 +25,6 @@ html_playground_url = "http://play.rust-lang.org/")] #![feature(int_uint)] -#![feature(slicing_syntax)] #![feature(staged_api)] #![feature(unicode)] diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index a3cae259fd3..ca184fb8736 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -91,7 +91,6 @@ #![deny(missing_docs)] #![feature(collections)] #![feature(int_uint)] -#![feature(slicing_syntax)] #![feature(staged_api)] #![cfg_attr(test, feature(rustc_private))] diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index 2d94ddaef18..a1a271bc5ab 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -273,7 +273,6 @@ #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/")] -#![feature(slicing_syntax)] #![feature(int_uint)] #![feature(collections)] #![feature(core)] diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index 1fedf49738c..5edb4a96a7d 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -168,7 +168,6 @@ #![deny(missing_docs)] #![feature(staged_api)] -#![feature(slicing_syntax)] #![feature(box_syntax)] #![feature(int_uint)] #![feature(core)] diff --git a/src/librbml/lib.rs b/src/librbml/lib.rs index 20af4dadfca..154dbbdb750 100644 --- a/src/librbml/lib.rs +++ b/src/librbml/lib.rs @@ -30,7 +30,6 @@ #![feature(int_uint)] #![feature(io)] #![feature(rustc_private)] -#![feature(slicing_syntax)] #![feature(staged_api)] extern crate serialize; diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index a4c4ea54386..f060d464e41 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -36,7 +36,7 @@ #![feature(quote)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] -#![feature(slicing_syntax, unsafe_destructor)] +#![feature(unsafe_destructor)] #![feature(staged_api)] #![feature(std_misc)] #![feature(unicode)] diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 50a68e8f1e3..9b8ca398b12 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -35,7 +35,7 @@ #![feature(quote)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] -#![feature(slicing_syntax, unsafe_destructor)] +#![feature(unsafe_destructor)] #![feature(staged_api)] #![feature(std_misc)] #![feature(unicode)] diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 848c3557b1b..874c8f2a940 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -24,7 +24,6 @@ #![feature(int_uint)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] -#![feature(slicing_syntax)] #![feature(staged_api)] #![feature(std_misc)] diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index c4d1416d975..21557379e3a 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -37,7 +37,7 @@ #![feature(quote)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] -#![feature(slicing_syntax, unsafe_destructor)] +#![feature(unsafe_destructor)] #![feature(staged_api)] #![feature(std_misc)] #![feature(unicode)] diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index ccfadaba244..7498dc8179d 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -83,7 +83,7 @@ This API is completely unstable and subject to change. #![feature(quote)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] -#![feature(slicing_syntax, unsafe_destructor)] +#![feature(unsafe_destructor)] #![feature(staged_api)] #[macro_use] extern crate log; diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 9d45caf7669..b09c3f730fc 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -30,7 +30,6 @@ #![feature(os)] #![feature(path)] #![feature(rustc_private)] -#![feature(slicing_syntax)] #![feature(staged_api)] #![feature(std_misc)] #![feature(test)] diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index 4579d1f19d3..6cada2e5614 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -33,7 +33,6 @@ Core encoding and decoding interfaces. #![feature(path)] #![feature(hash)] #![feature(rustc_private)] -#![feature(slicing_syntax)] #![feature(staged_api)] #![feature(std_misc)] #![feature(unicode)] diff --git a/src/libstd/old_io/net/udp.rs b/src/libstd/old_io/net/udp.rs index 5f1089bc63b..8dc19047de0 100644 --- a/src/libstd/old_io/net/udp.rs +++ b/src/libstd/old_io/net/udp.rs @@ -32,7 +32,6 @@ use sys_common; /// /// ```rust,no_run /// # #![allow(unused_must_use)] -/// #![feature(slicing_syntax)] /// /// use std::old_io::net::udp::UdpSocket; /// use std::old_io::net::ip::{Ipv4Addr, SocketAddr}; diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 951e4dcf792..f4b0c867f42 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -35,7 +35,6 @@ #![feature(path)] #![feature(quote, unsafe_destructor)] #![feature(rustc_private)] -#![feature(slicing_syntax)] #![feature(staged_api)] #![feature(std_misc)] #![feature(unicode)] diff --git a/src/libterm/lib.rs b/src/libterm/lib.rs index 1bb038603c3..c4b3d2813af 100644 --- a/src/libterm/lib.rs +++ b/src/libterm/lib.rs @@ -57,7 +57,6 @@ #![feature(io)] #![feature(path)] #![feature(rustc_private)] -#![feature(slicing_syntax)] #![feature(staged_api)] #![feature(std_misc)] #![feature(unicode)] diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index cc468df87f3..860ce209d45 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -32,7 +32,7 @@ html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/")] -#![feature(asm, slicing_syntax)] +#![feature(asm)] #![feature(box_syntax)] #![feature(collections)] #![feature(core)] diff --git a/src/libunicode/lib.rs b/src/libunicode/lib.rs index 977cb783344..89b310d4949 100644 --- a/src/libunicode/lib.rs +++ b/src/libunicode/lib.rs @@ -31,7 +31,6 @@ html_playground_url = "http://play.rust-lang.org/")] #![feature(no_std)] #![no_std] -#![feature(slicing_syntax)] #![feature(core)] extern crate core; diff --git a/src/rustbook/main.rs b/src/rustbook/main.rs index 3e571bad09c..b29538ad620 100644 --- a/src/rustbook/main.rs +++ b/src/rustbook/main.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(slicing_syntax, box_syntax)] +#![feature(box_syntax)] #![feature(collections)] #![feature(core)] #![feature(io)] diff --git a/src/test/run-pass/ranges-precedence.rs b/src/test/run-pass/ranges-precedence.rs index cd490948516..db414abb7ff 100644 --- a/src/test/run-pass/ranges-precedence.rs +++ b/src/test/run-pass/ranges-precedence.rs @@ -10,7 +10,6 @@ // Test that the precedence of ranges is correct -#![feature(slicing_syntax)] struct Foo { foo: uint, -- cgit 1.4.1-3-g733a5