Skip to content

Commit 3cd7b84

Browse files
committed
---
yaml --- r: 36367 b: refs/heads/master c: a73c352 h: refs/heads/master i: 36365: 7055765 36363: 47e4ace 36359: 47e645c 36351: 3cf3e78
1 parent 7ee5c29 commit 3cd7b84

File tree

520 files changed

+12601
-7719
lines changed

Some content is hidden

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

520 files changed

+12601
-7719
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: e723fe07783cd9b797c9f1456d359879bba44907
2+
refs/heads/master: a73c35249d7a9ddf92e5c203b244a4a10a6e8119

trunk/CONTRIBUTING.md

+9
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,14 @@ example, if it's 2014, and you change a Rust file that was created in
4747
// Copyright 2010-2014 The Rust Project Developers.
4848
```
4949

50+
# Coordination and communication
51+
52+
Get feedback from other developers on
53+
[discuss.rust-lang.org][discuss], and
54+
[#rust-internals][pound-rust-internals].
55+
56+
[pound-rust-internals]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-internals
57+
[discuss]: http://discuss.rust-lang.org
58+
5059
For more details, please refer to
5160
[Note-development-policy](https://github.com/rust-lang/rust/wiki/Note-development-policy).

trunk/man/rustc.1

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Specify the name of the crate being built
3434
\fB\-\-emit\fR [asm|llvm-bc|llvm-ir|obj|link|dep-info]
3535
Configure the output that rustc will produce
3636
.TP
37-
\fB\-\-print\fR [crate-name|output-file-names|sysroot]
37+
\fB\-\-print\fR [crate-name|file-names|sysroot]
3838
Comma separated list of compiler information to print on stdout
3939
.TP
4040
\fB\-g\fR

trunk/mk/docs.mk

+8-3
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ RUSTDOC_HTML_OPTS_NO_CSS = --html-before-content=doc/version_info.html \
4949
RUSTDOC_HTML_OPTS = $(RUSTDOC_HTML_OPTS_NO_CSS) --markdown-css rust.css
5050

5151
PANDOC_BASE_OPTS := --standalone --toc --number-sections
52-
PANDOC_TEX_OPTS = $(PANDOC_BASE_OPTS) --include-before-body=doc/version.tex \
53-
--from=markdown --include-before-body=doc/footer.tex --to=latex
52+
PANDOC_TEX_OPTS = $(PANDOC_BASE_OPTS) --from=markdown --to=latex \
53+
--include-before-body=doc/version.tex \
54+
--include-before-body=doc/footer.tex \
55+
--include-in-header=doc/uptack.tex
5456
PANDOC_EPUB_OPTS = $(PANDOC_BASE_OPTS) --to=epub
5557

5658
# The rustdoc executable...
@@ -155,6 +157,9 @@ doc/footer.tex: $(D)/footer.inc | doc/
155157
@$(call E, pandoc: $@)
156158
$(CFG_PANDOC) --from=html --to=latex $< --output=$@
157159

160+
doc/uptack.tex: $(D)/uptack.tex | doc/
161+
$(Q)cp $< $@
162+
158163
# HTML (rustdoc)
159164
DOC_TARGETS += doc/not_found.html
160165
doc/not_found.html: $(D)/not_found.md $(HTML_DEPS) | doc/
@@ -180,7 +185,7 @@ doc/$(1).epub: $$(D)/$(1).md | doc/
180185

181186
# PDF (md =(pandoc)=> tex =(pdflatex)=> pdf)
182187
DOC_TARGETS += doc/$(1).tex
183-
doc/$(1).tex: $$(D)/$(1).md doc/footer.tex doc/version.tex | doc/
188+
doc/$(1).tex: $$(D)/$(1).md doc/uptack.tex doc/footer.tex doc/version.tex | doc/
184189
@$$(call E, pandoc: $$@)
185190
$$(CFG_PANDOC) $$(PANDOC_TEX_OPTS) $$< --output=$$@
186191

trunk/mk/install.mk

+2-6
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ endif
2828
# Remove tmp files because it's a decent amount of disk space
2929
$(Q)rm -R tmp/dist
3030

31-
ifeq ($(CFG_DISABLE_DOCS),)
32-
prepare_install: dist/$(PKG_NAME)-$(CFG_BUILD).tar.gz dist/$(DOC_PKG_NAME)-$(CFG_BUILD).tar.gz | tmp/empty_dir
33-
else
34-
prepare_install: dist/$(PKG_NAME)-$(CFG_BUILD).tar.gz | tmp/empty_dir
35-
endif
31+
prepare_install: dist-tar-bins | tmp/empty_dir
3632

3733
uninstall:
3834
ifeq (root user, $(USER) $(patsubst %,user,$(SUDO_USER)))
@@ -48,7 +44,7 @@ endif
4844
# Remove tmp files because it's a decent amount of disk space
4945
$(Q)rm -R tmp/dist
5046

51-
prepare_uninstall: dist/$(PKG_NAME)-$(CFG_BUILD).tar.gz | tmp/empty_dir
47+
prepare_uninstall: dist-tar-bins | tmp/empty_dir
5248

5349
.PHONY: install prepare_install uninstall prepare_uninstall
5450

trunk/src/compiletest/compiletest.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,9 @@ pub fn is_test(config: &Config, testfile: &Path) -> bool {
339339
return valid;
340340
}
341341

342-
pub fn make_test(config: &Config, testfile: &Path, f: || -> test::TestFn)
343-
-> test::TestDescAndFn {
342+
pub fn make_test<F>(config: &Config, testfile: &Path, f: F) -> test::TestDescAndFn where
343+
F: FnOnce() -> test::TestFn,
344+
{
344345
test::TestDescAndFn {
345346
desc: test::TestDesc {
346347
name: make_test_name(config, testfile),

trunk/src/compiletest/header.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
220220
!val
221221
}
222222

223-
fn iter_header(testfile: &Path, it: |&str| -> bool) -> bool {
223+
fn iter_header<F>(testfile: &Path, mut it: F) -> bool where
224+
F: FnMut(&str) -> bool,
225+
{
224226
use std::io::{BufferedReader, File};
225227

226228
let mut rdr = BufferedReader::new(File::open(testfile).unwrap());

trunk/src/compiletest/runtest.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -1233,12 +1233,14 @@ enum TargetLocation {
12331233
ThisDirectory(Path),
12341234
}
12351235

1236-
fn make_compile_args(config: &Config,
1237-
props: &TestProps,
1238-
extras: Vec<String> ,
1239-
xform: |&Config, &Path| -> TargetLocation,
1240-
testfile: &Path)
1241-
-> ProcArgs {
1236+
fn make_compile_args<F>(config: &Config,
1237+
props: &TestProps,
1238+
extras: Vec<String> ,
1239+
xform: F,
1240+
testfile: &Path)
1241+
-> ProcArgs where
1242+
F: FnOnce(&Config, &Path) -> TargetLocation,
1243+
{
12421244
let xform_file = xform(config, testfile);
12431245
let target = if props.force_host {
12441246
config.host.as_slice()

trunk/src/doc/complement-lang-faq.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Some examples that demonstrate different aspects of the language:
1717
* [sprocketnes], an NES emulator with no GC, using modern Rust conventions
1818
* The language's general-purpose [hash] function, SipHash-2-4. Bit twiddling, OO, macros
1919
* The standard library's [HashMap], a sendable hash map in an OO style
20-
* The extra library's [json] module. Enums and pattern matching
20+
* The standard library's [json] module. Enums and pattern matching
2121

2222
[sprocketnes]: https://github.com/pcwalton/sprocketnes
2323
[hash]: https://github.com/rust-lang/rust/blob/master/src/libstd/hash/mod.rs

trunk/src/doc/guide-ffi.md

+27-23
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ them.
451451
~~~no_run
452452
extern crate libc;
453453
454-
use std::c_str::ToCStr;
454+
use std::ffi::CString;
455455
use std::ptr;
456456
457457
#[link(name = "readline")]
@@ -460,11 +460,10 @@ extern {
460460
}
461461
462462
fn main() {
463-
"[my-awesome-shell] $".with_c_str(|buf| {
464-
unsafe { rl_prompt = buf; }
465-
// get a line, process it
466-
unsafe { rl_prompt = ptr::null(); }
467-
});
463+
let prompt = CString::from_slice(b"[my-awesome-shell] $");
464+
unsafe { rl_prompt = prompt.as_ptr(); }
465+
// get a line, process it
466+
unsafe { rl_prompt = ptr::null(); }
468467
}
469468
~~~
470469
@@ -509,23 +508,28 @@ to define a block for all windows systems, not just x86 ones.
509508
510509
# Interoperability with foreign code
511510
512-
Rust guarantees that the layout of a `struct` is compatible with the platform's representation in C
513-
only if the `#[repr(C)]` attribute is applied to it. `#[repr(C, packed)]` can be used to lay out
514-
struct members without padding. `#[repr(C)]` can also be applied to an enum.
515-
516-
Rust's owned boxes (`Box<T>`) use non-nullable pointers as handles which point to the contained
517-
object. However, they should not be manually created because they are managed by internal
518-
allocators. References can safely be assumed to be non-nullable pointers directly to the type.
519-
However, breaking the borrow checking or mutability rules is not guaranteed to be safe, so prefer
520-
using raw pointers (`*`) if that's needed because the compiler can't make as many assumptions about
521-
them.
522-
523-
Vectors and strings share the same basic memory layout, and utilities are available in the `vec` and
524-
`str` modules for working with C APIs. However, strings are not terminated with `\0`. If you need a
525-
NUL-terminated string for interoperability with C, you should use the `c_str::to_c_str` function.
526-
527-
The standard library includes type aliases and function definitions for the C standard library in
528-
the `libc` module, and Rust links against `libc` and `libm` by default.
511+
Rust guarantees that the layout of a `struct` is compatible with the platform's
512+
representation in C only if the `#[repr(C)]` attribute is applied to it.
513+
`#[repr(C, packed)]` can be used to lay out struct members without padding.
514+
`#[repr(C)]` can also be applied to an enum.
515+
516+
Rust's owned boxes (`Box<T>`) use non-nullable pointers as handles which point
517+
to the contained object. However, they should not be manually created because
518+
they are managed by internal allocators. References can safely be assumed to be
519+
non-nullable pointers directly to the type. However, breaking the borrow
520+
checking or mutability rules is not guaranteed to be safe, so prefer using raw
521+
pointers (`*`) if that's needed because the compiler can't make as many
522+
assumptions about them.
523+
524+
Vectors and strings share the same basic memory layout, and utilities are
525+
available in the `vec` and `str` modules for working with C APIs. However,
526+
strings are not terminated with `\0`. If you need a NUL-terminated string for
527+
interoperability with C, you should use the `CString` type in the `std::ffi`
528+
module.
529+
530+
The standard library includes type aliases and function definitions for the C
531+
standard library in the `libc` module, and Rust links against `libc` and `libm`
532+
by default.
529533
530534
# The "nullable pointer optimization"
531535

trunk/src/doc/guide-ownership.md

+77-2
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,9 @@ fn add_one(num: &int) -> int {
230230
```
231231

232232
Rust has a feature called 'lifetime elision,' which allows you to not write
233-
lifetime annotations in certain circumstances. This is one of them. Without
234-
eliding the lifetimes, `add_one` looks like this:
233+
lifetime annotations in certain circumstances. This is one of them. We will
234+
cover the others later. Without eliding the lifetimes, `add_one` looks like
235+
this:
235236

236237
```rust
237238
fn add_one<'a>(num: &'a int) -> int {
@@ -449,6 +450,80 @@ This is the simplest kind of multiple ownership possible. For example, there's
449450
also `Arc<T>`, which uses more expensive atomic instructions to be the
450451
thread-safe counterpart of `Rc<T>`.
451452

453+
## Lifetime Elision
454+
455+
Earlier, we mentioned 'lifetime elision,' a feature of Rust which allows you to
456+
not write lifetime annotations in certain circumstances. All references have a
457+
lifetime, and so if you elide a lifetime (like `&T` instead of `&'a T`), Rust
458+
will do three things to determine what those lifetimes should be.
459+
460+
When talking about lifetime elision, we use the term 'input lifetime' and
461+
'output lifetime'. An 'input liftime' is a lifetime associated with a parameter
462+
of a function, and an 'output lifetime' is a lifetime associated with the return
463+
value of a function. For example, this function has an input lifetime:
464+
465+
```{rust,ignore}
466+
fn foo<'a>(bar: &'a str)
467+
```
468+
469+
This one has an output lifetime:
470+
471+
```{rust,ignore}
472+
fn foo<'a>() -> &'a str
473+
```
474+
475+
This one has a lifetime in both positions:
476+
477+
```{rust,ignore}
478+
fn foo<'a>(bar: &'a str) -> &'a str
479+
```
480+
481+
Here are the three rules:
482+
483+
* Each elided lifetime in a function's arguments becomes a distinct lifetime
484+
parameter.
485+
486+
* If there is exactly one input lifetime, elided or not, that lifetime is
487+
assigned to all elided lifetimes in the return values of that function..
488+
489+
* If there are multiple input lifetimes, but one of them is `&self` or `&mut
490+
self`, the lifetime of `self` is assigned to all elided output lifetimes.
491+
492+
Otherwise, it is an error to elide an output lifetime.
493+
494+
### Examples
495+
496+
Here are some examples of functions with elided lifetimes, and the version of
497+
what the elided lifetimes are expand to:
498+
499+
```{rust,ignore}
500+
fn print(s: &str); // elided
501+
fn print<'a>(s: &'a str); // expanded
502+
503+
fn debug(lvl: uint, s: &str); // elided
504+
fn debug<'a>(lvl: uint, s: &'a str); // expanded
505+
506+
// In the preceeding example, `lvl` doesn't need a lifetime because it's not a
507+
// reference (`&`). Only things relating to references (such as a `struct`
508+
// which contains a reference) need lifetimes.
509+
510+
fn substr(s: &str, until: uint) -> &str; // elided
511+
fn substr<'a>(s: &'a str, until: uint) -> &'a str; // expanded
512+
513+
fn get_str() -> &str; // ILLEGAL, no inputs
514+
515+
fn frob(s: &str, t: &str) -> &str; // ILLEGAL, two inputs
516+
517+
fn get_mut(&mut self) -> &mut T; // elided
518+
fn get_mut<'a>(&'a mut self) -> &'a mut T; // expanded
519+
520+
fn args<T:ToCStr>(&mut self, args: &[T]) -> &mut Command // elided
521+
fn args<'a, 'b, T:ToCStr>(&'a mut self, args: &'b [T]) -> &'a mut Command // expanded
522+
523+
fn new(buf: &mut [u8]) -> BufWriter; // elided
524+
fn new<'a>(buf: &'a mut [u8]) -> BufWriter<'a> // expanded
525+
```
526+
452527
# Related Resources
453528

454529
Coming Soon.

trunk/src/doc/guide-testing.md

+15-4
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,8 @@ Advice on writing benchmarks:
503503
* Make the code in the `iter` loop do something simple, to assist in pinpointing
504504
performance improvements (or regressions)
505505

506+
## Gotcha: optimizations
507+
506508
There's another tricky part to writing benchmarks: benchmarks compiled with
507509
optimizations activated can be dramatically changed by the optimizer so that
508510
the benchmark is no longer benchmarking what one expects. For example, the
@@ -537,7 +539,8 @@ computation entirely. This could be done for the example above by adjusting the
537539
`b.iter` call to
538540

539541
```rust
540-
# struct X; impl X { fn iter<T>(&self, _: || -> T) {} } let b = X;
542+
# struct X;
543+
# impl X { fn iter<T, F>(&self, _: F) where F: FnMut() -> T {} } let b = X;
541544
b.iter(|| {
542545
// note lack of `;` (could also use an explicit `return`).
543546
range(0u, 1000).fold(0, |old, new| old ^ new)
@@ -552,10 +555,15 @@ argument as used.
552555
extern crate test;
553556

554557
# fn main() {
555-
# struct X; impl X { fn iter<T>(&self, _: || -> T) {} } let b = X;
558+
# struct X;
559+
# impl X { fn iter<T, F>(&self, _: F) where F: FnMut() -> T {} } let b = X;
556560
b.iter(|| {
557-
test::black_box(range(0u, 1000).fold(0, |old, new| old ^ new));
558-
});
561+
let mut n = 1000_u32;
562+
563+
test::black_box(&mut n); // pretend to modify `n`
564+
565+
range(0, n).fold(0, |a, b| a ^ b)
566+
})
559567
# }
560568
```
561569

@@ -571,3 +579,6 @@ test bench_xor_1000_ints ... bench: 1 ns/iter (+/- 0)
571579
572580
test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
573581
```
582+
583+
However, the optimizer can still modify a testcase in an undesirable manner
584+
even when using either of the above.

0 commit comments

Comments
 (0)