Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 13 pull requests #21582

Merged
merged 33 commits into from
Jan 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
06d4019
For issue 15149 test, don't execute from tmpfs, and wait to see if th…
quantheory Jan 15, 2015
be138ed
Add `#[rustc_on_unimplemented]` annotations to more traits
ftxqxd Jan 20, 2015
87db16c
core::marker: s/task/thread/
ftxqxd Jan 22, 2015
3dbac78
libsyntax: fix for `has_test_signature`
blackbeam Jan 22, 2015
fd02920
Add test for `has_test_signature` for explicit return
blackbeam Jan 22, 2015
918dd34
Attempt fix for assertion on Windows, and add extra output for debugg…
quantheory Jan 22, 2015
ea6dc18
remove weird sentence
steveklabnik Jan 22, 2015
7f45dc9
Add a random number string to the end of the issue-15149 test's child…
quantheory Jan 23, 2015
a808070
Language tweak in configure
steveklabnik Jan 23, 2015
7aa3ed1
Check for make in configure
steveklabnik Jan 23, 2015
fc5bbdf
Make `make tidy` Python scripts more idiomatic
iKevinY Jan 23, 2015
76c279a
Use a regex to perform license check
iKevinY Jan 23, 2015
06714c2
Fix compile test for stage0
flaper87 Jan 23, 2015
aca7939
Soup up 'method syntax' chapter of the Book
steveklabnik Jan 13, 2015
dc2b3ac
Remove lang items from the reference.
steveklabnik Jan 23, 2015
91037a4
remove discuss link from the book
steveklabnik Jan 23, 2015
6f7c0b1
add test for issue 19660
Jan 24, 2015
2595780
Fix beta naming
brson Jan 24, 2015
d19f28b
Rollup merge of #21108 - steveklabnik:gh16969, r=alexcrichton
flaper87 Jan 24, 2015
6a9ee09
Rollup merge of #21445 - P1start:no-implemented, r=nikomatsakis
flaper87 Jan 24, 2015
65d14d2
Rollup merge of #21498 - quantheory:master, r=alexcrichton
flaper87 Jan 24, 2015
82299c0
Rollup merge of #21504 - blackbeam:has_test_signature_fix, r=alexcric…
flaper87 Jan 24, 2015
fd6fb16
Rollup merge of #21532 - steveklabnik:gh21531, r=alexcrichton
flaper87 Jan 24, 2015
dc32dfa
Rollup merge of #21535 - steveklabnik:gh19759, r=alexcrichton
flaper87 Jan 24, 2015
41e2d71
Rollup merge of #21539 - iKevinY:pythonic, r=alexcrichton
flaper87 Jan 24, 2015
60c9e12
Rollup merge of #21540 - steveklabnik:gh13082, r=brson
flaper87 Jan 24, 2015
8a2eee6
Rollup merge of #21541 - steveklabnik:gh13179, r=huonw
flaper87 Jan 24, 2015
a1f1541
Rollup merge of #21550 - FlaPer87:fix-compiletest, r=huonw
flaper87 Jan 24, 2015
df2ab66
Rollup merge of #21560 - steveklabnik:remove_discuss_link, r=sanxiyn
flaper87 Jan 24, 2015
38cb4c1
Rollup merge of #21573 - japaric:gh19660, r=huonw
flaper87 Jan 24, 2015
8d40f0f
Rollup merge of #21579 - brson:beta, r=alexcrichton
flaper87 Jan 24, 2015
577c464
don't run pretty-rpass for tests using #![main]
flaper87 Jan 24, 2015
7e83e46
assert path ends with executable. On Windows the process executable c…
flaper87 Jan 25, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ need_ok() {

need_cmd() {
if command -v $1 >/dev/null 2>&1
then msg "found $1"
else err "need $1"
then msg "found program $1"
else err "need program $1"
fi
}

Expand Down Expand Up @@ -340,6 +340,7 @@ need_cmd date
need_cmd tr
need_cmd sed
need_cmd file
need_cmd make

msg "inspecting environment"

Expand Down
4 changes: 2 additions & 2 deletions mk/main.mk
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ CFG_PACKAGE_VERS=$(CFG_RELEASE_NUM)
CFG_DISABLE_UNSTABLE_FEATURES=1
endif
ifeq ($(CFG_RELEASE_CHANNEL),beta)
CFG_RELEASE=$(CFG_RELEASE_NUM)-beta(CFG_PRERELEASE_VERSION)
CFG_PACKAGE_VERS=$(CFG_RELEASE_NUM)-beta(CFG_PRERELEASE_VERSION)
CFG_RELEASE=$(CFG_RELEASE_NUM)-beta$(CFG_PRERELEASE_VERSION)
CFG_PACKAGE_VERS=$(CFG_RELEASE_NUM)-beta$(CFG_PRERELEASE_VERSION)
CFG_DISABLE_UNSTABLE_FEATURES=1
endif
ifeq ($(CFG_RELEASE_CHANNEL),nightly)
Expand Down
15 changes: 15 additions & 0 deletions src/compiletest/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ pub use self::Mode::*;
use std::fmt;
use std::str::FromStr;

#[cfg(stage0)] // NOTE: remove impl after snapshot
#[derive(Clone, PartialEq, Show)]
pub enum Mode {
CompileFail,
RunFail,
RunPass,
RunPassValgrind,
Pretty,
DebugInfoGdb,
DebugInfoLldb,
Codegen
}

#[cfg(not(stage0))] // NOTE: remove cfg after snapshot
#[derive(Clone, PartialEq, Debug)]
pub enum Mode {
CompileFail,
Expand All @@ -24,6 +38,7 @@ pub enum Mode {
Codegen
}


impl Copy for Mode {}

impl FromStr for Mode {
Expand Down
135 changes: 2 additions & 133 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2291,136 +2291,7 @@ The name `str_eq` has a special meaning to the Rust compiler, and the presence
of this definition means that it will use this definition when generating calls
to the string equality function.

A complete list of the built-in language items follows:

#### Built-in Traits

* `copy`
: Types that do not move ownership when used by-value.
* `drop`
: Have destructors.
* `send`
: Able to be sent across thread boundaries.
* `sized`
: Has a size known at compile time.
* `sync`
: Able to be safely shared between threads when aliased.

#### Operators

These language items are traits:

* `add`
: Elements can be added (for example, integers and floats).
* `sub`
: Elements can be subtracted.
* `mul`
: Elements can be multiplied.
* `div`
: Elements have a division operation.
* `rem`
: Elements have a remainder operation.
* `neg`
: Elements can be negated arithmetically.
* `not`
: Elements can be negated logically.
* `bitxor`
: Elements have an exclusive-or operation.
* `bitand`
: Elements have a bitwise `and` operation.
* `bitor`
: Elements have a bitwise `or` operation.
* `shl`
: Elements have a left shift operation.
* `shr`
: Elements have a right shift operation.
* `index`
: Elements can be indexed.
* `index_mut`
: ___Needs filling in___
* `eq`
: Elements can be compared for equality.
* `ord`
: Elements have a partial ordering.
* `deref`
: `*` can be applied, yielding a reference to another type.
* `deref_mut`
: `*` can be applied, yielding a mutable reference to another type.

These are functions:

* `fn`
: ___Needs filling in___
* `fn_mut`
: ___Needs filling in___
* `fn_once`
: ___Needs filling in___
* `str_eq`
: Compare two strings (`&str`) for equality.
* `strdup_uniq`
: Return a new unique string
containing a copy of the contents of a unique string.

#### Types

* `type_id`
: The type returned by the `type_id` intrinsic.
* `unsafe`
: A type whose contents can be mutated through an immutable reference.

#### Marker types

These types help drive the compiler's analysis

* `begin_unwind`
: ___Needs filling in___
* `no_copy_bound`
: This type does not implement "copy", even if eligible.
* `eh_personality`
: ___Needs filling in___
* `exchange_free`
: Free memory that was allocated on the exchange heap.
* `exchange_malloc`
: Allocate memory on the exchange heap.
* `closure_exchange_malloc`
: ___Needs filling in___
* `panic`
: Abort the program with an error.
* `fail_bounds_check`
: Abort the program with a bounds check error.
* `free`
: Free memory that was allocated on the managed heap.
* `gc`
: ___Needs filling in___
* `exchange_heap`
: ___Needs filling in___
* `iterator`
: ___Needs filling in___
* `contravariant_lifetime`
: The lifetime parameter should be considered contravariant.
* `covariant_lifetime`
: The lifetime parameter should be considered covariant.
* `invariant_lifetime`
: The lifetime parameter should be considered invariant.
* `malloc`
: Allocate memory on the managed heap.
* `owned_box`
: ___Needs filling in___
* `stack_exhausted`
: ___Needs filling in___
* `start`
: ___Needs filling in___
* `contravariant_type`
: The type parameter should be considered contravariant.
* `covariant_type`
: The type parameter should be considered covariant.
* `invariant_type`
: The type parameter should be considered invariant.
* `ty_desc`
: ___Needs filling in___

> **Note:** This list is likely to become out of date. We should auto-generate
> it from `librustc/middle/lang_items.rs`.
A complete list of the built-in language items will be added in the future.

### Inline attributes

Expand Down Expand Up @@ -2652,9 +2523,7 @@ The currently implemented features of the reference compiler are:
declare a `static` as being unique per-thread leveraging
LLVM's implementation which works in concert with the kernel
loader and dynamic linker. This is not necessarily available
on all platforms, and usage of it is discouraged (rust
focuses more on thread-local data instead of thread-local
data).
on all platforms, and usage of it is discouraged.

* `trace_macros` - Allows use of the `trace_macros` macro, which is a nasty
hack that will certainly be removed.
Expand Down
5 changes: 2 additions & 3 deletions src/doc/trpl/installing-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ If not, there are a number of places where you can get help. The easiest is
you can access through
[Mibbit](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust). Click
that link, and you'll be chatting with other Rustaceans (a silly nickname we
call ourselves), and we can help you out. Other great resources include [our
forum](http://discuss.rust-lang.org/), [the /r/rust
subreddit](http://www.reddit.com/r/rust), and [Stack
call ourselves), and we can help you out. Other great resources include [the
/r/rust subreddit](http://www.reddit.com/r/rust), and [Stack
Overflow](http://stackoverflow.com/questions/tagged/rust).
114 changes: 112 additions & 2 deletions src/doc/trpl/method-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ x.foo().bar().baz();
Luckily, as you may have guessed with the leading question, you can! Rust provides
the ability to use this *method call syntax* via the `impl` keyword.

## Method calls

Here's how it works:

```{rust}
Expand Down Expand Up @@ -56,11 +58,56 @@ other parameter. Because we know it's a `Circle`, we can access the `radius`
just like we would with any other struct. An import of π and some
multiplications later, and we have our area.

## Chaining method calls

So, now we know how to call a method, such as `foo.bar()`. But what about our
original example, `foo.bar().baz()`? This is called 'method chaining', and we
can do it by returning `self`.

```
struct Circle {
x: f64,
y: f64,
radius: f64,
}

impl Circle {
fn area(&self) -> f64 {
std::f64::consts::PI * (self.radius * self.radius)
}

fn grow(&self) -> Circle {
Circle { x: self.x, y: self.y, radius: (self.radius * 10.0) }
}
}

fn main() {
let c = Circle { x: 0.0, y: 0.0, radius: 2.0 };
println!("{}", c.area());

let d = c.grow().area();
println!("{}", d);
}
```

Check the return type:

```
# struct Circle;
# impl Circle {
fn grow(&self) -> Circle {
# Circle } }
```

We just say we're returning a `Circle`. With this, we can grow a new circle
that's twice as big as the old one.

## Static methods

You can also define methods that do not take a `self` parameter. Here's a
pattern that's very common in Rust code:

```{rust}
# #![allow(non_shorthand_field_patterns)]
```
struct Circle {
x: f64,
y: f64,
Expand All @@ -86,3 +133,66 @@ This *static method* builds a new `Circle` for us. Note that static methods
are called with the `Struct::method()` syntax, rather than the `ref.method()`
syntax.

## Builder Pattern

Let's say that we want our users to be able to create Circles, but we will
allow them to only set the properties they care about. Otherwise, the `x`
and `y` attributes will be `0.0`, and the `radius` will be `1.0`. Rust doesn't
have method overloading, named arguments, or variable arguments. We employ
the builder pattern instead. It looks like this:

```
struct Circle {
x: f64,
y: f64,
radius: f64,
}

impl Circle {
fn area(&self) -> f64 {
std::f64::consts::PI * (self.radius * self.radius)
}
}

struct CircleBuilder {
coordinate: f64,
radius: f64,
}

impl CircleBuilder {
fn new() -> CircleBuilder {
CircleBuilder { coordinate: 0.0, radius: 0.0, }
}

fn coordinate(&mut self, coordinate: f64) -> &mut CircleBuilder {
self.coordinate = coordinate;
self
}

fn radius(&mut self, radius: f64) -> &mut CircleBuilder {
self.radius = radius;
self
}

fn finalize(&self) -> Circle {
Circle { x: self.coordinate, y: self.coordinate, radius: self.radius }
}
}

fn main() {
let c = CircleBuilder::new()
.coordinate(10.0)
.radius(5.0)
.finalize();


println!("area: {}", c.area());
}
```

What we've done here is make another struct, `CircleBuilder`. We've defined our
builder methods on it. We've also defined our `area()` method on `Circle`. We
also made one more method on `CircleBuilder`: `finalize()`. This method creates
our final `Circle` from the builder. Now, we've used the type system to enforce
our concerns: we can use the methods on `CircleBuilder` to constrain making
`Circle`s in any way we choose.
Loading