From 14d476ecbb502d2d085c101b0c41e8e51ca5b4cf Mon Sep 17 00:00:00 2001 From: Carol Nichols Date: Sat, 9 May 2015 13:03:16 -0400 Subject: [PATCH 01/11] Remove auxiliary files not used since 812637e --- src/test/auxiliary/crateresolve3-1.rs | 15 -------- src/test/auxiliary/crateresolve3-2.rs | 15 -------- src/test/auxiliary/crateresolve5-1.rs | 34 ------------------- src/test/auxiliary/crateresolve5-2.rs | 33 ------------------ src/test/auxiliary/crateresolve7x.rs | 23 ------------- src/test/auxiliary/crateresolve8-1.rs | 16 --------- src/test/auxiliary/crateresolve_calories-1.rs | 14 -------- src/test/auxiliary/crateresolve_calories-2.rs | 14 -------- 8 files changed, 164 deletions(-) delete mode 100644 src/test/auxiliary/crateresolve3-1.rs delete mode 100644 src/test/auxiliary/crateresolve3-2.rs delete mode 100644 src/test/auxiliary/crateresolve5-1.rs delete mode 100644 src/test/auxiliary/crateresolve5-2.rs delete mode 100644 src/test/auxiliary/crateresolve7x.rs delete mode 100644 src/test/auxiliary/crateresolve8-1.rs delete mode 100644 src/test/auxiliary/crateresolve_calories-1.rs delete mode 100644 src/test/auxiliary/crateresolve_calories-2.rs diff --git a/src/test/auxiliary/crateresolve3-1.rs b/src/test/auxiliary/crateresolve3-1.rs deleted file mode 100644 index 0e02a8d96a3b2..0000000000000 --- a/src/test/auxiliary/crateresolve3-1.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 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. - -#![crate_name="crateresolve3#0.1"] - -#![crate_type = "lib"] - -pub fn f() -> isize { 10 } diff --git a/src/test/auxiliary/crateresolve3-2.rs b/src/test/auxiliary/crateresolve3-2.rs deleted file mode 100644 index 6a11465b27ca0..0000000000000 --- a/src/test/auxiliary/crateresolve3-2.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 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. - -#![crate_name="crateresolve3#0.2"] - -#![crate_type = "lib"] - -pub fn g() -> isize { 20 } diff --git a/src/test/auxiliary/crateresolve5-1.rs b/src/test/auxiliary/crateresolve5-1.rs deleted file mode 100644 index eaec37ed417d0..0000000000000 --- a/src/test/auxiliary/crateresolve5-1.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2012 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. - -#![crate_name="crateresolve5#0.1"] - -#![crate_type = "lib"] - -pub struct NameVal { pub name: String, pub val: isize } - -pub fn struct_nameval() -> NameVal { - NameVal { name: "crateresolve5".to_string(), val: 10 } -} - -pub enum e { - e_val -} - -pub fn nominal() -> e { e_val } - -pub fn nominal_eq(_e1: e, _e2: e) -> bool { true } - -impl PartialEq for e { - fn eq(&self, other: &e) -> bool { nominal_eq(*self, *other) } - fn ne(&self, other: &e) -> bool { !nominal_eq(*self, *other) } -} - -pub fn f() -> isize { 10 } diff --git a/src/test/auxiliary/crateresolve5-2.rs b/src/test/auxiliary/crateresolve5-2.rs deleted file mode 100644 index 14d28c709cdb5..0000000000000 --- a/src/test/auxiliary/crateresolve5-2.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2012 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. - -#![crate_name="crateresolve5#0.2"] - -#![crate_type = "lib"] - -pub struct NameVal { pub name: String, pub val: isize } -pub fn struct_nameval() -> NameVal { - NameVal { name: "crateresolve5".to_string(), val: 10 } -} - -pub enum e { - e_val -} - -impl PartialEq for e { - fn eq(&self, other: &e) -> bool { !nominal_neq(*self, *other) } - fn ne(&self, other: &e) -> bool { nominal_neq(*self, *other) } -} - -pub fn nominal() -> e { e_val } - -pub fn nominal_neq(_e1: e, _e2: e) -> bool { false } - -pub fn f() -> isize { 20 } diff --git a/src/test/auxiliary/crateresolve7x.rs b/src/test/auxiliary/crateresolve7x.rs deleted file mode 100644 index c05d292eaea47..0000000000000 --- a/src/test/auxiliary/crateresolve7x.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012-2014 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. - -// aux-build:crateresolve_calories-1.rs -// aux-build:crateresolve_calories-2.rs - -// These both have the same version but differ in other metadata -pub mod a { - extern crate cr_1 (name = "crateresolve_calories", vers = "0.1", calories="100"); - pub fn f() -> isize { cr_1::f() } -} - -pub mod b { - extern crate cr_2 (name = "crateresolve_calories", vers = "0.1", calories="200"); - pub fn f() -> isize { cr_2::f() } -} diff --git a/src/test/auxiliary/crateresolve8-1.rs b/src/test/auxiliary/crateresolve8-1.rs deleted file mode 100644 index bc2a2d83bfec1..0000000000000 --- a/src/test/auxiliary/crateresolve8-1.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 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. - -// default link meta for 'package_id' will be equal to filestem -#![crate_name="crateresolve8#0.1"] - -#![crate_type = "lib"] - -pub fn f() -> isize { 20 } diff --git a/src/test/auxiliary/crateresolve_calories-1.rs b/src/test/auxiliary/crateresolve_calories-1.rs deleted file mode 100644 index c1705d687abb0..0000000000000 --- a/src/test/auxiliary/crateresolve_calories-1.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 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. - -#![crate_name="crateresolve_calories#0.1"] -#![crate_type = "lib"] - -pub fn f() -> isize { 100 } diff --git a/src/test/auxiliary/crateresolve_calories-2.rs b/src/test/auxiliary/crateresolve_calories-2.rs deleted file mode 100644 index 2ae87daab4e29..0000000000000 --- a/src/test/auxiliary/crateresolve_calories-2.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 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. - -#![crate_name="crateresolve_calories#0.1"] -#![crate_type = "lib"] - -pub fn f() -> isize { 200 } From 7d5c248f31d1c6d0cb69d91be4d68e8740743287 Mon Sep 17 00:00:00 2001 From: Carol Nichols Date: Sat, 9 May 2015 13:05:16 -0400 Subject: [PATCH 02/11] Remove auxiliary file not used since 17da4c7 --- src/test/auxiliary/inherit_struct_lib.rs | 27 ------------------------ 1 file changed, 27 deletions(-) delete mode 100644 src/test/auxiliary/inherit_struct_lib.rs diff --git a/src/test/auxiliary/inherit_struct_lib.rs b/src/test/auxiliary/inherit_struct_lib.rs deleted file mode 100644 index 6f5ddfd37a5c2..0000000000000 --- a/src/test/auxiliary/inherit_struct_lib.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2014 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. - -// Test struct inheritance on structs from another crate. -#![feature(struct_inherit)] - -pub virtual struct S1 { - pub f1: isize, -} - -pub struct S2 : S1 { - pub f2: isize, -} - -pub fn test_s2(s2: S2) { - assert!(s2.f1 == 115); - assert!(s2.f2 == 113); -} - -pub static glob_s: S2 = S2 { f1: 32, f2: -45 }; From 757809c8d380886e5fa38d307ceeba3a3c74449e Mon Sep 17 00:00:00 2001 From: Carol Nichols Date: Sat, 9 May 2015 13:09:47 -0400 Subject: [PATCH 03/11] Remove auxiliary files not used since eb4d39e --- src/test/auxiliary/issue_2242_a.rs | 20 -------------------- src/test/auxiliary/issue_2242_c.rs | 20 -------------------- 2 files changed, 40 deletions(-) delete mode 100644 src/test/auxiliary/issue_2242_a.rs delete mode 100644 src/test/auxiliary/issue_2242_c.rs diff --git a/src/test/auxiliary/issue_2242_a.rs b/src/test/auxiliary/issue_2242_a.rs deleted file mode 100644 index 33b6d116c8a2d..0000000000000 --- a/src/test/auxiliary/issue_2242_a.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 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. - -#![crate_name="a#0.1"] -#![crate_type = "lib"] - -trait to_strz { - fn to_strz() -> String; -} - -impl to_strz for String { - fn to_strz() -> String { self.clone() } -} diff --git a/src/test/auxiliary/issue_2242_c.rs b/src/test/auxiliary/issue_2242_c.rs deleted file mode 100644 index 31d119b20beaa..0000000000000 --- a/src/test/auxiliary/issue_2242_c.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 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. - -#![crate_name="c#0.1"] -#![crate_type = "lib"] - -extern crate a; - -use a::to_strz; - -impl to_strz for bool { - fn to_strz() -> String { fmt!("%b", self) } -} From 978dc9f36a7ebd5c16100ab6cf6ee5f528ccf14a Mon Sep 17 00:00:00 2001 From: Rob Young Date: Sat, 9 May 2015 18:31:00 +0100 Subject: [PATCH 04/11] Minor docs fix Remove an rogue 'is' and fix some line wrapping. --- src/doc/trpl/guessing-game.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/doc/trpl/guessing-game.md b/src/doc/trpl/guessing-game.md index 57479a21e47a8..50767b603c46c 100644 --- a/src/doc/trpl/guessing-game.md +++ b/src/doc/trpl/guessing-game.md @@ -131,7 +131,9 @@ prints a [string][strings] to the screen. let mut guess = String::new(); ``` -Now we’re getting interesting! There’s a lot going on in this little line. The first thing to notice is that this is a [let statement][let], which is used to create ‘variable bindings’. They take this form: +Now we’re getting interesting! There’s a lot going on in this little line. +The first thing to notice is that this is a [let statement][let], which is +used to create ‘variable bindings’. They take this form: ```rust,ignore let foo = bar; @@ -171,7 +173,7 @@ bound to: `String::new()`. [string]: ../std/string/struct.String.html -The `::new()` syntax is uses `::` because this is an ‘associated function’ of +The `::new()` syntax uses `::` because this is an ‘associated function’ of a particular type. That is to say, it’s associated with `String` itself, rather than a particular instance of a `String`. Some languages call this a ‘static method’. From 87f0237d01936d291fc0f6499aff32726f0f6cb1 Mon Sep 17 00:00:00 2001 From: Nick Hamann Date: Thu, 7 May 2015 18:41:33 -0500 Subject: [PATCH 05/11] Add long diagnostics for E0062 and E0063 --- src/librustc_typeck/diagnostics.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index f00f0eea1f48d..cf229e5802729 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -34,6 +34,16 @@ let x_is_nonzero = x as bool; ``` "##, +E0062: r##" +This error indicates that during an attempt to build a struct or struct-like +enum variant, one of the fields was specified more than once. +"##, + +E0063: r##" +This error indicates that during an attempt to build a struct or struct-like +enum variant, one of the fields was not provided. +"##, + E0081: r##" Enum discriminants are used to differentiate enum variants stored in memory. This error indicates that the same value was used for two or more variants, @@ -136,8 +146,6 @@ register_diagnostics! { E0059, E0060, E0061, - E0062, - E0063, E0066, E0067, E0068, From f736468c06b7c2dfc30ab72741aa2c63385bf2f0 Mon Sep 17 00:00:00 2001 From: Nick Hamann Date: Thu, 7 May 2015 19:00:56 -0500 Subject: [PATCH 06/11] Add long diagnostic for E0137 --- src/librustc/diagnostics.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index ad37cc254d1bc..aaf615ee40409 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -271,6 +271,12 @@ fn main() { See also http://doc.rust-lang.org/book/unsafe.html "##, +E0137: r##" +This error indicates that the compiler found multiple functions with the +#[main] attribute. This is an error because there must be a unique entry point +into a Rust program. +"##, + E0152: r##" Lang items are already implemented in the standard library. Unless you are writing a free-standing application (e.g. a kernel), you do not need to provide @@ -800,7 +806,6 @@ register_diagnostics! { E0134, E0135, E0136, - E0137, E0138, E0139, E0261, // use of undeclared lifetime name From df64e05426d894241398b941f89001e81fd1521b Mon Sep 17 00:00:00 2001 From: Nick Hamann Date: Fri, 8 May 2015 13:13:43 -0500 Subject: [PATCH 07/11] Change E0062 and E0063 to say each field should be specified once. --- src/librustc_typeck/diagnostics.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index cf229e5802729..0e6386618f17b 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -36,12 +36,14 @@ let x_is_nonzero = x as bool; E0062: r##" This error indicates that during an attempt to build a struct or struct-like -enum variant, one of the fields was specified more than once. +enum variant, one of the fields was specified more than once. Each field should +be specified exactly one time. "##, E0063: r##" This error indicates that during an attempt to build a struct or struct-like -enum variant, one of the fields was not provided. +enum variant, one of the fields was not provided. Each field should be specified +exactly once. "##, E0081: r##" From a1898f890d907fadd45a1a927c8cd76dfb4ecdea Mon Sep 17 00:00:00 2001 From: Nick Hamann Date: Sat, 9 May 2015 14:50:28 -0500 Subject: [PATCH 08/11] Convert #[lang="..."] to #[lang = "..."] In my opinion this looks nicer, but also it matches the whitespace generally used for stability markers more closely. --- src/liballoc/heap.rs | 4 ++-- src/libcore/cell.rs | 2 +- src/libcore/cmp.rs | 4 ++-- src/libcore/iter.rs | 2 +- src/libcore/marker.rs | 12 +++++----- src/libcore/nonzero.rs | 2 +- src/libcore/ops.rs | 48 ++++++++++++++++++++-------------------- src/libcore/panicking.rs | 4 ++-- src/libcore/str/mod.rs | 2 +- src/libstd/rt/unwind.rs | 8 +++---- 10 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs index 86a04a0687a5b..83795a24c8160 100644 --- a/src/liballoc/heap.rs +++ b/src/liballoc/heap.rs @@ -95,7 +95,7 @@ pub const EMPTY: *mut () = 0x1 as *mut (); /// The allocator for unique pointers. #[cfg(not(test))] -#[lang="exchange_malloc"] +#[lang = "exchange_malloc"] #[inline] unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 { if size == 0 { @@ -108,7 +108,7 @@ unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 { } #[cfg(not(test))] -#[lang="exchange_free"] +#[lang = "exchange_free"] #[inline] unsafe fn exchange_free(ptr: *mut u8, old_size: usize, align: usize) { deallocate(ptr, old_size, align); diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 2412bdc220ece..bf5fdb973eb76 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -634,7 +634,7 @@ impl<'b, T: ?Sized> DerefMut for RefMut<'b, T> { /// /// **NOTE:** `UnsafeCell`'s fields are public to allow static initializers. It is not /// recommended to access its fields directly, `get` should be used instead. -#[lang="unsafe_cell"] +#[lang = "unsafe_cell"] #[stable(feature = "rust1", since = "1.0.0")] pub struct UnsafeCell { /// Wrapped value diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index dd59ceff577a8..dab549f784cf8 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -41,7 +41,7 @@ use option::Option::{self, Some, None}; /// PartialEq only requires the `eq` method to be implemented; `ne` is defined in terms of it by /// default. Any manual implementation of `ne` *must* respect the rule that `eq` is a strict /// inverse of `ne`; that is, `!(a == b)` if and only if `a != b`. -#[lang="eq"] +#[lang = "eq"] #[stable(feature = "rust1", since = "1.0.0")] pub trait PartialEq { /// This method tests for `self` and `other` values to be equal, and is used by `==`. @@ -222,7 +222,7 @@ impl PartialOrd for Ordering { /// However it remains possible to implement the others separately for types which do not have a /// total order. For example, for floating point numbers, `NaN < 0 == false` and `NaN >= 0 == /// false` (cf. IEEE 754-2008 section 5.11). -#[lang="ord"] +#[lang = "ord"] #[stable(feature = "rust1", since = "1.0.0")] pub trait PartialOrd: PartialEq { /// This method returns an ordering between `self` and `other` values if one exists. diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index de962b51e0590..e4d2ab198630a 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -82,7 +82,7 @@ fn _assert_is_object_safe(_: &Iterator) {} /// is returned. A concrete Iterator implementation may choose to behave however /// it wishes, either by returning `None` infinitely, or by doing something /// else. -#[lang="iterator"] +#[lang = "iterator"] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_on_unimplemented = "`{Self}` is not an iterator; maybe try calling \ `.iter()` or a similar method"] diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 1bd0b3638c683..3aaedaeb813e3 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -33,7 +33,7 @@ use hash::Hasher; /// Types able to be transferred across thread boundaries. #[stable(feature = "rust1", since = "1.0.0")] -#[lang="send"] +#[lang = "send"] #[rustc_on_unimplemented = "`{Self}` cannot be sent between threads safely"] pub unsafe trait Send { // empty. @@ -46,7 +46,7 @@ impl !Send for *mut T { } /// Types with a constant size known at compile-time. #[stable(feature = "rust1", since = "1.0.0")] -#[lang="sized"] +#[lang = "sized"] #[rustc_on_unimplemented = "`{Self}` does not have a constant size known at compile-time"] #[fundamental] // for Default, for example, which requires that `[T]: !Default` be evaluatable pub trait Sized { @@ -154,7 +154,7 @@ pub trait Sized { /// then it might be prudent to not implement `Copy`. This is because removing `Copy` is a breaking /// change: that second example would fail to compile if we made `Foo` non-`Copy`. #[stable(feature = "rust1", since = "1.0.0")] -#[lang="copy"] +#[lang = "copy"] pub trait Copy : Clone { // Empty. } @@ -201,7 +201,7 @@ pub trait Copy : Clone { /// reference; not doing this is undefined behaviour (for example, /// `transmute`-ing from `&T` to `&mut T` is illegal). #[stable(feature = "rust1", since = "1.0.0")] -#[lang="sync"] +#[lang = "sync"] #[rustc_on_unimplemented = "`{Self}` cannot be shared between threads safely"] pub unsafe trait Sync { // Empty @@ -217,7 +217,7 @@ impl !Sync for *mut T { } /// ensure that they are never copied, even if they lack a destructor. #[unstable(feature = "core", reason = "likely to change with new variance strategy")] -#[lang="no_copy_bound"] +#[lang = "no_copy_bound"] #[derive(Clone, PartialEq, Eq, PartialOrd, Ord)] pub struct NoCopy; @@ -359,7 +359,7 @@ macro_rules! impls{ /// better to use a reference type, like `PhantomData<&'a T>` /// (ideally) or `PhantomData<*const T>` (if no lifetime applies), so /// as not to indicate ownership. -#[lang="phantom_data"] +#[lang = "phantom_data"] #[stable(feature = "rust1", since = "1.0.0")] pub struct PhantomData; diff --git a/src/libcore/nonzero.rs b/src/libcore/nonzero.rs index 640703ca2f9c2..13b6468105dcf 100644 --- a/src/libcore/nonzero.rs +++ b/src/libcore/nonzero.rs @@ -31,7 +31,7 @@ unsafe impl Zeroable for u64 {} /// A wrapper type for raw pointers and integers that will never be /// NULL or 0 that might allow certain optimizations. -#[lang="non_zero"] +#[lang = "non_zero"] #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)] #[unstable(feature = "core")] pub struct NonZero(T); diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 8a4f603ec4720..55c4264b10c70 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -91,7 +91,7 @@ use fmt; /// let _x = HasDrop; /// } /// ``` -#[lang="drop"] +#[lang = "drop"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Drop { /// The `drop` method, called when the value goes out of scope. @@ -181,7 +181,7 @@ macro_rules! forward_ref_binop { /// Foo + Foo; /// } /// ``` -#[lang="add"] +#[lang = "add"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Add { /// The resulting type after applying the `+` operator @@ -235,7 +235,7 @@ add_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// Foo - Foo; /// } /// ``` -#[lang="sub"] +#[lang = "sub"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Sub { /// The resulting type after applying the `-` operator @@ -289,7 +289,7 @@ sub_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// Foo * Foo; /// } /// ``` -#[lang="mul"] +#[lang = "mul"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Mul { /// The resulting type after applying the `*` operator @@ -343,7 +343,7 @@ mul_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// Foo / Foo; /// } /// ``` -#[lang="div"] +#[lang = "div"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Div { /// The resulting type after applying the `/` operator @@ -397,7 +397,7 @@ div_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// Foo % Foo; /// } /// ``` -#[lang="rem"] +#[lang = "rem"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Rem { /// The resulting type after applying the `%` operator @@ -470,7 +470,7 @@ rem_float_impl! { f64, fmod } /// -Foo; /// } /// ``` -#[lang="neg"] +#[lang = "neg"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Neg { /// The resulting type after applying the `-` operator @@ -541,7 +541,7 @@ neg_impl_numeric! { isize i8 i16 i32 i64 f32 f64 } /// !Foo; /// } /// ``` -#[lang="not"] +#[lang = "not"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Not { /// The resulting type after applying the `!` operator @@ -595,7 +595,7 @@ not_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } /// Foo & Foo; /// } /// ``` -#[lang="bitand"] +#[lang = "bitand"] #[stable(feature = "rust1", since = "1.0.0")] pub trait BitAnd { /// The resulting type after applying the `&` operator @@ -649,7 +649,7 @@ bitand_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } /// Foo | Foo; /// } /// ``` -#[lang="bitor"] +#[lang = "bitor"] #[stable(feature = "rust1", since = "1.0.0")] pub trait BitOr { /// The resulting type after applying the `|` operator @@ -703,7 +703,7 @@ bitor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } /// Foo ^ Foo; /// } /// ``` -#[lang="bitxor"] +#[lang = "bitxor"] #[stable(feature = "rust1", since = "1.0.0")] pub trait BitXor { /// The resulting type after applying the `^` operator @@ -757,7 +757,7 @@ bitxor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } /// Foo << Foo; /// } /// ``` -#[lang="shl"] +#[lang = "shl"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Shl { /// The resulting type after applying the `<<` operator @@ -829,7 +829,7 @@ shl_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } /// Foo >> Foo; /// } /// ``` -#[lang="shr"] +#[lang = "shr"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Shr { /// The resulting type after applying the `>>` operator @@ -902,7 +902,7 @@ shr_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } /// Foo[Bar]; /// } /// ``` -#[lang="index"] +#[lang = "index"] #[rustc_on_unimplemented = "the type `{Self}` cannot be indexed by `{Idx}`"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Index { @@ -949,7 +949,7 @@ pub trait Index { /// &mut Foo[Bar]; /// } /// ``` -#[lang="index_mut"] +#[lang = "index_mut"] #[rustc_on_unimplemented = "the type `{Self}` cannot be mutably indexed by `{Idx}`"] #[stable(feature = "rust1", since = "1.0.0")] pub trait IndexMut: Index { @@ -960,7 +960,7 @@ pub trait IndexMut: Index { /// An unbounded range. #[derive(Copy, Clone, PartialEq, Eq)] -#[lang="range_full"] +#[lang = "range_full"] #[stable(feature = "rust1", since = "1.0.0")] pub struct RangeFull; @@ -973,7 +973,7 @@ impl fmt::Debug for RangeFull { /// A (half-open) range which is bounded at both ends. #[derive(Clone, PartialEq, Eq)] -#[lang="range"] +#[lang = "range"] #[stable(feature = "rust1", since = "1.0.0")] pub struct Range { /// The lower bound of the range (inclusive). @@ -993,7 +993,7 @@ impl fmt::Debug for Range { /// A range which is only bounded below. #[derive(Clone, PartialEq, Eq)] -#[lang="range_from"] +#[lang = "range_from"] #[stable(feature = "rust1", since = "1.0.0")] pub struct RangeFrom { /// The lower bound of the range (inclusive). @@ -1010,7 +1010,7 @@ impl fmt::Debug for RangeFrom { /// A range which is only bounded above. #[derive(Copy, Clone, PartialEq, Eq)] -#[lang="range_to"] +#[lang = "range_to"] #[stable(feature = "rust1", since = "1.0.0")] pub struct RangeTo { /// The upper bound of the range (exclusive). @@ -1053,7 +1053,7 @@ impl fmt::Debug for RangeTo { /// assert_eq!('a', *x); /// } /// ``` -#[lang="deref"] +#[lang = "deref"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Deref { /// The resulting type after dereferencing @@ -1114,7 +1114,7 @@ impl<'a, T: ?Sized> Deref for &'a mut T { /// assert_eq!('b', *x); /// } /// ``` -#[lang="deref_mut"] +#[lang = "deref_mut"] #[stable(feature = "rust1", since = "1.0.0")] pub trait DerefMut: Deref { /// The method called to mutably dereference a value @@ -1128,7 +1128,7 @@ impl<'a, T: ?Sized> DerefMut for &'a mut T { } /// A version of the call operator that takes an immutable receiver. -#[lang="fn"] +#[lang = "fn"] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_paren_sugar] #[fundamental] // so that regex can rely that `&str: !FnMut` @@ -1138,7 +1138,7 @@ pub trait Fn : FnMut { } /// A version of the call operator that takes a mutable receiver. -#[lang="fn_mut"] +#[lang = "fn_mut"] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_paren_sugar] #[fundamental] // so that regex can rely that `&str: !FnMut` @@ -1148,7 +1148,7 @@ pub trait FnMut : FnOnce { } /// A version of the call operator that takes a by-value receiver. -#[lang="fn_once"] +#[lang = "fn_once"] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_paren_sugar] #[fundamental] // so that regex can rely that `&str: !FnMut` diff --git a/src/libcore/panicking.rs b/src/libcore/panicking.rs index 0b8a52329dce6..635150c088688 100644 --- a/src/libcore/panicking.rs +++ b/src/libcore/panicking.rs @@ -33,7 +33,7 @@ use fmt; #[cold] #[inline(never)] // this is the slow path, always -#[lang="panic"] +#[lang = "panic"] pub fn panic(expr_file_line: &(&'static str, &'static str, u32)) -> ! { // Use Arguments::new_v1 instead of format_args!("{}", expr) to potentially // reduce size overhead. The format_args! macro uses str's Display trait to @@ -46,7 +46,7 @@ pub fn panic(expr_file_line: &(&'static str, &'static str, u32)) -> ! { } #[cold] #[inline(never)] -#[lang="panic_bounds_check"] +#[lang = "panic_bounds_check"] fn panic_bounds_check(file_line: &(&'static str, u32), index: usize, len: usize) -> ! { panic_fmt(format_args!("index out of bounds: the len is {} but the index is {}", diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index c10e1443cfcbe..4d39607b16e92 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -1185,7 +1185,7 @@ fn eq_slice_(a: &str, b: &str) -> bool { /// Bytewise slice equality /// NOTE: This function is (ab)used in rustc::middle::trans::_match /// to compare &[u8] byte slices that are not necessarily valid UTF-8. -#[lang="str_eq"] +#[lang = "str_eq"] #[inline] fn eq_slice(a: &str, b: &str) -> bool { eq_slice_(a, b) diff --git a/src/libstd/rt/unwind.rs b/src/libstd/rt/unwind.rs index 8e55ff0b76c50..b24099505ed89 100644 --- a/src/libstd/rt/unwind.rs +++ b/src/libstd/rt/unwind.rs @@ -238,7 +238,7 @@ pub mod eabi { -> uw::_Unwind_Reason_Code; } - #[lang="eh_personality"] + #[lang = "eh_personality"] #[no_mangle] // referenced from rust_try.ll #[allow(private_no_mangle_fns)] extern fn rust_eh_personality( @@ -292,7 +292,7 @@ pub mod eabi { -> uw::_Unwind_Reason_Code; } - #[lang="eh_personality"] + #[lang = "eh_personality"] #[no_mangle] // referenced from rust_try.ll pub extern "C" fn rust_eh_personality( version: c_int, @@ -345,7 +345,7 @@ pub mod eabi { -> uw::_Unwind_Reason_Code; } - #[lang="eh_personality"] + #[lang = "eh_personality"] #[no_mangle] // referenced from rust_try.ll #[allow(private_no_mangle_fns)] extern "C" fn rust_eh_personality( @@ -432,7 +432,7 @@ pub mod eabi { ) -> EXCEPTION_DISPOSITION; } - #[lang="eh_personality"] + #[lang = "eh_personality"] #[no_mangle] // referenced from rust_try.ll #[allow(private_no_mangle_fns)] extern "C" fn rust_eh_personality( From 7984074e25e2d4ac2b5bc125d44e38a280f964f9 Mon Sep 17 00:00:00 2001 From: Nick Hamann Date: Sat, 9 May 2015 16:08:02 -0500 Subject: [PATCH 09/11] Convert #[lang=".."] to #[lang = ".."] for docs too. --- src/doc/reference.md | 2 +- src/doc/trpl/lang-items.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/doc/reference.md b/src/doc/reference.md index e3e542efb6a43..16fdcfa301392 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -2028,7 +2028,7 @@ makes it possible to declare these operations. For example, the `str` module in the Rust standard library defines the string equality function: ```{.ignore} -#[lang="str_eq"] +#[lang = "str_eq"] pub fn eq_slice(a: &str, b: &str) -> bool { // details elided } diff --git a/src/doc/trpl/lang-items.md b/src/doc/trpl/lang-items.md index 5c27c03e8e0b2..4808ad6ff1feb 100644 --- a/src/doc/trpl/lang-items.md +++ b/src/doc/trpl/lang-items.md @@ -7,7 +7,7 @@ The `rustc` compiler has certain pluggable operations, that is, functionality that isn't hard-coded into the language, but is implemented in libraries, with a special marker to tell the compiler -it exists. The marker is the attribute `#[lang="..."]` and there are +it exists. The marker is the attribute `#[lang = "..."]` and there are various different values of `...`, i.e. various different 'lang items'. @@ -28,7 +28,7 @@ extern { #[lang = "owned_box"] pub struct Box(*mut T); -#[lang="exchange_malloc"] +#[lang = "exchange_malloc"] unsafe fn allocate(size: usize, _align: usize) -> *mut u8 { let p = libc::malloc(size as libc::size_t) as *mut u8; @@ -39,7 +39,7 @@ unsafe fn allocate(size: usize, _align: usize) -> *mut u8 { p } -#[lang="exchange_free"] +#[lang = "exchange_free"] unsafe fn deallocate(ptr: *mut u8, _size: usize, _align: usize) { libc::free(ptr as *mut libc::c_void) } From 8e8f8d9a5a35eb5875999efac7837956ed1b20da Mon Sep 17 00:00:00 2001 From: inrustwetrust Date: Sun, 10 May 2015 00:07:26 +0200 Subject: [PATCH 10/11] Upgraded warning for invalid crate_type attribute syntax to an error If the user intended to set the crate_type to "lib" but accidentally used incorrect syntax such as `#![crate_type(lib)]`, the compilation would fail with "main function not found". This made it hard to locate the source of the problem, since the failure would cause the warning about the incorrect attribute not to be shown. --- src/librustc_driver/driver.rs | 7 ++----- src/test/compile-fail/invalid_crate_type_syntax.rs | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 src/test/compile-fail/invalid_crate_type_syntax.rs diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 154e0a1f64460..a956b173f96c6 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -871,11 +871,8 @@ pub fn collect_crate_types(session: &Session, None } _ => { - session.add_lint(lint::builtin::UNKNOWN_CRATE_TYPES, - ast::CRATE_NODE_ID, - a.span, - "`crate_type` requires a \ - value".to_string()); + session.span_err(a.span, "`crate_type` requires a value"); + session.note("for example: `#![crate_type=\"lib\"]`"); None } } diff --git a/src/test/compile-fail/invalid_crate_type_syntax.rs b/src/test/compile-fail/invalid_crate_type_syntax.rs new file mode 100644 index 0000000000000..6d42515704ea1 --- /dev/null +++ b/src/test/compile-fail/invalid_crate_type_syntax.rs @@ -0,0 +1,14 @@ +// 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. + +// regression test for issue 16974 +#![crate_type(lib)] //~ ERROR `crate_type` requires a value + +fn my_lib_fn() {} From fa3fd813d644795063167440e6d8a22cdca44453 Mon Sep 17 00:00:00 2001 From: Isaac Ge Date: Sat, 9 May 2015 20:36:12 +0800 Subject: [PATCH 11/11] Update error-handling.md Fix two typos while `io::stdin().read_line()` returns `Result` actually Signed-off-by: acgtyrant --- src/doc/trpl/error-handling.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/trpl/error-handling.md b/src/doc/trpl/error-handling.md index e4809214bd48e..95b39a660636a 100644 --- a/src/doc/trpl/error-handling.md +++ b/src/doc/trpl/error-handling.md @@ -214,7 +214,7 @@ we can use the `unwrap()` method: io::stdin().read_line(&mut buffer).unwrap(); ``` -`unwrap()` will `panic!` if the `Option` is `None`. This basically says "Give +`unwrap()` will `panic!` if the `Result` is `Err`. This basically says "Give me the value, and if something goes wrong, just crash." This is less reliable than matching the error and attempting to recover, but is also significantly shorter. Sometimes, just crashing is appropriate.