Commit Graph

34020 Commits

Author SHA1 Message Date
bors
5c1fd5f8b7 auto merge of #18462 : netvl/rust/to-socket-addr, r=alexcrichton
This is a follow-up to [RFC PR #173](https://github.com/rust-lang/rfcs/pull/173). I was told there that changes like this don't need to go through the RFC process, so I'm submitting this directly.

This PR introduces `ToSocketAddr` trait as defined in said RFC. This trait defines a conversion from different types like `&str`, `(&str, u16)` or even `SocketAddr` to `SocketAddr`. Then this trait is used in all constructor methods for `TcpStream`, `TcpListener` and `UdpSocket`.

This unifies these constructor methods - previously they were using different types of input parameters (TCP ones used `(&str, u16)` pair while UDP ones used `SocketAddr`), which is not consistent by itself and sometimes inconvenient - for example, when the address initially is available as `SocketAddr`, you still need to convert it to string to pass it to e.g. `TcpStream`. This is very prominently demonstrated by the unit tests for TCP functionality. This PR makes working with network objects much like with `Path`, which also uses similar trait to be able to be constructed from `&[u8]`, `Vec<u8>` and other `Path`s.

This is a breaking change. If constant literals were used before, like this:
```rust
TcpStream::connect("localhost", 12345)
```
then the nicest fix is to change it to this:
```rust
TcpStream::connect("localhost:12345")
```

If variables were used before, like this:
```rust
TcpStream::connect(some_address, some_port)
```
then the arguments should be wrapped in another set of parentheses:
```rust
TcpStream::connect((some_address, some_port))
```

`UdpSocket` usages won't break because its constructor method accepted `SocketAddr` which implements `ToSocketAddr`, so `bind()` calls:
```rust
UdpSocket::bind(some_socket_addr)
```
will continue working as before.

I haven't changed `UdpStream` constructor because it is deprecated anyway.
2014-11-05 18:01:53 +00:00
Michael Woerister
36088ab21f debuginfo: Add a timeout for LLDB tests.
Fixes #18649.
2014-11-05 18:35:24 +01:00
Niko Matsakis
81c00e66f5 Better debug printouts 2014-11-05 11:29:15 -05:00
Niko Matsakis
dfe840245b Remove incorrect doc annotation, mark experimental since we haven't discussed in an API meeting 2014-11-05 11:29:15 -05:00
Niko Matsakis
63718792df Update the guide examples and try not to leave user hanging as to what
this `&x` sigil is all about.
2014-11-05 11:29:15 -05:00
Niko Matsakis
0b5bc3314f Implement new operator dispatch semantics.
Key points are:
1. `a + b` maps directly to `Add<A,B>`, where `A` and `B` are the types of `a` and `b`.
2. Indexing and slicing autoderefs consistently.
2014-11-05 11:29:15 -05:00
Vladimir Matveev
0f610f3c14 Fixed not compiling code in docstring 2014-11-05 19:18:30 +03:00
Joseph Crail
1d4b024542 Add missing dragonfly module. 2014-11-05 10:37:08 -05:00
Joseph Crail
a31e3d6de3 Rename misspelled module reference. 2014-11-05 10:37:08 -05:00
Niko Matsakis
33ef78fa8b Add impls of the comparison operators for fixed-length arrays of lengths 0...32 and repair various cases where slices and fixed-length arrays were being compared. 2014-11-05 09:15:28 -05:00
Niko Matsakis
4af52eee59 Repair various cases where values of distinct types were being operated
upon (e.g., `&int` added to `int`).
2014-11-05 09:15:28 -05:00
thiagopnts
23913ec713 rename deprecated non_uppercase_statics to non_upper_case_globals 2014-11-05 12:04:26 -02:00
Michael Woerister
37a823b223 debuginfo: Add timeout before running executable in LLDB tests.
This should help with a potential race condition.
2014-11-05 13:32:09 +01:00
Michael Woerister
2f215f644f debuginfo: Make LLDB test make targets dependent on lldb python scripts. 2014-11-05 13:32:09 +01:00
bors
14cd5c590e auto merge of #18646 : eddyb/rust/snapshots, r=alexcrichton 2014-11-05 12:26:34 +00:00
Eduard Burtescu
56dbf3d122 Register snapshots. 2014-11-05 12:55:58 +02:00
bors
98958bcaf4 auto merge of #18546 : bkoropoff/rust/unboxed-closures-cross-crate, r=nick29581
This fixes some metadata/AST encoding problems that lead to ICEs.  The way this is currently handled will need revisiting if abstract return types are added, as unboxed closure types from extern crates could show up without being inlined into the local crate.

Closes #16790 (I think this was fixed earlier by accident and just needed a test case)
Closes #18378
Closes #18543

r? @pcwalton
2014-11-05 10:21:38 +00:00
Vladimir Matveev
d1ec703329 Added more documentation on ToSocketAddr trait 2014-11-05 12:01:24 +03:00
Vladimir Matveev
7af0cb8af7 Fixed tidy errors 2014-11-05 12:01:24 +03:00
Vladimir Matveev
7d379fa78f Fixed other tests to pass make check 2014-11-05 12:01:23 +03:00
Vladimir Matveev
7e3344b17f Migrated io::net::udp over to ToSocketAddr
UdpSocket constructor methods now use ToSocketAddr trait instead of
SocketAddr.

[breaking-change]
2014-11-05 12:01:23 +03:00
Vladimir Matveev
ac846749f0 Switched io::net::tcp to use ToSocketAddr
TcpListener and TcpStream are converted to use ToSocketAddr trait in
their constructor methods.

[breaking-change]
2014-11-05 12:01:23 +03:00
Vladimir Matveev
d97bfb22f8 Added ToSocketAddr trait
This commit adds ToSocketAddr trait to std::io::net::ip module. This
trait is used for generic conversion from different types (strings,
(string, u16) tuples, etc.) into a SocketAddr instance. It supports
multiple output SocketAddresses when it is appropriate (e.g. DNS name
resolution).

This trait is going to be used by TcpStream, TcpListener and UdpSocket
structures.
2014-11-05 12:01:23 +03:00
bors
eca8f11315 auto merge of #18592 : alexcrichton/rust/dylib-harder, r=pcwalton
If a dylib is being produced, the compiler will now first check to see if it can
be created entirely statically before falling back to dynamic dependencies. This
behavior can be overridden with `-C prefer-dynamic`.

Due to the alteration in behavior, this is a breaking change. Any previous users
relying on dylibs implicitly maximizing dynamic dependencies should start
passing `-C prefer-dynamic` to compilations.

Closes #18499
[breaking-change]
2014-11-05 07:01:38 +00:00
Nick Cameron
9af15e3a6b Test 2014-11-05 16:53:10 +13:00
Nick Cameron
04dd61d1ec Make trans::adt know that some structs are unsized 2014-11-05 16:53:09 +13:00
Luqman Aden
20c1945c51 librustc: Call return_type only for functions. 2014-11-04 22:44:02 -05:00
bors
4375b32dab auto merge of #18504 : pcwalton/rust/small-escapes, r=pcwalton
Use `\u0080`-`\u00ff` instead. ASCII/byte literals are unaffected.

This PR introduces a new function, `escape_default`, into the ASCII
module. This was necessary for the pretty printer to continue to
function.

RFC #326.

Closes #18062.

[breaking-change]

r? @aturon
2014-11-05 03:31:33 +00:00
Luqman Aden
2c09da7d1e librustc_back: Fix triple for linux armhf. 2014-11-04 18:13:37 -05:00
Patrick Walton
e8d6031c71 libsyntax: Forbid escapes in the inclusive range \x80-\xff in
Unicode characters and strings.

Use `\u0080`-`\u00ff` instead. ASCII/byte literals are unaffected.

This PR introduces a new function, `escape_default`, into the ASCII
module. This was necessary for the pretty printer to continue to
function.

RFC #326.

Closes #18062.

[breaking-change]
2014-11-04 14:58:11 -08:00
Huon Wilson
769fa48a1c test: correct spelling error & inverted match. 2014-11-05 09:27:37 +11:00
bors
ceeac26de8 auto merge of #18338 : chastell/rust/guide_pointer_fixes, r=alexcrichton
This removes some leftover line-numbering cruft from elided error examples and brings some minor clarifications.

I’m not super happy about the ‘we cannot have two mutable pointers that point to the same memory’ wording (to the best of my understanding we can’t even have one mutable and one immutable), but other attempts to word this were derailing the flow a bit too much.
2014-11-04 21:26:23 +00:00
Aaron Turon
0514e54b97 std::error: fix stray doc comment 2014-11-04 12:43:35 -08:00
bors
bb70ee56db auto merge of #18528 : seanjensengrey/rust/doc-18498, r=brson
This addresses https://github.com/rust-lang/rust/issues/18498 by adding a prepopulated search box to do site search on `doc.rust-lang.org` using duckduckgo AND generating a search url against the rust documentation using the internal search facilities.

* https://duckduckgo.com/?q=type+Option+unwrap_or_else+site%3Adoc.rust-lang.org
* http://doc.rust-lang.org/core/?search=unwrap_or_else
2014-11-04 18:46:19 +00:00
Piotr Szotkowski
9be04d574a Guide: drop line-number cruft from elided error examples 2014-11-04 19:39:12 +01:00
Piotr Szotkowski
c7182ba997 Guide: minor clarifications for the Pointers part 2014-11-04 19:39:12 +01:00
bors
1b2ad7831f auto merge of #18497 : gamazeps/rust/enumsmatch, r=steveklabnik
Closes #18169
2014-11-04 16:16:28 +00:00
Alex Crichton
68ac44cb97 rustc: Support stability attributes on crates
This commit adds support for linting `extern crate` statements for stability
attributes attached to the crate itself. This is likely to be the mechanism used
to deny access to experimental crates that are part of the standard
distribution.

cc #18585
2014-11-04 08:13:09 -08:00
Huon Wilson
071c411045 Translate SIMD construction as insertelements and a single store.
This almost completely avoids GEPi's and pointer manipulation,
postponing it until the end with one big write of the whole vector. This
leads to a small speed-up in compilation, and makes it easier for LLVM
to work with the values, e.g. with `--opt-level=0`,

    pub fn foo() -> f32x4 {
        f32x4(0.,0.,0.,0.)
    }

was previously compiled to

    define <4 x float> @_ZN3foo20h74913e8b13d89666eaaE() unnamed_addr #0 {
    entry-block:
      %sret_slot = alloca <4 x float>
      %0 = getelementptr inbounds <4 x float>* %sret_slot, i32 0, i32 0
      store float 0.000000e+00, float* %0
      %1 = getelementptr inbounds <4 x float>* %sret_slot, i32 0, i32 1
      store float 0.000000e+00, float* %1
      %2 = getelementptr inbounds <4 x float>* %sret_slot, i32 0, i32 2
      store float 0.000000e+00, float* %2
      %3 = getelementptr inbounds <4 x float>* %sret_slot, i32 0, i32 3
      store float 0.000000e+00, float* %3
      %4 = load <4 x float>* %sret_slot
      ret <4 x float> %4
    }

but now becomes

    define <4 x float> @_ZN3foo20h74913e8b13d89666eaaE() unnamed_addr #0 {
    entry-block:
      ret <4 x float> zeroinitializer
    }
2014-11-05 00:02:43 +11:00
gamazeps
dc7c8da74b Guide: explains the enum/match relationship
Closes #18169
2014-11-04 13:47:53 +01:00
bors
3a8f4ec32a auto merge of #16156 : cmr/rust/target-spec, r=alexcrichton
See commit message.
2014-11-04 11:11:20 +00:00
Corey Richardson
61aeab4c9e Update for collections reform 2014-11-04 05:35:53 -05:00
Corey Richardson
87a753e5ce Update some new use of the old targ_cfg 2014-11-04 05:09:08 -05:00
Corey Richardson
70dedbb1a2 Don't use pie on Android 2014-11-04 05:07:47 -05:00
Corey Richardson
244bb14fd5 Same fix for dragonfly 2014-11-04 05:07:47 -05:00
Corey Richardson
4a6f4c9606 Same fix for mac32 2014-11-04 05:07:47 -05:00
Corey Richardson
0e03503f53 Use -m32 on 32bit Linux 2014-11-04 05:07:47 -05:00
Corey Richardson
6b130e3dd9 Implement flexible target specification
Removes all target-specific knowledge from rustc. Some targets have changed
during this, but none of these should be very visible outside of
cross-compilation. The changes make our targets more consistent.

iX86-unknown-linux-gnu is now only available as i686-unknown-linux-gnu. We
used to accept any value of X greater than 1. i686 was released in 1995, and
should encompass the bare minimum of what Rust supports on x86 CPUs.

The only two windows targets are now i686-pc-windows-gnu and
x86_64-pc-windows-gnu.

The iOS target has been renamed from arm-apple-ios to arm-apple-darwin.

A complete list of the targets we accept now:

arm-apple-darwin
arm-linux-androideabi
arm-unknown-linux-gnueabi
arm-unknown-linux-gnueabihf

i686-apple-darwin
i686-pc-windows-gnu
i686-unknown-freebsd
i686-unknown-linux-gnu

mips-unknown-linux-gnu
mipsel-unknown-linux-gnu

x86_64-apple-darwin
x86_64-unknown-freebsd
x86_64-unknown-linux-gnu
x86_64-pc-windows-gnu

Closes #16093

[breaking-change]
2014-11-04 05:07:47 -05:00
bors
82fb413d37 auto merge of #18596 : alexcrichton/rust/rollup, r=alexcrichton
Let's see if we can clear out the queue entirely today!
2014-11-04 08:11:53 +00:00
bors
ec28b4a6c8 auto merge of #18132 : P1start/rust/more-help, r=jakub-
Closes #18126.

At the moment this mostly only changes notes that are particularly help-oriented or directly suggest the user to do something to help messages, and does not change messages that simply explain an error message further. If it is decided that those messages should also be help messages, I can add them to this PR, but for now I’m excluding them as I believe that changing those messages might leave very few places where notes would be appropriate.
2014-11-04 03:36:55 +00:00