Skip to content

Commit 9587c25

Browse files
committed
---
yaml --- r: 209823 b: refs/heads/try c: 5a61d43 h: refs/heads/master i: 209821: e1aeaea 209819: ebdfbf1 209815: af6ea43 209807: 7cf8a4f 209791: 7b2abf4 v: v3
1 parent 6641e9c commit 9587c25

Some content is hidden

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

44 files changed

+292
-97
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3e561f05c00cd180ec02db4ccab2840a4aba93d2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
5-
refs/heads/try: 17934e5c29509fe72dbf6228033ab632919dba95
5+
refs/heads/try: 5a61d43526b97d864b68a98008837a09629f2573
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/configure

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,15 @@ to_gnu_triple() {
337337
esac
338338
}
339339

340+
# Prints the absolute path of a directory to stdout
341+
abs_path() {
342+
local _path="$1"
343+
# Unset CDPATH because it causes havok: it makes the destination unpredictable
344+
# and triggers 'cd' to print the path to stdout. Route `cd`'s output to /dev/null
345+
# for good measure.
346+
(unset CDPATH && cd "$_path" > /dev/null && pwd)
347+
}
348+
340349
msg "looking for configure programs"
341350
need_cmd cmp
342351
need_cmd mkdir
@@ -509,7 +518,7 @@ fi
509518

510519
DEFAULT_BUILD="${CFG_CPUTYPE}-${CFG_OSTYPE}"
511520

512-
CFG_SRC_DIR="$(cd $(dirname $0) && pwd)/"
521+
CFG_SRC_DIR="$(abs_path $(dirname $0))/"
513522
CFG_BUILD_DIR="$(pwd)/"
514523
CFG_SELF="$0"
515524
CFG_CONFIGURE_ARGS="$@"

branches/try/mk/main.mk

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@ CFG_PACKAGE_VERS=$(CFG_RELEASE_NUM)
3030
CFG_DISABLE_UNSTABLE_FEATURES=1
3131
endif
3232
ifeq ($(CFG_RELEASE_CHANNEL),beta)
33-
CFG_RELEASE=$(CFG_RELEASE_NUM)-beta$(CFG_PRERELEASE_VERSION)
34-
CFG_PACKAGE_VERS=$(CFG_RELEASE_NUM)-beta$(CFG_PRERELEASE_VERSION)
33+
CFG_RELEASE=$(CFG_RELEASE_NUM)-beta
34+
# When building beta distributables just reuse the same "beta" name
35+
# so when we upload we'll always override the previous beta. This
36+
# doesn't actually impact the version reported by rustc - it's just
37+
# for file naming.
38+
CFG_PACKAGE_VERS=beta
3539
CFG_DISABLE_UNSTABLE_FEATURES=1
3640
endif
3741
ifeq ($(CFG_RELEASE_CHANNEL),nightly)

branches/try/mk/tests.mk

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -753,20 +753,22 @@ PRETTY_DEPS_pretty-rpass-full = $(RPASS_FULL_TESTS)
753753
PRETTY_DEPS_pretty-rfail = $(RFAIL_TESTS)
754754
PRETTY_DEPS_pretty-bench = $(BENCH_TESTS)
755755
PRETTY_DEPS_pretty-pretty = $(PRETTY_TESTS)
756-
# The stage- and host-specific dependencies are for e.g. macro_crate_test which pulls in
757-
# external crates.
758-
PRETTY_DEPS$(1)_H_$(3)_pretty-rpass =
759-
PRETTY_DEPS$(1)_H_$(3)_pretty-rpass-full = $$(HLIB$(1)_H_$(3))/stamp.syntax $$(HLIB$(1)_H_$(3))/stamp.rustc
760-
PRETTY_DEPS$(1)_H_$(3)_pretty-rfail =
761-
PRETTY_DEPS$(1)_H_$(3)_pretty-bench =
762-
PRETTY_DEPS$(1)_H_$(3)_pretty-pretty =
763756
PRETTY_DIRNAME_pretty-rpass = run-pass
764757
PRETTY_DIRNAME_pretty-rpass-valgrind = run-pass-valgrind
765758
PRETTY_DIRNAME_pretty-rpass-full = run-pass-fulldeps
766759
PRETTY_DIRNAME_pretty-rfail = run-fail
767760
PRETTY_DIRNAME_pretty-bench = bench
768761
PRETTY_DIRNAME_pretty-pretty = pretty
769762

763+
define DEF_PRETTY_FULLDEPS
764+
PRETTY_DEPS$(1)_T_$(2)_H_$(3)_pretty-rpass-full = $$(CSREQ$(1)_T_$(3)_H_$(3))
765+
endef
766+
767+
$(foreach host,$(CFG_HOST), \
768+
$(foreach target,$(CFG_TARGET), \
769+
$(foreach stage,$(STAGES), \
770+
$(eval $(call DEF_PRETTY_FULLDEPS,$(stage),$(target),$(host))))))
771+
770772
define DEF_RUN_PRETTY_TEST
771773

772774
PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4) := \
@@ -780,7 +782,7 @@ check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4
780782
$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
781783
$$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
782784
$$(PRETTY_DEPS_$(4)) \
783-
$$(PRETTY_DEPS$(1)_H_$(3)_$(4))
785+
$$(PRETTY_DEPS$(1)_T_$(2)_H_$(3)_$(4))
784786
@$$(call E, run pretty-rpass [$(2)]: $$<)
785787
$$(Q)touch $$@.start_time
786788
$$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \

branches/try/src/compiletest/runtest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1465,7 +1465,7 @@ fn make_out_name(config: &Config, testfile: &Path, extension: &str) -> PathBuf {
14651465
fn aux_output_dir_name(config: &Config, testfile: &Path) -> PathBuf {
14661466
let f = output_base_name(config, testfile);
14671467
let mut fname = f.file_name().unwrap().to_os_string();
1468-
fname.push("libaux");
1468+
fname.push(&format!(".{}.libaux", config.mode));
14691469
f.with_file_name(&fname)
14701470
}
14711471

branches/try/src/doc/reference.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,7 @@ fn draw_twice<T: Shape>(surface: Surface, sh: T) {
15551555
}
15561556
```
15571557

1558-
Traits also define an [object type](#object-types) with the same name as the
1558+
Traits also define an [trait object](#trait-objects) with the same name as the
15591559
trait. Values of this type are created by [casting](#type-cast-expressions)
15601560
pointer values (pointing to a type for which an implementation of the given
15611561
trait is in scope) to pointers to the trait name, used as a type.
@@ -2146,7 +2146,7 @@ The following configurations must be defined by the implementation:
21462146
`"unix"` or `"windows"`. The value of this configuration option is defined
21472147
as a configuration itself, like `unix` or `windows`.
21482148
* `target_os = "..."`. Operating system of the target, examples include
2149-
`"win32"`, `"macos"`, `"linux"`, `"android"`, `"freebsd"`, `"dragonfly"`,
2149+
`"windows"`, `"macos"`, `"ios"`, `"linux"`, `"android"`, `"freebsd"`, `"dragonfly"`,
21502150
`"bitrig"` or `"openbsd"`.
21512151
* `target_pointer_width = "..."`. Target pointer width in bits. This is set
21522152
to `"32"` for targets with 32-bit pointers, and likewise set to `"64"` for
@@ -2744,7 +2744,7 @@ A _method call_ consists of an expression followed by a single dot, an
27442744
identifier, and a parenthesized expression-list. Method calls are resolved to
27452745
methods on specific traits, either statically dispatching to a method if the
27462746
exact `self`-type of the left-hand-side is known, or dynamically dispatching if
2747-
the left-hand-side expression is an indirect [object type](#object-types).
2747+
the left-hand-side expression is an indirect [trait object](#trait-objects).
27482748

27492749
### Field expressions
27502750

@@ -3649,23 +3649,23 @@ call_closure(closure_no_args, closure_args);
36493649

36503650
```
36513651

3652-
### Object types
3652+
### Trait objects
36533653

36543654
Every trait item (see [traits](#traits)) defines a type with the same name as
3655-
the trait. This type is called the _object type_ of the trait. Object types
3655+
the trait. This type is called the _trait object_ of the trait. Trait objects
36563656
permit "late binding" of methods, dispatched using _virtual method tables_
36573657
("vtables"). Whereas most calls to trait methods are "early bound" (statically
36583658
resolved) to specific implementations at compile time, a call to a method on an
3659-
object type is only resolved to a vtable entry at compile time. The actual
3659+
trait objects is only resolved to a vtable entry at compile time. The actual
36603660
implementation for each vtable entry can vary on an object-by-object basis.
36613661

36623662
Given a pointer-typed expression `E` of type `&T` or `Box<T>`, where `T`
36633663
implements trait `R`, casting `E` to the corresponding pointer type `&R` or
3664-
`Box<R>` results in a value of the _object type_ `R`. This result is
3664+
`Box<R>` results in a value of the _trait object_ `R`. This result is
36653665
represented as a pair of pointers: the vtable pointer for the `T`
36663666
implementation of `R`, and the pointer value of `E`.
36673667

3668-
An example of an object type:
3668+
An example of a trait object:
36693669

36703670
```
36713671
trait Printable {
@@ -3685,7 +3685,7 @@ fn main() {
36853685
}
36863686
```
36873687

3688-
In this example, the trait `Printable` occurs as an object type in both the
3688+
In this example, the trait `Printable` occurs as a trait object in both the
36893689
type signature of `print`, and the cast expression in `main`.
36903690

36913691
### Type parameters

branches/try/src/doc/trpl/ufcs.md

Lines changed: 125 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,127 @@
11
% Universal Function Call Syntax
22

3-
Coming soon
3+
Sometimes, functions can have the same names. Consider this code:
4+
5+
```rust
6+
trait Foo {
7+
fn f(&self);
8+
}
9+
10+
trait Bar {
11+
fn f(&self);
12+
}
13+
14+
struct Baz;
15+
16+
impl Foo for Baz {
17+
fn f(&self) { println!("Baz’s impl of Foo"); }
18+
}
19+
20+
impl Bar for Baz {
21+
fn f(&self) { println!("Baz’s impl of Bar"); }
22+
}
23+
24+
let b = Baz;
25+
```
26+
27+
If we were to try to call `b.f()`, we’d get an error:
28+
29+
```text
30+
error: multiple applicable methods in scope [E0034]
31+
b.f();
32+
^~~
33+
note: candidate #1 is defined in an impl of the trait `main::Foo` for the type
34+
`main::Baz`
35+
fn f(&self) { println!("Baz’s impl of Foo"); }
36+
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37+
note: candidate #2 is defined in an impl of the trait `main::Bar` for the type
38+
`main::Baz`
39+
fn f(&self) { println!("Baz’s impl of Bar"); }
40+
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
41+
42+
```
43+
44+
We need a way to disambiguate which method we need. This feature is called
45+
‘universal function call syntax’, and it looks like this:
46+
47+
```rust
48+
# trait Foo {
49+
# fn f(&self);
50+
# }
51+
# trait Bar {
52+
# fn f(&self);
53+
# }
54+
# struct Baz;
55+
# impl Foo for Baz {
56+
# fn f(&self) { println!("Baz’s impl of Foo"); }
57+
# }
58+
# impl Bar for Baz {
59+
# fn f(&self) { println!("Baz’s impl of Bar"); }
60+
# }
61+
# let b = Baz;
62+
Foo::f(&b);
63+
Bar::f(&b);
64+
```
65+
66+
Let’s break it down.
67+
68+
```rust,ignore
69+
Foo::
70+
Bar::
71+
```
72+
73+
These halves of the invocation are the types of the two traits: `Foo` and
74+
`Bar`. This is what ends up actually doing the disambiguation between the two:
75+
Rust calls the one from the trait name you use.
76+
77+
```rust,ignore
78+
f(&b)
79+
```
80+
81+
When we call a method like `b.f()` using [method syntax][methodsyntax], Rust
82+
will automatically borrow `b` if `f()` takes `&self`. In this case, Rust will
83+
not, and so we need to pass an explicit `&b`.
84+
85+
[methodsyntax]: method-syntax.html
86+
87+
# Angle-bracket Form
88+
89+
The form of UFCS we just talked about:
90+
91+
```rust,ignore
92+
Type::method(args);
93+
```
94+
95+
Is a short-hand. There’s an expanded form of this that’s needed in some
96+
situations:
97+
98+
```rust,ignore
99+
<Type as Trait>::method(args);
100+
```
101+
102+
The `<>::` syntax is a means of providing a type hint. The type goes inside
103+
the `<>`s. In this case, the type is `Type as Trait`, indicating that we want
104+
`Trait`’s version of `method` to be called here. The `as Trait` part is
105+
optional if it’s not ambiguous. Same with the angle brackets, hence the
106+
shorter form.
107+
108+
Here’s an example of using the longer form.
109+
110+
```rust
111+
trait Foo {
112+
fn clone(&self);
113+
}
114+
115+
#[derive(Clone)]
116+
struct Bar;
117+
118+
impl Foo for Bar {
119+
fn clone(&self) {
120+
println!("Making a clone of Bar");
121+
122+
<Bar as Clone>::clone(self);
123+
}
124+
}
125+
```
126+
127+
This will call the `Clone` trait’s `clone()` method, rather than `Foo`’s.

branches/try/src/liballoc/arc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ impl<T> fmt::Pointer for Arc<T> {
675675
}
676676

677677
#[stable(feature = "rust1", since = "1.0.0")]
678-
impl<T: Default + Sync + Send> Default for Arc<T> {
678+
impl<T: Default> Default for Arc<T> {
679679
#[stable(feature = "rust1", since = "1.0.0")]
680680
fn default() -> Arc<T> { Arc::new(Default::default()) }
681681
}

0 commit comments

Comments
 (0)