Commit Graph

30226 Commits

Author SHA1 Message Date
Joseph Crail
4a6fcc51a0 Rename set_broadast() to set_broadcast(). 2014-07-03 12:54:51 -07:00
Joseph Crail
e3fa23bcb6 Fix spelling errors. 2014-07-03 12:54:51 -07:00
Patrick Walton
8297edd549 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]
2014-07-03 12:54:51 -07:00
Nathan Froyd
704f11d3d8 correct a few spelling mistakes in the tutorial 2014-07-03 12:54:51 -07:00
Ruud van Asseldonk
5d36005066 remove duplicated slash in install script path 2014-07-03 12:54:51 -07:00
Kevin Ballard
b81905eedb Fix ICE with nested macro_rules!-style macros
Fixes #10536.
2014-07-03 12:54:51 -07:00
Steve Klabnik
9868b65b15 Guide: add mutable binding section
Fixes #15334.
2014-07-03 12:54:51 -07:00
John Clements
e38cb972dc 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.
2014-07-03 12:54:51 -07:00
Paolo Falabella
cff79ab563 Rationals that have a 1 denom should print like ints 2014-07-03 12:54:51 -07:00
Steve Klabnik
faf5d926ec Guide: functions
Just a few words about functions and defining them.
2014-07-03 10:55:19 -07:00
Aaron Turon
8877b81f2c 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]
2014-07-03 10:55:14 -07:00
Steve Klabnik
748b9477f8 Guide: if 2014-07-03 10:55:10 -07:00
bors
524f469943 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.
2014-07-03 12:36:36 +00:00
bors
550cc045e2 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).
2014-07-03 10:46:39 +00:00
bors
e26d0a7a36 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.
2014-07-03 08:56:36 +00:00
Jakub Wieczorek
6b6edf4702 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.
2014-07-03 09:17:47 +02:00
bors
00f9ff2b41 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.
2014-07-03 06:11:38 +00:00
bors
e6c54a12c4 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.
2014-07-03 03:41:39 +00:00
bors
67776ba3da 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
2014-07-03 01:06:38 +00:00
Mike Boutin
ccd7aaf17a 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.
2014-07-02 20:03:10 -04:00
bors
c8ae065182 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.
2014-07-02 23:16:40 +00:00
Samuel Neves
c0248c0839 Fix rotate_{left, right} for multiple of bitsize rotation amounts
Add additional rotation tests
2014-07-02 23:45:27 +01:00
bors
3035d8dfb1 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
2014-07-02 21:26:40 +00:00
bors
169c988d09 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).
2014-07-02 18:41:38 +00:00
bors
f728ad0134 auto merge of #15186 : jakub-/rust/issue-15104, r=pnkfelix 2014-07-02 16:56:32 +00:00
Jakub Wieczorek
9b3f9d9444 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.
2014-07-02 18:27:12 +02:00
bors
ca2778ede7 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.
2014-07-02 13:52:00 +00:00
Alex Crichton
58133ae360 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.
2014-07-02 05:59:25 -07:00
bors
cb220a86ba 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.
2014-07-02 12:06:34 +00:00
Michael Woerister
40e0541309 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.
2014-07-02 13:32:57 +02:00
bors
3fb3568377 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?
2014-07-02 09:21:39 +00:00
Derecho
c85d42a305 Fix example in docs on documentation 2014-07-02 10:53:30 +02:00
bors
7c4d8e94ba 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.
2014-07-02 07:31:41 +00:00
bors
89259b34c0 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.
2014-07-02 05:41:30 +00:00
Patrick Walton
e56dbad9f7 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]
2014-07-01 21:59:16 -07:00
bors
bd893d1922 auto merge of #15069 : luqmana/rust/cia, r=pcwalton
Fixes #11205.
2014-07-02 03:56:29 +00:00
Alex Crichton
9af1b0e5e1 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.
2014-07-01 20:21:16 -07:00
Brian Anderson
d21336ee0a 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]
2014-07-01 19:12:29 -07:00
bors
e76369e9a0 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. 😉 

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.
2014-07-02 02:11:31 +00:00
Steve Klabnik
a55c508db6 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.
2014-07-01 20:27:37 -04:00
bors
380657557c 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?
2014-07-02 00:21:36 +00:00
OGINO Masanori
55f5a1ef59 Add recvfrom and sendto.
We leave them for compatibility, but mark them as deprecated.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-07-02 08:21:43 +09:00
OGINO Masanori
dfdce47988 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>
2014-07-02 08:21:42 +09:00
Patrick Walton
454b9d2d1f 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]
2014-07-01 14:32:57 -07:00
bors
44ec28cfac 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.
2014-07-01 21:26:33 +00:00
bors
6d60956e58 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.
2014-07-01 19:37:17 +00:00
Patrick Walton
8b272238f1 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.
2014-07-01 11:47:21 -07:00
bors
efebeec6ca auto merge of #15308 : brson/rust/intro, r=alexcrichton
This was asked on HN, and it's easy to clarify.
2014-07-01 17:51:41 +00:00
Brian Anderson
d89577b5a2 doc: Clarify that an error is a compiler error
This was asked on HN, and it's easy to clarify.
2014-07-01 10:46:31 -07:00
Alisdair Owens
88008b3ad5 Improve rustdocs for Rc, add examples 2014-07-01 17:58:40 +01:00