Skip to content

Commit d1d50eb

Browse files
committed
---
yaml --- r: 64294 b: refs/heads/snap-stage3 c: 8d0feb5 h: refs/heads/master v: v3
1 parent 960458d commit d1d50eb

File tree

7 files changed

+74
-33
lines changed

7 files changed

+74
-33
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: e56b3691c87c24fc335fa8a293f1bf2e13a01ad9
4+
refs/heads/snap-stage3: 8d0feb58e7f5ae67546db9c3cd7fdf4ab792d839
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/librustc/middle/trans/glue.rs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ pub fn lazily_emit_tydesc_glue(ccx: @mut CrateContext,
230230
field: uint,
231231
ti: @mut tydesc_info) {
232232
let _icx = push_ctxt("lazily_emit_tydesc_glue");
233-
let llfnty = Type::glue_fn(type_of::type_of(ccx, ti.ty).ptr_to());
233+
let llfnty = Type::glue_fn();
234234

235235
if lazily_emit_simplified_tydesc_glue(ccx, field, ti) {
236236
return;
@@ -323,20 +323,7 @@ pub fn call_tydesc_glue_full(bcx: block,
323323
}
324324
};
325325

326-
// When static type info is available, avoid casting parameter unless the
327-
// glue is using a simplified type, because the function already has the
328-
// right type. Otherwise cast to generic pointer.
329-
let llrawptr = if static_ti.is_none() || static_glue_fn.is_none() {
330-
PointerCast(bcx, v, Type::i8p())
331-
} else {
332-
let ty = static_ti.get().ty;
333-
let simpl = simplified_glue_type(ccx.tcx, field, ty);
334-
if simpl != ty {
335-
PointerCast(bcx, v, type_of(ccx, simpl).ptr_to())
336-
} else {
337-
v
338-
}
339-
};
326+
let llrawptr = PointerCast(bcx, v, Type::i8p());
340327

341328
let llfn = {
342329
match static_glue_fn {
@@ -722,14 +709,13 @@ pub fn make_generic_glue_inner(ccx: @mut CrateContext,
722709
// requirement since in many contexts glue is invoked indirectly and
723710
// the caller has no idea if it's dealing with something that can be
724711
// passed by value.
725-
//
726-
// llfn is expected be declared to take a parameter of the appropriate
727-
// type, so we don't need to explicitly cast the function parameter.
728712

729713
let bcx = top_scope_block(fcx, None);
730714
let lltop = bcx.llbb;
731715
let rawptr0_arg = fcx.arg_pos(0u);
732716
let llrawptr0 = unsafe { llvm::LLVMGetParam(llfn, rawptr0_arg as c_uint) };
717+
let llty = type_of(ccx, t);
718+
let llrawptr0 = PointerCast(bcx, llrawptr0, llty.ptr_to());
733719
let bcx = helper(bcx, llrawptr0, t);
734720

735721
finish_fn(fcx, lltop, bcx);

branches/snap-stage3/src/librustc/middle/trans/type_.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,20 +187,20 @@ impl Type {
187187
None => ()
188188
}
189189

190-
let ty = Type::glue_fn(Type::i8p());
190+
let ty = Type::glue_fn();
191191
cx.tn.associate_type("glue_fn", &ty);
192192

193193
return ty;
194194
}
195195

196-
pub fn glue_fn(t: Type) -> Type {
197-
Type::func([ Type::nil().ptr_to(), t ],
196+
pub fn glue_fn() -> Type {
197+
Type::func([ Type::nil().ptr_to(), Type::i8p() ],
198198
&Type::void())
199199
}
200200

201201
pub fn tydesc(arch: Architecture) -> Type {
202202
let mut tydesc = Type::named_struct("tydesc");
203-
let glue_fn_ty = Type::glue_fn(Type::i8p()).ptr_to();
203+
let glue_fn_ty = Type::glue_fn().ptr_to();
204204

205205
let int_ty = Type::int(arch);
206206

branches/snap-stage3/src/libstd/cmp.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,20 @@ pub fn lexical_ordering(o1: Ordering, o2: Ordering) -> Ordering {
157157
/**
158158
* Trait for values that can be compared for a sort-order.
159159
*
160-
* Eventually this may be simplified to only require
161-
* an `le` method, with the others generated from
162-
* default implementations. However it should remain
163-
* possible to implement the others separately, for
164-
* compatibility with floating-point NaN semantics
160+
* Ord only requires implementation of the `lt` method,
161+
* with the others generated from default implementations.
162+
*
163+
* However it remains possible to implement the others separately,
164+
* for compatibility with floating-point NaN semantics
165165
* (cf. IEEE 754-2008 section 5.11).
166166
*/
167+
#[allow(default_methods)] // NOTE: Remove when allowed in stage0
167168
#[lang="ord"]
168169
pub trait Ord {
169170
fn lt(&self, other: &Self) -> bool;
170-
fn le(&self, other: &Self) -> bool;
171-
fn ge(&self, other: &Self) -> bool;
172-
fn gt(&self, other: &Self) -> bool;
171+
fn le(&self, other: &Self) -> bool { !other.lt(self) }
172+
fn gt(&self, other: &Self) -> bool { other.lt(self) }
173+
fn ge(&self, other: &Self) -> bool { !self.lt(other) }
173174
}
174175

175176
/// The equivalence relation. Two values may be equivalent even if they are

branches/snap-stage3/src/libsyntax/ext/expand.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,18 @@ pub fn core_macros() -> @str {
643643
$(if $pred $body)else+
644644
);
645645
)
646+
647+
macro_rules! print(
648+
($( $arg:expr),+) => ( {
649+
print(fmt!($($arg),+));
650+
} )
651+
)
652+
653+
macro_rules! println(
654+
($( $arg:expr),+) => ( {
655+
println(fmt!($($arg),+));
656+
} )
657+
)
646658
}";
647659
}
648660

branches/snap-stage3/src/test/compile-fail/issue-3344.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
// except according to those terms.
1010

1111
struct thing(uint);
12-
impl Ord for thing { //~ ERROR missing method `gt`
13-
fn lt(&self, other: &thing) -> bool { **self < **other }
12+
impl Ord for thing { //~ ERROR missing method `lt`
1413
fn le(&self, other: &thing) -> bool { **self < **other }
1514
fn ge(&self, other: &thing) -> bool { **self < **other }
1615
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test default methods in Ord
12+
//
13+
struct Int(int);
14+
15+
impl Ord for Int {
16+
fn lt(&self, other: &Int) -> bool {
17+
**self < **other
18+
}
19+
}
20+
21+
struct RevInt(int);
22+
23+
impl Ord for RevInt {
24+
fn lt(&self, other: &RevInt) -> bool {
25+
**self > **other
26+
}
27+
}
28+
29+
pub fn main() {
30+
assert!(Int(2) > Int(1));
31+
assert!(Int(2) >= Int(1));
32+
assert!(Int(1) >= Int(1));
33+
assert!(Int(1) < Int(2));
34+
assert!(Int(1) <= Int(2));
35+
assert!(Int(1) <= Int(1));
36+
37+
assert!(RevInt(2) < RevInt(1));
38+
assert!(RevInt(2) <= RevInt(1));
39+
assert!(RevInt(1) <= RevInt(1));
40+
assert!(RevInt(1) > RevInt(2));
41+
assert!(RevInt(1) >= RevInt(2));
42+
assert!(RevInt(1) >= RevInt(1));
43+
}

0 commit comments

Comments
 (0)