]> git.lizzy.rs Git - rust.git/log
rust.git
10 years agoAdd tests for null pointer opt.
Luqman Aden [Fri, 4 Jul 2014 21:54:23 +0000 (14:54 -0700)]
Add tests for null pointer opt.

10 years agolibrustc: Don't create &[T] slices with NULL as the ptr.
Luqman Aden [Fri, 4 Jul 2014 05:24:33 +0000 (22:24 -0700)]
librustc: Don't create &[T] slices with NULL as the ptr.

10 years agolibrustc: Remove match arm since we don't allow enum to float casts.
Luqman Aden [Fri, 4 Jul 2014 05:19:38 +0000 (22:19 -0700)]
librustc: Remove match arm since we don't allow enum to float casts.

10 years agolibrustc: Apply null pointer optimization to slices, closures and trait
Luqman Aden [Fri, 4 Jul 2014 02:26:38 +0000 (19:26 -0700)]
librustc: Apply null pointer optimization to slices, closures and trait
objects.

10 years agoauto merge of #15377 : alexcrichton/rust/rollup, r=alexcrichton
bors [Thu, 3 Jul 2014 21:46:47 +0000 (21:46 +0000)]
auto merge of #15377 : alexcrichton/rust/rollup, r=alexcrichton

Closes #15276 (Guide: if)
Closes #15280 (std::os - Add join_paths, make setenv non-utf8 capable)
Closes #15314 (Guide: functions)
Closes #15327 (Simplify PatIdent to contain an Ident rather than a Path)
Closes #15340 (Guide: add mutable binding section)
Closes #15342 (Fix ICE with nested macro_rules!-style macros)
Closes #15350 (Remove duplicated slash in install script path)
Closes #15351 (correct a few spelling mistakes in the tutorial)
Closes #15352 (librustc: Have the kind checker check sub-bounds in trait casts.)
Closes #15359 (Fix spelling errors.)
Closes #15361 (Rename set_broadast() to set_broadcast().)
Closes #15366 (Simplify creating a parser from a token tree)
Closes #15367 (Add examples for StrVector methods)
Closes #15372 (Vec::grow should use reserve_additional, Vec::reserve should check against capacity)
Closes #15373 (Fix minor issues in the documentation of libtime.)

10 years agoauto merge of #15076 : luqmana/rust/naim, r=pcwalton
bors [Thu, 3 Jul 2014 19:56:47 +0000 (19:56 +0000)]
auto merge of #15076 : luqmana/rust/naim, r=pcwalton

```Rust
struct With {
    x: int,
    f: NoCopy
}

#[no_mangle]
fn bar() {
    let mine = With { x: 3, f: NoCopy };
    match mine {
        c => {
            foo(c);
        }
    }
}

#[no_mangle]
fn foo(_: With) {}
```

Before:
```LLVM
define internal void @bar() unnamed_addr #1 {
entry-block:
  %mine = alloca %"struct.With<[]>"
  %__llmatch = alloca %"struct.With<[]>"*
  %c = alloca %"struct.With<[]>"
  %0 = getelementptr inbounds %"struct.With<[]>"* %mine, i32 0, i32 0
  store i64 3, i64* %0
  %1 = getelementptr inbounds %"struct.With<[]>"* %mine, i32 0, i32 1
  store %"struct.With<[]>"* %mine, %"struct.With<[]>"** %__llmatch
  br label %case_body

case_body:                                        ; preds = %entry-block
  %2 = load %"struct.With<[]>"** %__llmatch
  %3 = bitcast %"struct.With<[]>"* %2 to i8*
  %4 = bitcast %"struct.With<[]>"* %c to i8*
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %4, i8* %3, i64 8, i32 8, i1 false)
  %5 = load %"struct.With<[]>"* %c
  call void @foo(%"struct.With<[]>" %5)
  br label %join

join:                                             ; preds = %case_body
  ret void
}
```

After:
```LLVM
define internal void @bar() unnamed_addr #1 {
entry-block:
  %mine = alloca %"struct.With<[]>"
  %c = alloca %"struct.With<[]>"*
  %0 = getelementptr inbounds %"struct.With<[]>"* %mine, i32 0, i32 0
  store i64 3, i64* %0
  %1 = getelementptr inbounds %"struct.With<[]>"* %mine, i32 0, i32 1
  store %"struct.With<[]>"* %mine, %"struct.With<[]>"** %c
  br label %case_body

case_body:                                        ; preds = %entry-block
  %2 = load %"struct.With<[]>"** %c
  %3 = load %"struct.With<[]>"* %2
  call void @foo(%"struct.With<[]>" %3)
  br label %join

join:                                             ; preds = %case_body
  ret void
}
```

r? @pcwalton

10 years agoTest fixes from the rollup
Alex Crichton [Thu, 3 Jul 2014 19:01:33 +0000 (12:01 -0700)]
Test fixes from the rollup

10 years agoFix minor issues in the documentation of libtime.
OGINO Masanori [Thu, 3 Jul 2014 15:53:14 +0000 (00:53 +0900)]
Fix minor issues in the documentation of libtime.

- When the timezone is UTC, the "zone" field of the RFC 822 format is
  "GMT" (or "UT"), not "UTC."

- Although the name of `rfc3999` refers to RFC 3999, the documentation
  of it refers only to ISO 8601. This commit adds a description of the
  relation between ISO 8601 and RFC 3999.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
10 years agocollections: Fix conditional when reserving extra vec space
Erick Tryzelaar [Thu, 3 Jul 2014 15:45:28 +0000 (08:45 -0700)]
collections: Fix conditional when reserving extra vec space

10 years agocollections: grow should use the overflow-checked reserve_additional
Erick Tryzelaar [Thu, 3 Jul 2014 15:40:08 +0000 (08:40 -0700)]
collections: grow should use the overflow-checked reserve_additional

10 years agoAdd examples for StrVector methods
Jason Thompson [Thu, 3 Jul 2014 10:02:21 +0000 (06:02 -0400)]
Add examples for StrVector methods

- examples for connect and concat
- also fixed extra word in existing docs

10 years agoSimplify creating a parser from a token tree
Piotr Jawniak [Thu, 3 Jul 2014 09:42:24 +0000 (11:42 +0200)]
Simplify creating a parser from a token tree

Closes #15306

10 years agoRename set_broadast() to set_broadcast().
Joseph Crail [Thu, 3 Jul 2014 05:30:00 +0000 (01:30 -0400)]
Rename set_broadast() to set_broadcast().

10 years agoFix spelling errors.
Joseph Crail [Thu, 3 Jul 2014 01:27:07 +0000 (21:27 -0400)]
Fix spelling errors.

10 years agolibrustc: Have the kind checker check sub-bounds in trait casts.
Patrick Walton [Wed, 2 Jul 2014 20:27:14 +0000 (13:27 -0700)]
librustc: Have the kind checker check sub-bounds in trait casts.

This can break code that looked like:

    struct S<T> {
        val: T,
    }
    trait Gettable<T> {
        ...
    }
    impl<T: Copy> Gettable<T> for S<T> {
        ...
    }
    let t: Box<S<String>> = box S {
        val: "one".to_string(),
    };
    let a = t as Box<Gettable<String>>;
    //                        ^ note no `Copy` bound

Change this code to:

    impl<T> Gettable<T> for S<T> {
    //   ^ remove `Copy` bound
        ...
    }

Closes #14061.

[breaking-change]

10 years agocorrect a few spelling mistakes in the tutorial
Nathan Froyd [Wed, 2 Jul 2014 20:27:08 +0000 (16:27 -0400)]
correct a few spelling mistakes in the tutorial

10 years agoremove duplicated slash in install script path
Ruud van Asseldonk [Wed, 2 Jul 2014 19:37:33 +0000 (21:37 +0200)]
remove duplicated slash in install script path

10 years agoFix ICE with nested macro_rules!-style macros
Kevin Ballard [Wed, 2 Jul 2014 05:11:47 +0000 (22:11 -0700)]
Fix ICE with nested macro_rules!-style macros

Fixes #10536.

10 years agoGuide: add mutable binding section
Steve Klabnik [Wed, 2 Jul 2014 17:21:58 +0000 (13:21 -0400)]
Guide: add mutable binding section

Fixes #15334.

10 years agoSimplify PatIdent to contain an Ident rather than a Path
John Clements [Tue, 1 Jul 2014 01:02:14 +0000 (18:02 -0700)]
Simplify PatIdent to contain an Ident rather than a Path

Rationale: for what appear to be historical reasons only, the PatIdent contains
a Path rather than an Ident.  This means that there are many places in the code
where an ident is artificially promoted to a path, and---much more problematically---
a bunch of elements from a path are simply thrown away, which seems like an invitation
to some really nasty bugs.

This commit replaces the Path in a PatIdent with a SpannedIdent, which just contains an ident
and a span.

10 years agoRationals that have a 1 denom should print like ints
Paolo Falabella [Wed, 2 Jul 2014 15:39:43 +0000 (16:39 +0100)]
Rationals that have a 1 denom should print like ints

10 years agoGuide: functions
Steve Klabnik [Tue, 1 Jul 2014 22:05:50 +0000 (18:05 -0400)]
Guide: functions

Just a few words about functions and defining them.

10 years agoAdd os::join_paths, make setenv non-utf8 capable
Aaron Turon [Mon, 30 Jun 2014 17:19:02 +0000 (10:19 -0700)]
Add os::join_paths, make setenv non-utf8 capable

This commit changes `os` in three ways:

* It adds a `join_paths` function that is the converse to `split_paths`,
  easing manipulation of the `PATH` environment variable according to
  platform conventions.

* **Breaking change**: It changes `split_paths` to no longer drop empty paths, since they are
  meaningful to some shells (where they are synonymous with the current
  working directory).

* It changes `setenv` to take a `BytesContainer` rather than a `&str`
  value, since environment variables may have non-utf8 values on some
  platforms. Since `&str` is a `BytesContainer`, this is *not* a
  breaking change.

Along the way, it also refactors the `split_paths` function so that
`cfg` switches are applied internally (and the function header is given
only once). This fixes a bug: the doc comment had an example for only
one platform.

[breaking-change]

10 years agoGuide: if
Steve Klabnik [Mon, 30 Jun 2014 16:17:52 +0000 (12:17 -0400)]
Guide: if

10 years agoauto merge of #15370 : alexcrichton/rust/fix-cargo, r=pnkfelix
bors [Thu, 3 Jul 2014 16:56:51 +0000 (16:56 +0000)]
auto merge of #15370 : alexcrichton/rust/fix-cargo, r=pnkfelix

This was causing lots of ICEs in cargo. I sadly wasn't ever able to reduce the
test case down, but I presume that's because it has to do with node id
collisions which are pretty difficult to turn up...

10 years agorustc: Fix a call to with_path in trans_unboxing_shim
Alex Crichton [Thu, 3 Jul 2014 15:20:04 +0000 (08:20 -0700)]
rustc: Fix a call to with_path in trans_unboxing_shim

This was causing lots of ICEs in cargo. I sadly wasn't ever able to reduce the
test case down, but I presume that's because it has to do with node id
collisions which are pretty difficult to turn up...

10 years agoauto merge of #15338 : pfalabella/rust/rational-impl-2, r=alexcrichton
bors [Thu, 3 Jul 2014 14:21:35 +0000 (14:21 +0000)]
auto merge of #15338 : pfalabella/rust/rational-impl-2, r=alexcrichton

Tried squashing commits for https://github.com/rust-lang/rust/pull/15329, failed spectacularly.
This is a fresh PR for the same change.

@alexcrichton?

10 years agoauto merge of #15331 : Derecho/rust/master, r=alexcrichton
bors [Thu, 3 Jul 2014 12:36:36 +0000 (12:36 +0000)]
auto merge of #15331 : Derecho/rust/master, r=alexcrichton

One of the examples in the docs on adding documentation to rust code has an error that will cause the function to run endlessly rather than return the desired result, should someone actually implement this for some reason. While the error does not hinder the explanation of documenting code, it does look better if it is corrected.

10 years agoauto merge of #15199 : michaelwoerister/rust/cross-crate-stability, r=luqmana
bors [Thu, 3 Jul 2014 10:46:39 +0000 (10:46 +0000)]
auto merge of #15199 : michaelwoerister/rust/cross-crate-stability, r=luqmana

So far, type names generated for debuginfo where a bit sketchy. It was not clearly defined when a name should be fully qualified and when not, if region parameters should be shown or not, and other things like that.
This commit makes the debuginfo module responsible for creating type names instead of using `ppaux::ty_to_str()` and brings type names (as they show up in the DWARF information) in line with GCC and Clang:

* The name of the type being described is unqualified. It's path is defined by its position in the namespace hierarchy.
* Type arguments are always fully qualified, no matter if they would actually be in scope at the type definition location.

Care is also taken to make type names consistent across crate boundaries. That is, the code now tries make the type name the same, regardless if the type is in the local crate or reconstructed from metadata. Otherwise LLVM will complain about violating the one-definition-rule when using link-time-optimization.

This commit also removes all source location information from type descriptions because these cannot be reconstructed for types instantiated from metadata. Again, with LTO enabled, this can lead to two versions of the debuginfo type description, one with and one without source location information, which then triggers the LLVM ODR assertion.
Fortunately, source location information about types is rarely used, so this has little impact. Once source location information is preserved in metadata (#1972) it can also be re-enabled for type descriptions.

`RUSTFLAGS=-g make check` no works again for me locally, including the LTO test cases (note that I've taken care of #15156 by reverting the change in LLVM that @luqmana identified as the culprit for that issue).

10 years agoauto merge of #15078 : jakub-/rust/pattern-matching-refactor-vol-2, r=pnkfelix
bors [Thu, 3 Jul 2014 08:56:36 +0000 (08:56 +0000)]
auto merge of #15078 : jakub-/rust/pattern-matching-refactor-vol-2, r=pnkfelix

I believe there's more commonality to be found there but maybe small steps are better. I'm also in the process of documenting what I can, I will see if I can add it to this PR.

It also seems to me that ideally some of this stuff (especially the pattern sanity check) could live as a separate compiler-agnostic module but I understand this may not be the right time (if not the worst) to start the process of modularising rustc.

10 years agoImprove code reuse between trans/_match.rs and check_match.rs
Jakub Wieczorek [Sat, 21 Jun 2014 12:56:23 +0000 (14:56 +0200)]
Improve code reuse between trans/_match.rs and check_match.rs

The specialization logic for patterns is really the same in both
exhaustiveness/reachability checking and codegen.

10 years agoauto merge of #15324 : sneves/rust/master, r=alexcrichton
bors [Thu, 3 Jul 2014 06:11:38 +0000 (06:11 +0000)]
auto merge of #15324 : sneves/rust/master, r=alexcrichton

The current implementation of `rotate_left` and `rotate_right` are incorrect when the rotation amount is 0, or a multiple of the input's bitsize. When `n = 0`, the expression

    (self >> n) | (self << ($BITS - n))

results in a shift left by `$BITS` bits, which is undefined behavior (see https://github.com/rust-lang/rust/issues/10183), and currently results in a hardcoded `-1` value, instead of the original input value. Reducing `($BITS - n)` modulo `$BITS`, simplified to `(-n % $BITS)`, fixes this problem.

10 years agoauto merge of #15087 : iliekturtles/rust/13810-make-install-mingw32, r=brson
bors [Thu, 3 Jul 2014 03:41:39 +0000 (03:41 +0000)]
auto merge of #15087 : iliekturtles/rust/13810-make-install-mingw32, r=brson

Short-term fix per @brson's comment: https://github.com/rust-lang/rust/issues/13810#issuecomment-43562843. Tested on Win7 x64 and Linux.

One possible issue is that `install.sh` doesn't have a `need_cmd` definition like `configure` does. Should this be ported over as well?

Platform-detection code from `configure` copied over to `install.sh` in
order to special case the lib dir being `bin` on Windows instead of
`lib`.

Short-term fix for #13810.

10 years agoBuild rustc with /LARGEADDRESSAWARE on windows.
Luqman Aden [Thu, 3 Jul 2014 03:22:22 +0000 (20:22 -0700)]
Build rustc with /LARGEADDRESSAWARE on windows.

10 years agolibrustc: Don't schedule redundant cleanups.
Luqman Aden [Sun, 22 Jun 2014 23:20:44 +0000 (19:20 -0400)]
librustc: Don't schedule redundant cleanups.

10 years agolibrustc: Use different alloca slot for non-move bindings.
Luqman Aden [Sat, 21 Jun 2014 21:05:05 +0000 (17:05 -0400)]
librustc: Use different alloca slot for non-move bindings.

10 years agolibrustc: Don't create extra alloca slot for by value bindings in match.
Luqman Aden [Sat, 21 Jun 2014 12:01:12 +0000 (08:01 -0400)]
librustc: Don't create extra alloca slot for by value bindings in match.

10 years agoauto merge of #15325 : pcwalton/rust/trait-impl-bound-mismatch, r=pnkfelix
bors [Thu, 3 Jul 2014 01:06:38 +0000 (01:06 +0000)]
auto merge of #15325 : pcwalton/rust/trait-impl-bound-mismatch, r=pnkfelix

with the corresponding trait parameter bounds.

This is a version of the patch in PR #12611 by Florian Hahn, modified to
address Niko's feedback.

It does not address the issue of duplicate type parameter bounds, nor
does it address the issue of implementation-defined methods that contain
*fewer* bounds than the trait, because Niko's review indicates that this
should not be necessary (and indeed I believe it is not). A test has
been added to ensure that this works.

This will break code like:

    trait Foo {
        fn bar<T:Baz>();
    }

    impl Foo for Boo {
        fn bar<T:Baz + Quux>() { ... }
        //             ^~~~ ERROR
    }

This will be rejected because the implementation requires *more* bounds
than the trait. It can be fixed by either adding the missing bound to
the trait:

    trait Foo {
        fn bar<T:Baz + Quux>();
        //             ^~~~
    }

    impl Foo for Boo {
        fn bar<T:Baz + Quux>() { ... }  // OK
    }

Or by removing the bound from the impl:

    trait Foo {
        fn bar<T:Baz>();
    }

    impl Foo for Boo {
        fn bar<T:Baz>() { ... }  // OK
        //       ^ remove Quux
    }

This patch imports the relevant tests from #2687, as well as the test
case in #5886, which is fixed as well by this patch.

Closes #2687.
Closes #5886.

[breaking-change]

r? @pnkfelix

10 years agoinstall: Correct libdir for Windows installs.
Mike Boutin [Sat, 21 Jun 2014 18:55:08 +0000 (14:55 -0400)]
install: Correct libdir for Windows installs.

Platform-detection code from `configure` copied over to `install.sh`
in order to special case the lib dir being `bin` on Windows instead
of `lib`.

Short-term fix for #13810.

10 years agoauto merge of #15323 : alexcrichton/rust/no-travis-wait, r=huonw
bors [Wed, 2 Jul 2014 23:16:40 +0000 (23:16 +0000)]
auto merge of #15323 : alexcrichton/rust/no-travis-wait, r=huonw

It's looking like we're still timing out all over the place with travis_wait
because the entire `make -j4 rustc-stage1` command is taking too long. Instead,
achieve roughly the same idea by just having `-Z time-passes` printing
information. We shouldn't have a pass that takes longer than 10 minutes in
isolation.

10 years agoFix rotate_{left, right} for multiple of bitsize rotation amounts
Samuel Neves [Wed, 2 Jul 2014 03:58:23 +0000 (04:58 +0100)]
Fix rotate_{left, right} for multiple of bitsize rotation amounts

Add additional rotation tests

10 years agoauto merge of #15313 : pcwalton/rust/overloaded-call-expr-use, r=alexcrichton
bors [Wed, 2 Jul 2014 21:26:40 +0000 (21:26 +0000)]
auto merge of #15313 : pcwalton/rust/overloaded-call-expr-use, r=alexcrichton

with overloaded calls.

This enforces the mutability and borrow restrictions around overloaded
calls.

[breaking-change]

Closes #12223.

r? @alexcrichton

10 years agoauto merge of #15222 : alexcrichton/rust/relnotes, r=brson
bors [Wed, 2 Jul 2014 18:41:38 +0000 (18:41 +0000)]
auto merge of #15222 : alexcrichton/rust/relnotes, r=brson

Detailed notes have their skeleton [on the wiki](https://github.com/rust-lang/rust/wiki/Doc-detailed-release-notes) (and need filling out).

10 years agoauto merge of #15186 : jakub-/rust/issue-15104, r=pnkfelix
bors [Wed, 2 Jul 2014 16:56:32 +0000 (16:56 +0000)]
auto merge of #15186 : jakub-/rust/issue-15104, r=pnkfelix

10 years agoChange exhaustiveness analysis to permit multiple constructors per pattern
Jakub Wieczorek [Wed, 25 Jun 2014 17:07:37 +0000 (19:07 +0200)]
Change exhaustiveness analysis to permit multiple constructors per pattern

Slice patterns are different from the rest in that a single slice pattern
does not have a distinct constructor if it contains a variable-length subslice
pattern. For example, the pattern [a, b, ..tail] can match a slice of length 2, 3, 4
and so on.

As a result, the decision tree for exhaustiveness and redundancy analysis should
explore each of those constructors separately to determine if the pattern could be useful
when specialized for any of them.

10 years agoRationals that have a 1 denom should print like ints
Paolo Falabella [Wed, 2 Jul 2014 15:39:43 +0000 (16:39 +0100)]
Rationals that have a 1 denom should print like ints

10 years agoauto merge of #15286 : alexcrichton/rust/channel-stability, r=cmr
bors [Wed, 2 Jul 2014 13:52:00 +0000 (13:52 +0000)]
auto merge of #15286 : alexcrichton/rust/channel-stability, r=cmr

* channel() - #[unstable]. This will likely remain forever

* sync_channel(n: int) - #[unstable with comment]. Concerns have ben raised
  about the usage of the term "synchronous channel" because that generally only
  applies to the case where n == 0. If n > 0 then these channels are often
  referred to as buffered channels.

* Sender::send(), SyncSender::send(), Receiver::recv() - #[experimental]. These
  functions directly violate the general guideline of not providing a failing
  and non-failing variant. These functions were explicitly selected for being
  excused from this guideline, but recent discussions have cast doubt on that
  decision. These functions are #[experimental] for now until a decision is made
  as they are candidates for removal.

* Sender::send_opt(), SyncSender::send_opt(), Receiver::recv_opt() - #[unstable
  with a comment]. If the above no-`_opt` functions are removed, these functions
  will be renamed to the non-`_opt` variants.

* SyncSender::try_send(), Receiver::try_recv() - #[unstable with a comment].
  These return types of these functions to not follow general conventions. They
  are consistent with the rest of the api, but not with the rest of the
  libraries. Until their return types are nailed down, these functions are
  #[unstable].

* Receiver::iter() - #[unstable]. This will likely remain forever.

* std::com::select - #[experimental]. The functionality is likely to remain in
  some form forever, but it is highly unlikely to remain in its current form. It
  is unknown how much breakage this will cause if and when the api is
  redesigned, so the entire module and its components are all experimental.

* DuplexStream - #[deprecated]. This type is not composable with other channels
  in terms of selection or other expected locations. It can also not be used
  with ChanWriter and ChanReader, for example. Due to it being only lightly
  used, and easily replaced with two channels, this type is being deprecated and
  slated for removal.

* Clone for {,Sync}Sender - #[unstable]. This will likely remain forever.

10 years agoApply stability attributes to std::comm
Alex Crichton [Mon, 30 Jun 2014 22:10:57 +0000 (15:10 -0700)]
Apply stability attributes to std::comm

* channel() - #[unstable]. This will likely remain forever

* sync_channel(n: int) - #[unstable with comment]. Concerns have ben raised
  about the usage of the term "synchronous channel" because that generally only
  applies to the case where n == 0. If n > 0 then these channels are often
  referred to as buffered channels.

* Sender::send(), SyncSender::send(), Receiver::recv() - #[experimental]. These
  functions directly violate the general guideline of not providing a failing
  and non-failing variant. These functions were explicitly selected for being
  excused from this guideline, but recent discussions have cast doubt on that
  decision. These functions are #[experimental] for now until a decision is made
  as they are candidates for removal.

* Sender::send_opt(), SyncSender::send_opt(), Receiver::recv_opt() - #[unstable
  with a comment]. If the above no-`_opt` functions are removed, these functions
  will be renamed to the non-`_opt` variants.

* SyncSender::try_send(), Receiver::try_recv() - #[unstable with a comment].
  These return types of these functions to not follow general conventions. They
  are consistent with the rest of the api, but not with the rest of the
  libraries. Until their return types are nailed down, these functions are
  #[unstable].

* Receiver::iter() - #[unstable]. This will likely remain forever.

* std::com::select - #[experimental]. The functionality is likely to remain in
  some form forever, but it is highly unlikely to remain in its current form. It
  is unknown how much breakage this will cause if and when the api is
  redesigned, so the entire module and its components are all experimental.

* DuplexStream - #[deprecated]. This type is not composable with other channels
  in terms of selection or other expected locations. It can also not be used
  with ChanWriter and ChanReader, for example. Due to it being only lightly
  used, and easily replaced with two channels, this type is being deprecated and
  slated for removal.

* Clone for {,Sync}Sender - #[unstable]. This will likely remain forever.

10 years agoauto merge of #15310 : pcwalton/rust/tests-for-12223, r=brson
bors [Wed, 2 Jul 2014 12:06:34 +0000 (12:06 +0000)]
auto merge of #15310 : pcwalton/rust/tests-for-12223, r=brson

still in scope".

This issue was fixed by PR #12828 and #5781. All that was left was to
add tests.

Closes #12223.

10 years agodebuginfo: Make names of types in debuginfo reliable and omit source locations from...
Michael Woerister [Thu, 26 Jun 2014 11:46:54 +0000 (13:46 +0200)]
debuginfo: Make names of types in debuginfo reliable and omit source locations from debug info type descriptions.

So far, type names generated for debuginfo where a bit sketchy. It was not clearly defined when a name should be fully qualified and when not, if region parameters should be shown or not, and other things like that.
This commit makes the debuginfo module responsible for creating type names instead of using ppaux::ty_to_str() and brings type names, as they show up in the DWARF information, in line with GCC and Clang:

* The name of the type being described is unqualified. It's path is defined by its position in the namespace hierarchy.
* Type arguments are always fully qualified, no matter if they would actually be in scope at the type definition location.

Care is also taken to reliably make type names consistent across crate boundaries. That is, the code now tries make the type name the same, regardless if the type is in the local crate or reconstructed from metadata. Otherwise LLVM will complain about violating the one-definition-rule when using link-time-optimization.

This commit also removes all source location information from type descriptions because these cannot be reconstructed for types instantiated from metadata. Again, with LTO enabled, this can lead to two versions of the debuginfo type description, one with and one without source location information, which then triggers the LLVM ODR assertion.
Fortunately, source location information about types is rarely used, so this has little impact. Once source location information is preserved in metadata (#1972) it can also be reenabled for type descriptions.

10 years agoauto merge of #15265 : omasanori/rust/udp, r=alexcrichton
bors [Wed, 2 Jul 2014 09:21:39 +0000 (09:21 +0000)]
auto merge of #15265 : omasanori/rust/udp, r=alexcrichton

POSIX has recvfrom(2) and sendto(2), but their name seem not to be suitable with Rust. We already renamed getpeername(2) and getsockname(2), so I think it makes sense.

Alternatively, `receive_from` would be fine. However, we have `.recv()` so I chose `recv_from`.

What do you think? If this makes sense, should I provide `recvfrom` and `sendto` deprecated methods just calling new methods for compatibility?

10 years agoFix example in docs on documentation
Derecho [Wed, 2 Jul 2014 08:53:30 +0000 (10:53 +0200)]
Fix example in docs on documentation

10 years agoauto merge of #15257 : erickt/rust/hashmap, r=alexcrichton
bors [Wed, 2 Jul 2014 07:31:41 +0000 (07:31 +0000)]
auto merge of #15257 : erickt/rust/hashmap, r=alexcrichton

While `HashMap::new` and `HashMap::with_capacity` were being initialized with a random `SipHasher`, it turns out that `HashMap::from_iter` was just using the default instance of `SipHasher`, which wasn't randomized. This closes that bug, and also inlines some important methods.

10 years agoauto merge of #15085 : brson/rust/stridx, r=alexcrichton
bors [Wed, 2 Jul 2014 05:41:30 +0000 (05:41 +0000)]
auto merge of #15085 : brson/rust/stridx, r=alexcrichton

Being able to index into the bytes of a string encourages
poor UTF-8 hygiene. To get a view of `&[u8]` from either
a `String` or `&str` slice, use the `as_bytes()` method.

Closes #12710.

[breaking-change]

If the diffstat is any indication this shouldn't have a huge impact but it will have some. Most changes in the `str` and `path` module. A lot of the existing usages were in tests where ascii is expected. There are a number of other legit uses where the characters are known to be ascii.

10 years agolibrustc: Properly compare implementation method type parameter bounds
Patrick Walton [Wed, 2 Jul 2014 04:59:16 +0000 (21:59 -0700)]
librustc: Properly compare implementation method type parameter bounds
with the corresponding trait parameter bounds.

This is a version of the patch in PR #12611 by Florian Hahn, modified to
address Niko's feedback.

It does not address the issue of duplicate type parameter bounds, nor
does it address the issue of implementation-defined methods that contain
*fewer* bounds than the trait, because Niko's review indicates that this
should not be necessary (and indeed I believe it is not). A test has
been added to ensure that this works.

This will break code like:

    trait Foo {
        fn bar<T:Baz>();
    }

    impl Foo for Boo {
        fn bar<T:Baz + Quux>() { ... }
        //             ^~~~ ERROR
    }

This will be rejected because the implementation requires *more* bounds
than the trait. It can be fixed by either adding the missing bound to
the trait:

    trait Foo {
        fn bar<T:Baz + Quux>();
        //             ^~~~
    }

    impl Foo for Boo {
        fn bar<T:Baz + Quux>() { ... }  // OK
    }

Or by removing the bound from the impl:

    trait Foo {
        fn bar<T:Baz>();
    }

    impl Foo for Boo {
        fn bar<T:Baz>() { ... }  // OK
        //       ^ remove Quux
    }

This patch imports the relevant tests from #2687, as well as the test
case in #5886, which is fixed as well by this patch.

Closes #2687.
Closes #5886.

[breaking-change]

10 years agoauto merge of #15069 : luqmana/rust/cia, r=pcwalton
bors [Wed, 2 Jul 2014 03:56:29 +0000 (03:56 +0000)]
auto merge of #15069 : luqmana/rust/cia, r=pcwalton

Fixes #11205.

10 years agotravis: Move from travis_wait to time-passes
Alex Crichton [Wed, 2 Jul 2014 03:19:26 +0000 (20:19 -0700)]
travis: Move from travis_wait to time-passes

It's looking like we're still timing out all over the place with travis_wait
because the entire `make -j4 rustc-stage1` command is taking too long. Instead,
achieve roughly the same idea by just having `-Z time-passes` printing
information. We shouldn't have a pass that takes longer than 10 minutes in
isolation.

10 years agorustc: Remove `&str` indexing from the language.
Brian Anderson [Fri, 20 Jun 2014 01:22:33 +0000 (18:22 -0700)]
rustc: Remove `&str` indexing from the language.

Being able to index into the bytes of a string encourages
poor UTF-8 hygiene. To get a view of `&[u8]` from either
a `String` or `&str` slice, use the `as_bytes()` method.

Closes #12710.

[breaking-change]

10 years agoauto merge of #15229 : steveklabnik/rust/if, r=cmr
bors [Wed, 2 Jul 2014 02:11:31 +0000 (02:11 +0000)]
auto merge of #15229 : steveklabnik/rust/if, r=cmr

Whew. So much here! Feedback very welcome.

This is the first part where we actually start learning things. I'd like to think I struck a good balance of explaining enough details, without getting too bogged down, and without being confusing... but of course I'd think that. :wink:

As I mention in the commit comment, We probably want to move the guessing game to the rust-lang org, rather than just having it on my GitHub. Or, I could put the code inline. I think it'd be neat to have it as a project, so people can pull it down with Cargo. Until we make that decision, I'll just leave this here.

10 years agoGuide: variable bindings.
Steve Klabnik [Fri, 27 Jun 2014 22:51:04 +0000 (18:51 -0400)]
Guide: variable bindings.

Whew! Who knew there was so much to say about variables.

We probably want to move the guessing game to the rust-lang org, rather than
just having it on my GitHub. Or, I could put the code inline. I think it'd be
neat to have it as a project, so people can pull it down with Cargo. Until we
make that decision, I'll just leave this here.

10 years agoauto merge of #15295 : TeXitoi/rust/relicense-shootout-mandelbrot, r=brson
bors [Wed, 2 Jul 2014 00:21:36 +0000 (00:21 +0000)]
auto merge of #15295 : TeXitoi/rust/relicense-shootout-mandelbrot, r=brson

Part of #14248

Main authors:
- @Ryman: OK
- @TeXitoi: OK
- @pcwalton: OK

Minor authors:
- @brson: OK
- @alexcrichton: OK
- @kballard: OK

Remark: @tedhorst was a main contributor, but its contribution
disapear with @pcwalton rewrite at af4ea11

@brson OK?

10 years agoAdd `recvfrom` and `sendto`.
OGINO Masanori [Mon, 30 Jun 2014 23:34:18 +0000 (08:34 +0900)]
Add `recvfrom` and `sendto`.

We leave them for compatibility, but mark them as deprecated.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
10 years agoRename recvfrom -> recv_from, sendto -> send_to.
OGINO Masanori [Mon, 30 Jun 2014 03:08:27 +0000 (12:08 +0900)]
Rename recvfrom -> recv_from, sendto -> send_to.

POSIX has recvfrom(2) and sendto(2), but their name seem not to be
suitable with Rust. We already renamed getpeername(2) and
getsockname(2), so I think it makes sense.

Alternatively, `receive_from` would be fine. However, we have `.recv()`
so I chose `recv_from`.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
10 years agolibrustc: Fix `expr_use_visitor` (and, transitively, the borrow check)
Patrick Walton [Tue, 1 Jul 2014 21:30:33 +0000 (14:30 -0700)]
librustc: Fix `expr_use_visitor` (and, transitively, the borrow check)
with overloaded calls.

This enforces the mutability and borrow restrictions around overloaded
calls.

Closes #14774.

[breaking-change]

10 years agoauto merge of #15292 : alxgnon/rust/vim_syntax_cleanup, r=cmr
bors [Tue, 1 Jul 2014 21:26:33 +0000 (21:26 +0000)]
auto merge of #15292 : alxgnon/rust/vim_syntax_cleanup, r=cmr

- Fix a couple mistakes:
  - `Ordering` is an enum, not a trait.
  - `Container` is now named `Collection`.
  - Add missing `CheckedDiv`.
  - Remove obsolete `OwnedVector`.
- Reorganize some lines to match [prelude's arrangement](http://doc.rust-lang.org/std/prelude/#reexports), making mistakes easier to spot in the future.

10 years agoauto merge of #15251 : AlisdairO/rust/master, r=alexcrichton
bors [Tue, 1 Jul 2014 19:37:17 +0000 (19:37 +0000)]
auto merge of #15251 : AlisdairO/rust/master, r=alexcrichton

I've seen quite a bit of confusion around regarding the use of Rc, so I thought I'd take a stab at adding some examples.

10 years agotest: Add tests for issue #12223, "drop allowed while active borrows
Patrick Walton [Tue, 1 Jul 2014 18:47:21 +0000 (11:47 -0700)]
test: Add tests for issue #12223, "drop allowed while active borrows
still in scope".

This issue was fixed by PR #12828 and #5781. All that was left was to
add tests.

Closes #12223.

10 years agoauto merge of #15308 : brson/rust/intro, r=alexcrichton
bors [Tue, 1 Jul 2014 17:51:41 +0000 (17:51 +0000)]
auto merge of #15308 : brson/rust/intro, r=alexcrichton

This was asked on HN, and it's easy to clarify.

10 years agodoc: Clarify that an error is a compiler error
Brian Anderson [Tue, 1 Jul 2014 17:46:29 +0000 (10:46 -0700)]
doc: Clarify that an error is a compiler error

This was asked on HN, and it's easy to clarify.

10 years agoImprove rustdocs for Rc, add examples
Alisdair Owens [Sun, 29 Jun 2014 15:33:42 +0000 (16:33 +0100)]
Improve rustdocs for Rc, add examples

10 years agoRe-arrange TOC.
Steve Klabnik [Fri, 27 Jun 2014 21:31:28 +0000 (17:31 -0400)]
Re-arrange TOC.

I'm going to move testing to be right AFTER the guessing game. I wanted it
to be borderline TDD, but I think that, since the first example is just one
file, it might be a bit overkill.

I'm doing this in its own commit to hopefully avoid merge conflicts.

10 years agoauto merge of #15301 : jasonthompson/rust/docs/str2, r=alexcrichton
bors [Tue, 1 Jul 2014 14:41:48 +0000 (14:41 +0000)]
auto merge of #15301 : jasonthompson/rust/docs/str2, r=alexcrichton

10 years agoAdd examples for from_utf8_owned, from_char, from_chars, from_byte
Jason Thompson [Mon, 30 Jun 2014 18:53:04 +0000 (14:53 -0400)]
Add examples for from_utf8_owned, from_char, from_chars, from_byte

10 years agostd: move the hash docstring over to std::hash.
Erick Tryzelaar [Tue, 1 Jul 2014 14:29:16 +0000 (07:29 -0700)]
std: move the hash docstring over to std::hash.

10 years agoauto merge of #15289 : aturon/rust/libstd-stability, r=alexcrichton
bors [Tue, 1 Jul 2014 10:11:34 +0000 (10:11 +0000)]
auto merge of #15289 : aturon/rust/libstd-stability, r=alexcrichton

Earlier commits have established a baseline of `experimental` stability
for all crates under the facade (so their contents are considered
experimental within libstd). Since `experimental` is `allow` by
default, we should use the same baseline stability for libstd itself.

This commit adds `experimental` tags to all of the modules defined in
`std`, and `unstable` to `std` itself.

10 years agoauto merge of #15288 : brson/rust/cleanslice, r=alexcrichton
bors [Tue, 1 Jul 2014 08:21:33 +0000 (08:21 +0000)]
auto merge of #15288 : brson/rust/cleanslice, r=alexcrichton

This does two things:

* Reorganizes the declaration order to be more readable, less random.
* Removes the `slice::traits` module, a public module that does nothing but declare impls of `cmp` traits.

10 years agorelicense shootout-mandelbrot.rs
Guillaume Pinot [Tue, 1 Jul 2014 08:00:27 +0000 (10:00 +0200)]
relicense shootout-mandelbrot.rs

Part of #14248

Main authors:
- @Ryman: OK
- @TeXitoi: OK
- @pcwalton: OK

Minor authors:
- @brson: OK
- @alexcrichton: OK
- @kballard: OK

Remark: @tedhorst was a main contributor, but its contribution
disapear with @pcwalton rewrite at af4ea11

10 years agoauto merge of #15263 : aturon/rust/rustdoc-stability-index, r=alexcrichton
bors [Tue, 1 Jul 2014 06:31:35 +0000 (06:31 +0000)]
auto merge of #15263 : aturon/rust/rustdoc-stability-index, r=alexcrichton

This commit hooks rustdoc into the stability index infrastructure in two
ways:

1. It looks up stability levels via the index, rather than by manual
attributes.

2. It adds stability level information throughout rustdoc output, rather
than just at the top header. In particular, a stability color (with
mouseover text) appears next to essentially every item that appears
in rustdoc's HTML output.

Along the way, the stability index code has been lightly refactored.

10 years agolibstd: set baseline stability levels.
Aaron Turon [Tue, 1 Jul 2014 00:22:40 +0000 (17:22 -0700)]
libstd: set baseline stability levels.

Earlier commits have established a baseline of `experimental` stability
for all crates under the facade (so their contents are considered
experimental within libstd). Since `experimental` is `allow` by
default, we should use the same baseline stability for libstd itself.

This commit adds `experimental` tags to all of the modules defined in
`std`, and `unstable` to `std` itself.

10 years agorustdoc: incorporate stability index throughout
Aaron Turon [Thu, 26 Jun 2014 18:37:39 +0000 (11:37 -0700)]
rustdoc: incorporate stability index throughout

This commit hooks rustdoc into the stability index infrastructure in two
ways:

1. It looks up stability levels via the index, rather than by manual
attributes.

2. It adds stability level information throughout rustdoc output, rather
than just at the top header. In particular, a stability color (with
mouseover text) appears next to essentially every item that appears
in rustdoc's HTML output.

Along the way, the stability index code has been lightly refactored.

10 years agoVim syntax file types and traits cleanup
Alexandre Gagnon [Tue, 1 Jul 2014 04:52:51 +0000 (00:52 -0400)]
Vim syntax file types and traits cleanup

10 years agoauto merge of #15281 : alexcrichton/rust/show-for-show, r=kballard
bors [Tue, 1 Jul 2014 04:41:32 +0000 (04:41 +0000)]
auto merge of #15281 : alexcrichton/rust/show-for-show, r=kballard

This makes printing a `Show` trait object much easier.

10 years agoauto merge of #15242 : pcwalton/rust/self-in-trait-methods, r=alexcrichton
bors [Tue, 1 Jul 2014 02:51:33 +0000 (02:51 +0000)]
auto merge of #15242 : pcwalton/rust/self-in-trait-methods, r=alexcrichton

I can't believe this worked! I believe that the way the ABI and
immediates work mean that this Just Works.

Closes #10672.

r? @alexcrichton

10 years agolibrustc: Permit by-value-self methods to be invoked on objects
Patrick Walton [Sat, 28 Jun 2014 19:55:17 +0000 (12:55 -0700)]
librustc: Permit by-value-self methods to be invoked on objects
referenced by boxes.

This is done by creating a shim function that handles the cleanup of the
box properly.

Closes #10672.

10 years agoauto merge of #15271 : jasonthompson/rust/docs/str, r=huonw
bors [Tue, 1 Jul 2014 01:01:36 +0000 (01:01 +0000)]
auto merge of #15271 : jasonthompson/rust/docs/str, r=huonw

I'm working on adding examples to the API documentation. Should future pull requests include examples for more than one function? Or is this about the right size for a pull request?

10 years agoauto merge of #15247 : smenardpw/rust/patch-1, r=alexcrichton
bors [Mon, 30 Jun 2014 23:06:35 +0000 (23:06 +0000)]
auto merge of #15247 : smenardpw/rust/patch-1, r=alexcrichton

./hello_world is not recognized on Windows.
We can type either hello_world or hello_world.exe to run the executable. I chose "hello_world.exe", which seems more conventional on Windows.

10 years agocore: Remove the unnecessary 'traits' module from 'slice'
Brian Anderson [Mon, 30 Jun 2014 22:43:13 +0000 (15:43 -0700)]
core: Remove the unnecessary 'traits' module from 'slice'

This is only breaking for code that references the empty `slice::traits`
module.

[breaking-change]

10 years agocore: Reorganize slice module.
Brian Anderson [Mon, 30 Jun 2014 20:58:53 +0000 (13:58 -0700)]
core: Reorganize slice module.

This is just moving things around so they are defined in a logical order.

10 years agoauto merge of #15238 : aochagavia/rust/json, r=alexcrichton
bors [Mon, 30 Jun 2014 21:16:32 +0000 (21:16 +0000)]
auto merge of #15238 : aochagavia/rust/json, r=alexcrichton

### Breaking changes:

* **Removed unnecessary `box` from enum variant (`Object(Box<Object>)` becomes `Object(Object)`)**
* **Deprecated `Encoder::str_encode`**

### Other changes:

* Tried to make the code more idiomatic
* Renamed the `wr` field of the `Encoder` and `PrettyEncoder` structs to `writer`
* Replaced some `from_utf8` by `from_utf8_owned` to avoid unnecessary allocations
* Removed unnecessary `unsafe` code
* Added `encode` and `decode` shortcut functions
* Implemented `FromStr` for `Json`
* Implemented `ToJson` for tuples of arity up to 12
* Fixed some details in the documentation

### Questions

* ~~The `encode` shortcut function does the same as the `Encoder::str_encode` function. It seems wrong to me that two functions do exactly the same. Should we deprecate `Encoder::str_encode`?~~
* ~~Do we really want the ToJson trait for tuples? At the moment we have it for (), (A, B), (A, B, C). I would like to remove them.~~
* ~~We are using `String` as key in the `TreeMap` representing a `Json` object. It would be better to use `&str`, but this would require to annotate lots of lifetimes. Is there any easy solution for this?~~
* There is a lot of duplicated code (`PrettyEncoder` copies about 50 lines from `Encoder`). In an OO language this could be solved very elegantly by using inheritance and overriding. What can we do here to reduce the amount of boilerplate?

[breaking-change]

10 years agoImplement ToJson for all tuples
Adolfo Ochagavía [Sun, 29 Jun 2014 09:33:45 +0000 (11:33 +0200)]
Implement ToJson for all tuples

10 years agoFix issues in librustdoc
Adolfo Ochagavía [Sat, 28 Jun 2014 17:28:29 +0000 (19:28 +0200)]
Fix issues in librustdoc

10 years agoFix issue with tests
Adolfo Ochagavía [Sat, 28 Jun 2014 15:27:29 +0000 (17:27 +0200)]
Fix issue with tests

10 years agoFix issues in libtest
Adolfo Ochagavía [Sat, 28 Jun 2014 14:37:28 +0000 (16:37 +0200)]
Fix issues in libtest

10 years agoFix JSON documentation
Adolfo Ochagavía [Sat, 28 Jun 2014 13:59:45 +0000 (15:59 +0200)]
Fix JSON documentation

Fixed some errors, removed some code examples and added usage of the
`encode` and `decode` functions.

10 years agoImplement FromStr for Json
Adolfo Ochagavía [Sat, 28 Jun 2014 13:39:49 +0000 (15:39 +0200)]
Implement FromStr for Json

10 years agoAdd `encode` and `decode` shortcut functions
Adolfo Ochagavía [Sat, 28 Jun 2014 13:33:37 +0000 (15:33 +0200)]
Add `encode` and `decode` shortcut functions

Now you can just use `json::encode` and `json::decode`, which is very
practical

**Deprecated `Encoder::str_encode` in favor of `json::encode`**

[breaking-change]

10 years agoRemoved unnecessary Box
Adolfo Ochagavía [Sat, 28 Jun 2014 12:41:40 +0000 (14:41 +0200)]
Removed unnecessary Box

10 years agoJSON cleanup
Adolfo Ochagavía [Sat, 28 Jun 2014 12:34:58 +0000 (14:34 +0200)]
JSON cleanup

* Tried to make the code more idiomatic
* Renamed the `wr` field of the `Encoder` and `PrettyEncoder` structs to `writer`
* Replaced some `from_utf8` by `from_utf8_owned` to avoid unnecessary allocations
* Removed unnecessary `unsafe` code

10 years agoAdd `impl Show for &Show`
Alex Crichton [Mon, 30 Jun 2014 19:33:37 +0000 (12:33 -0700)]
Add `impl Show for &Show`

This makes printing a `Show` trait object much easier.

10 years agoauto merge of #14613 : schmee/rust/utf16-iterator, r=huonw
bors [Mon, 30 Jun 2014 19:26:35 +0000 (19:26 +0000)]
auto merge of #14613 : schmee/rust/utf16-iterator, r=huonw

Closes #14358.

~~The tests are not yet moved to `utf16_iter`, so this probably won't compile. I'm submitting this PR anyway so it can be reviewed and since it was mentioned in #14611.~~ EDIT: Tests now use `utf16_iter`.

This deprecates `.to_utf16`. `x.to_utf16()` should be replaced by either `x.utf16_iter().collect::<Vec<u16>>()` (the type annotation may be optional), or just `x.utf16_iter()` directly, if it can be used in an iterator context.

[breaking-change]

cc @huonw