Skip to content

Commit 5365ffc

Browse files
author
blake2-ppc
committed
---
yaml --- r: 64826 b: refs/heads/snap-stage3 c: 11aad20 h: refs/heads/master v: v3
1 parent 6f73e6d commit 5365ffc

File tree

7 files changed

+68
-53
lines changed

7 files changed

+68
-53
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: fddb35e988384c7aa5d9aaf96c1e075bede7a188
4+
refs/heads/snap-stage3: 11aad20cf879f508a339c2af2bad901446f4fb3a
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/doc/tutorial.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ was taken.
309309

310310
In short, everything that's not a declaration (declarations are `let` for
311311
variables; `fn` for functions; and any top-level named items such as
312-
[traits](#traits), [enum types](#enums), and static items) is an
312+
[traits](#traits), [enum types](#enums), and [constants](#constants)) is an
313313
expression, including function bodies.
314314

315315
~~~~
@@ -992,7 +992,7 @@ task-local garbage collector. It will be destroyed at some point after there
992992
are no references left to the box, no later than the end of the task. Managed
993993
boxes lack an owner, so they start a new ownership tree and don't inherit
994994
mutability. They do own the contained object, and mutability is defined by the
995-
type of the managed box (`@` or `@mut`). An object containing a managed box is
995+
type of the shared box (`@` or `@mut`). An object containing a managed box is
996996
not `Owned`, and can't be sent between tasks.
997997

998998
~~~~
@@ -1089,8 +1089,10 @@ we might like to compute the distance between `on_the_stack` and
10891089
to define a function that takes two arguments of type point—that is,
10901090
it takes the points by value. But this will cause the points to be
10911091
copied when we call the function. For points, this is probably not so
1092-
bad, but often copies are expensive. So we’d like to define a function
1093-
that takes the points by pointer. We can use borrowed pointers to do this:
1092+
bad, but often copies are expensive or, worse, if there are mutable
1093+
fields, they can change the semantics of your program. So we’d like to
1094+
define a function that takes the points by pointer. We can use
1095+
borrowed pointers to do this:
10941096
10951097
~~~
10961098
# struct Point { x: float, y: float }
@@ -1373,7 +1375,7 @@ let exchange_crayons: ~str = ~"Black, BlizzardBlue, Blue";
13731375
~~~
13741376

13751377
Both vectors and strings support a number of useful
1376-
[methods](#methods), defined in [`std::vec`]
1378+
[methods](#functions-and-methods), defined in [`std::vec`]
13771379
and [`std::str`]. Here are some examples.
13781380

13791381
[`std::vec`]: std/vec.html
@@ -1928,7 +1930,7 @@ that implements a trait includes the name of the trait at the start of
19281930
the definition, as in the following impls of `Printable` for `int`
19291931
and `~str`.
19301932

1931-
[impls]: #methods
1933+
[impls]: #functions-and-methods
19321934

19331935
~~~~
19341936
# trait Printable { fn print(&self); }

branches/snap-stage3/src/compiletest/runtest.rs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use util::logv;
2222

2323
use std::io;
2424
use std::os;
25-
use std::str;
2625
use std::uint;
2726
use std::vec;
2827

@@ -356,30 +355,6 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
356355
fmt!("%s:%u:", testfile.to_str(), ee.line)
357356
}).collect::<~[~str]>();
358357

359-
fn to_lower( s : &str ) -> ~str {
360-
let i = s.iter();
361-
let c : ~[char] = i.transform( |c| {
362-
if c.is_ascii() {
363-
c.to_ascii().to_lower().to_char()
364-
} else {
365-
c
366-
}
367-
} ).collect();
368-
str::from_chars( c )
369-
}
370-
371-
#[cfg(target_os = "win32")]
372-
fn prefix_matches( line : &str, prefix : &str ) -> bool {
373-
to_lower(line).starts_with( to_lower(prefix) )
374-
}
375-
376-
#[cfg(target_os = "linux")]
377-
#[cfg(target_os = "macos")]
378-
#[cfg(target_os = "freebsd")]
379-
fn prefix_matches( line : &str, prefix : &str ) -> bool {
380-
line.starts_with( prefix )
381-
}
382-
383358
// Scan and extract our error/warning messages,
384359
// which look like:
385360
// filename:line1:col1: line2:col2: *error:* msg
@@ -392,7 +367,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
392367
if !found_flags[i] {
393368
debug!("prefix=%s ee.kind=%s ee.msg=%s line=%s",
394369
prefixes[i], ee.kind, ee.msg, line);
395-
if (prefix_matches(line, prefixes[i]) &&
370+
if (line.starts_with(prefixes[i]) &&
396371
line.contains(ee.kind) &&
397372
line.contains(ee.msg)) {
398373
found_flags[i] = true;

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

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,26 @@ clone_impl!(())
9797
clone_impl!(bool)
9898
clone_impl!(char)
9999

100+
macro_rules! extern_fn_clone(
101+
($($A:ident),*) => (
102+
impl<$($A,)* ReturnType> Clone for extern "Rust" fn($($A),*) -> ReturnType {
103+
/// Return a copy of a function pointer
104+
#[inline]
105+
fn clone(&self) -> extern "Rust" fn($($A),*) -> ReturnType { *self }
106+
}
107+
)
108+
)
109+
110+
extern_fn_clone!()
111+
extern_fn_clone!(A)
112+
extern_fn_clone!(A, B)
113+
extern_fn_clone!(A, B, C)
114+
extern_fn_clone!(A, B, C, D)
115+
extern_fn_clone!(A, B, C, D, E)
116+
extern_fn_clone!(A, B, C, D, E, F)
117+
extern_fn_clone!(A, B, C, D, E, F, G)
118+
extern_fn_clone!(A, B, C, D, E, F, G, H)
119+
100120
/// A trait distinct from `Clone` which represents "deep copies" of things like
101121
/// managed boxes which would otherwise not be copied.
102122
pub trait DeepClone {
@@ -157,6 +177,26 @@ deep_clone_impl!(())
157177
deep_clone_impl!(bool)
158178
deep_clone_impl!(char)
159179

180+
macro_rules! extern_fn_deep_clone(
181+
($($A:ident),*) => (
182+
impl<$($A,)* ReturnType> DeepClone for extern "Rust" fn($($A),*) -> ReturnType {
183+
/// Return a copy of a function pointer
184+
#[inline]
185+
fn deep_clone(&self) -> extern "Rust" fn($($A),*) -> ReturnType { *self }
186+
}
187+
)
188+
)
189+
190+
extern_fn_deep_clone!()
191+
extern_fn_deep_clone!(A)
192+
extern_fn_deep_clone!(A, B)
193+
extern_fn_deep_clone!(A, B, C)
194+
extern_fn_deep_clone!(A, B, C, D)
195+
extern_fn_deep_clone!(A, B, C, D, E)
196+
extern_fn_deep_clone!(A, B, C, D, E, F)
197+
extern_fn_deep_clone!(A, B, C, D, E, F, G)
198+
extern_fn_deep_clone!(A, B, C, D, E, F, G, H)
199+
160200
#[test]
161201
fn test_owned_clone() {
162202
let a = ~5i;
@@ -195,3 +235,21 @@ fn test_borrowed_clone() {
195235
let z: &int = (&y).clone();
196236
assert_eq!(*z, 5);
197237
}
238+
239+
#[test]
240+
fn test_extern_fn_clone() {
241+
trait Empty {}
242+
impl Empty for int {}
243+
244+
fn test_fn_a() -> float { 1.0 }
245+
fn test_fn_b<T: Empty>(x: T) -> T { x }
246+
fn test_fn_c(_: int, _: float, _: ~[int], _: int, _: int, _: int) {}
247+
248+
let _ = test_fn_a.clone();
249+
let _ = test_fn_b::<int>.clone();
250+
let _ = test_fn_c.clone();
251+
252+
let _ = test_fn_a.deep_clone();
253+
let _ = test_fn_b::<int>.deep_clone();
254+
let _ = test_fn_c.deep_clone();
255+
}

branches/snap-stage3/src/libstd/unstable/extfmt.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ pub mod ct {
114114
TyHex(Caseness),
115115
TyOctal,
116116
TyFloat,
117-
TyPointer,
118117
TyPoly,
119118
}
120119

@@ -326,7 +325,6 @@ pub mod ct {
326325
't' => TyBits,
327326
'o' => TyOctal,
328327
'f' => TyFloat,
329-
'p' => TyPointer,
330328
'?' => TyPoly,
331329
_ => err(fmt!("unknown type in conversion: %c", s.char_at(i)))
332330
};
@@ -436,7 +434,6 @@ pub mod ct {
436434
assert!(test("t", TyBits));
437435
assert!(test("x", TyHex(CaseLower)));
438436
assert!(test("X", TyHex(CaseUpper)));
439-
assert!(test("p", TyPointer));
440437
assert!(test("?", TyPoly));
441438
}
442439
@@ -576,10 +573,6 @@ pub mod rt {
576573
} else { None };
577574
pad(cv, s, head, PadFloat, buf);
578575
}
579-
pub fn conv_pointer<T>(cv: Conv, ptr: *T, buf: &mut ~str) {
580-
let s = ~"0x" + uint_to_str_prec(ptr as uint, 16, 1u);
581-
pad(cv, s, None, PadNozero, buf);
582-
}
583576
pub fn conv_poly<T>(cv: Conv, v: &T, buf: &mut ~str) {
584577
let s = sys::log_str(v);
585578
conv_str(cv, s, buf);

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span,
191191
TyChar => ("char", arg),
192192
TyBits | TyOctal | TyHex(_) | TyInt(Unsigned) => ("uint", arg),
193193
TyFloat => ("float", arg),
194-
TyPointer => ("pointer", arg),
195194
TyPoly => ("poly", cx.expr_addr_of(sp, arg))
196195
};
197196
return make_conv_call(cx, arg.span, name, cnv, actual_arg,
@@ -243,7 +242,6 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span,
243242
},
244243
TyOctal => debug!("type: octal"),
245244
TyFloat => debug!("type: float"),
246-
TyPointer => debug!("type: pointer"),
247245
TyPoly => debug!("type: poly")
248246
}
249247
}

branches/snap-stage3/src/test/run-pass/syntax-extension-fmt.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ pub fn main() {
3232
part6();
3333
percent();
3434
more_floats();
35-
pointer();
3635
}
3736
3837
fn part1() {
@@ -264,13 +263,3 @@ fn more_floats() {
264263
assert_eq!(~"7.0000", fmt!("%.4f", 6.999999999));
265264
assert_eq!(~"3.141590000", fmt!("%.9f", 3.14159));
266265
}
267-
268-
fn pointer() {
269-
for 10.times {
270-
let x: uint = ::std::rand::random();
271-
assert_eq!(fmt!("%p", x as *uint), fmt!("0x%x", x));
272-
}
273-
274-
let i = &1;
275-
assert_eq!(fmt!("%p", i), fmt!("0x%x", i as *uint as uint));
276-
}

0 commit comments

Comments
 (0)