Skip to content

Commit bb833ca

Browse files
committed
librustc: Stop parsing impl Type : Trait and fix several declarations that slipped through. r=tjc
1 parent 566bcf2 commit bb833ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+327
-424
lines changed

src/libcargo/cargo.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub struct Package {
7171
versions: ~[(~str, ~str)]
7272
}
7373

74-
pub impl Package : cmp::Ord {
74+
pub impl cmp::Ord for Package {
7575
pure fn lt(&self, other: &Package) -> bool {
7676
if (*self).name.lt(&(*other).name) { return true; }
7777
if (*other).name.lt(&(*self).name) { return false; }

src/libcore/at_vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ pub mod traits {
173173
use kinds::Copy;
174174
use ops::Add;
175175

176-
pub impl<T: Copy> @[T] : Add<&[const T],@[T]> {
176+
pub impl<T: Copy> Add<&[const T],@[T]> for @[T] {
177177
#[inline(always)]
178178
pure fn add(&self, rhs: & &self/[const T]) -> @[T] {
179179
append(*self, (*rhs))

src/libcore/num/f32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ impl num::One for f32 {
282282
static pure fn one() -> f32 { 1.0 }
283283
}
284284

285-
pub impl f32: NumCast {
285+
pub impl NumCast for f32 {
286286
/**
287287
* Cast `n` to an `f32`
288288
*/

src/libcore/num/f64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ impl cmp::Ord for f64 {
297297
pure fn gt(&self, other: &f64) -> bool { (*self) > (*other) }
298298
}
299299

300-
pub impl f64: NumCast {
300+
pub impl NumCast for f64 {
301301
/**
302302
* Cast `n` to an `f64`
303303
*/

src/libcore/num/float.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ impl num::One for float {
415415
static pure fn one() -> float { 1.0 }
416416
}
417417
418-
pub impl float: NumCast {
418+
pub impl NumCast for float {
419419
/**
420420
* Cast `n` to a `float`
421421
*/

src/libcore/num/int-template/i16.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ mod inst {
1717
pub const bits: uint = ::u16::bits;
1818
}
1919

20-
pub impl i16: NumCast {
20+
pub impl NumCast for i16 {
2121
/**
2222
* Cast `n` to a `i16`
2323
*/

src/libcore/num/int-template/i32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ mod inst {
1717
pub const bits: uint = ::u32::bits;
1818
}
1919

20-
pub impl i32: NumCast {
20+
pub impl NumCast for i32 {
2121
/**
2222
* Cast `n` to a `i32`
2323
*/

src/libcore/num/int-template/i64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ mod inst {
1717
pub const bits: uint = ::u64::bits;
1818
}
1919

20-
pub impl i64: NumCast {
20+
pub impl NumCast for i64 {
2121
/**
2222
* Cast `n` to a `i64`
2323
*/

src/libcore/num/int-template/i8.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ mod inst {
1717
pub const bits: uint = ::u8::bits;
1818
}
1919

20-
pub impl i8: NumCast {
20+
pub impl NumCast for i8 {
2121
/**
2222
* Cast `n` to a `i8`
2323
*/

src/libcore/num/int-template/int.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ mod inst {
5858
}
5959
}
6060

61-
pub impl int: NumCast {
61+
pub impl NumCast for int {
6262
/**
6363
* Cast `n` to a `int`
6464
*/

src/libcore/num/uint-template/u16.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ mod inst {
1919
pub const bits: uint = 16;
2020
}
2121

22-
pub impl u16: NumCast {
22+
pub impl NumCast for u16 {
2323
/**
2424
* Cast `n` to a `u16`
2525
*/

src/libcore/num/uint-template/u32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ mod inst {
1919
pub const bits: uint = 32;
2020
}
2121

22-
pub impl u32: NumCast {
22+
pub impl NumCast for u32 {
2323
/**
2424
* Cast `n` to a `u32`
2525
*/

src/libcore/num/uint-template/u64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ mod inst {
1919
pub const bits: uint = 64;
2020
}
2121

22-
pub impl u64: num::NumCast {
22+
pub impl NumCast for u64 {
2323
/**
2424
* Cast `n` to a `u64`
2525
*/

src/libcore/num/uint-template/u8.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ mod inst {
2626
pub pure fn is_ascii(x: T) -> bool { return 0 as T == x & 128 as T; }
2727
}
2828

29-
pub impl u8: NumCast {
29+
pub impl NumCast for u8 {
3030
/**
3131
* Cast `n` to a `u8`
3232
*/

src/libcore/num/uint-template/uint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ pub mod inst {
110110
return true;
111111
}
112112

113-
pub impl uint: iter::Times {
113+
pub impl iter::Times for uint {
114114
#[inline(always)]
115115
/**
116116
* A convenience form for basic iteration. Given a uint `x`,
@@ -209,7 +209,7 @@ pub mod inst {
209209
}
210210
}
211211

212-
pub impl uint: NumCast {
212+
pub impl NumCast for uint {
213213
/**
214214
* Cast `n` to a `uint`
215215
*/

src/libcore/pipes.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,11 +1211,11 @@ pub trait Select2<T: Owned, U: Owned> {
12111211
fn select() -> Either<T, U>;
12121212
}
12131213
1214-
impl<T: Owned, U: Owned,
1214+
impl<T: Owned,
1215+
U: Owned,
12151216
Left: Selectable GenericPort<T>,
12161217
Right: Selectable GenericPort<U>>
1217-
(Left, Right): Select2<T, U> {
1218-
1218+
Select2<T,U> for (Left, Right) {
12191219
fn select() -> Either<T, U> {
12201220
match self {
12211221
(ref lp, ref rp) => match select2i(lp, rp) {

src/libcore/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2328,7 +2328,7 @@ pub trait OwnedStr {
23282328
fn push_char(&mut self, c: char);
23292329
}
23302330

2331-
pub impl ~str : OwnedStr {
2331+
pub impl OwnedStr for ~str {
23322332
fn push_str(&mut self, v: &str) {
23332333
push_str(self, v);
23342334
}

src/libcore/to_bytes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ impl IterBytes for char {
170170
pub mod x32 {
171171
use to_bytes::{Cb, IterBytes};
172172

173-
pub impl uint: IterBytes {
173+
pub impl IterBytes for uint {
174174
#[inline(always)]
175175
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
176176
(*self as u32).iter_bytes(lsb0, f)
@@ -182,7 +182,7 @@ pub mod x32 {
182182
pub mod x64 {
183183
use to_bytes::{Cb, IterBytes};
184184

185-
pub impl uint: IterBytes {
185+
pub impl IterBytes for uint {
186186
#[inline(always)]
187187
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
188188
(*self as u64).iter_bytes(lsb0, f)

src/librustc/driver/driver.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ pub fn time<T>(do_it: bool, what: ~str, thunk: fn() -> T) -> T {
175175
rv
176176
}
177177

178+
#[deriving_eq]
178179
pub enum compile_upto {
179180
cu_parse,
180181
cu_expand,
@@ -183,13 +184,6 @@ pub enum compile_upto {
183184
cu_everything,
184185
}
185186

186-
pub impl compile_upto : cmp::Eq {
187-
pure fn eq(&self, other: &compile_upto) -> bool {
188-
((*self) as uint) == ((*other) as uint)
189-
}
190-
pure fn ne(&self, other: &compile_upto) -> bool { !(*self).eq(other) }
191-
}
192-
193187
pub fn compile_upto(sess: Session, cfg: ast::crate_cfg,
194188
input: input, upto: compile_upto,
195189
outputs: Option<output_filenames>)

src/librustc/driver/session.rs

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,12 @@ use syntax::parse::parse_sess;
2929
use syntax::{ast, codemap};
3030
use syntax;
3131

32+
#[deriving_eq]
3233
pub enum os { os_win32, os_macos, os_linux, os_android, os_freebsd, }
3334

34-
pub impl os : cmp::Eq {
35-
pure fn eq(&self, other: &os) -> bool {
36-
((*self) as uint) == ((*other) as uint)
37-
}
38-
pure fn ne(&self, other: &os) -> bool { !(*self).eq(other) }
39-
}
40-
35+
#[deriving_eq]
4136
pub enum arch { arch_x86, arch_x86_64, arch_arm, }
4237

43-
pub impl arch : cmp::Eq {
44-
pure fn eq(&self, other: &arch) -> bool {
45-
((*self) as uint) == ((*other) as uint)
46-
}
47-
pure fn ne(&self, other: &arch) -> bool { !(*self).eq(other) }
48-
}
49-
5038
pub enum crate_type { bin_crate, lib_crate, unknown_crate, }
5139

5240
pub type config =
@@ -117,20 +105,14 @@ pub fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
117105
]
118106
}
119107

108+
#[deriving_eq]
120109
pub enum OptLevel {
121110
No, // -O0
122111
Less, // -O1
123112
Default, // -O2
124113
Aggressive // -O3
125114
}
126115

127-
pub impl OptLevel : cmp::Eq {
128-
pure fn eq(&self, other: &OptLevel) -> bool {
129-
((*self) as uint) == ((*other) as uint)
130-
}
131-
pure fn ne(&self, other: &OptLevel) -> bool { !(*self).eq(other) }
132-
}
133-
134116
pub type options =
135117
// The crate config requested for the session, which may be combined
136118
// with additional crate configurations during the compile process

src/librustc/lib/llvm.rs

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ pub enum RealPredicate {
132132

133133
// enum for the LLVM TypeKind type - must stay in sync with the def of
134134
// LLVMTypeKind in llvm/include/llvm-c/Core.h
135+
#[deriving_eq]
135136
pub enum TypeKind {
136137
Void = 0,
137138
Half = 1,
@@ -151,46 +152,6 @@ pub enum TypeKind {
151152
X86_MMX = 15
152153
}
153154

154-
pub impl TypeKind : cmp::Eq {
155-
pure fn eq(&self, other: &TypeKind) -> bool {
156-
match ((*self), (*other)) {
157-
(Void, Void) => true,
158-
(Half, Half) => true,
159-
(Float, Float) => true,
160-
(Double, Double) => true,
161-
(X86_FP80, X86_FP80) => true,
162-
(FP128, FP128) => true,
163-
(PPC_FP128, PPC_FP128) => true,
164-
(Label, Label) => true,
165-
(Integer, Integer) => true,
166-
(Function, Function) => true,
167-
(Struct, Struct) => true,
168-
(Array, Array) => true,
169-
(Pointer, Pointer) => true,
170-
(Vector, Vector) => true,
171-
(Metadata, Metadata) => true,
172-
(X86_MMX, X86_MMX) => true,
173-
(Void, _) => false,
174-
(Half, _) => false,
175-
(Float, _) => false,
176-
(Double, _) => false,
177-
(X86_FP80, _) => false,
178-
(FP128, _) => false,
179-
(PPC_FP128, _) => false,
180-
(Label, _) => false,
181-
(Integer, _) => false,
182-
(Function, _) => false,
183-
(Struct, _) => false,
184-
(Array, _) => false,
185-
(Pointer, _) => false,
186-
(Vector, _) => false,
187-
(Metadata, _) => false,
188-
(X86_MMX, _) => false,
189-
}
190-
}
191-
pure fn ne(&self, other: &TypeKind) -> bool { !(*self).eq(other) }
192-
}
193-
194155
pub enum AtomicBinOp {
195156
Xchg = 0,
196157
Add = 1,

src/librustc/middle/borrowck/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ impl LoanKind {
449449

450450
/// Creates and returns a new root_map
451451
452-
pub impl root_map_key : to_bytes::IterBytes {
452+
pub impl to_bytes::IterBytes for root_map_key {
453453
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
454454
to_bytes::iter_bytes_2(&self.id, &self.derefs, lsb0, f);
455455
}

src/librustc/middle/mem_categorization.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,12 @@ pub trait ast_node {
281281
fn span() -> span;
282282
}
283283

284-
pub impl @ast::expr: ast_node {
284+
pub impl ast_node for @ast::expr {
285285
fn id() -> ast::node_id { self.id }
286286
fn span() -> span { self.span }
287287
}
288288

289-
pub impl @ast::pat: ast_node {
289+
pub impl ast_node for @ast::pat {
290290
fn id() -> ast::node_id { self.id }
291291
fn span() -> span { self.span }
292292
}
@@ -295,7 +295,7 @@ pub trait get_type_for_node {
295295
fn ty<N: ast_node>(node: N) -> ty::t;
296296
}
297297

298-
pub impl ty::ctxt: get_type_for_node {
298+
pub impl get_type_for_node for ty::ctxt {
299299
fn ty<N: ast_node>(node: N) -> ty::t {
300300
ty::node_id_to_type(self, node.id())
301301
}

src/librustc/middle/trans/base.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub trait get_insn_ctxt {
108108
fn insn_ctxt(s: &str) -> icx_popper;
109109
}
110110

111-
pub impl @crate_ctxt: get_insn_ctxt {
111+
pub impl get_insn_ctxt for @crate_ctxt {
112112
fn insn_ctxt(s: &str) -> icx_popper {
113113
debug!("new insn_ctxt: %s", s);
114114
if self.sess.count_llvm_insns() {
@@ -118,13 +118,13 @@ pub impl @crate_ctxt: get_insn_ctxt {
118118
}
119119
}
120120

121-
pub impl block: get_insn_ctxt {
121+
pub impl get_insn_ctxt for block {
122122
fn insn_ctxt(s: &str) -> icx_popper {
123123
self.ccx().insn_ctxt(s)
124124
}
125125
}
126126

127-
pub impl fn_ctxt: get_insn_ctxt {
127+
pub impl get_insn_ctxt for fn_ctxt {
128128
fn insn_ctxt(s: &str) -> icx_popper {
129129
self.ccx.insn_ctxt(s)
130130
}

0 commit comments

Comments
 (0)