Commit Graph

28943 Commits

Author SHA1 Message Date
klutzy
cc31bb0a9e pprust: Fix asm output 2014-05-13 17:24:08 -07:00
klutzy
7f203b6955 pprust: Add parentheses to some Expr
Some `Expr` needs parentheses when printed. For example, without
parentheses, `ExprUnary(UnNeg, ExprBinary(BiAdd, ..))` becomes
`-lhs + rhs` which is wrong.

Those cases don't appear in ordinary code (since parentheses are
explicitly added) but they can appear in manually crafted ast by
extensions.
2014-05-13 17:24:08 -07:00
klutzy
6d535b5b8d rustc: Make std_inject valid for pretty-printer
Inject `extern crate {std, native}` before `use` statements.
Add `#![feature(glob)]` since `use std::prelude::*` is used.

(Unfortunately `rustc --pretty expanded` does not converge,
since `extern crate` and `use std::prelude::*` is injected at every
iteration.)
2014-05-13 17:24:08 -07:00
Zooko Wilcox-O'Hearn
0004953c3a add a line to the example to clarify semantics
This is to clarify that match construct doesn't define a new variable, since I
observed a person reading the Rust tutorial who seemed to incorrectly think
that it did. Fixes https://github.com/mozilla/rust/issues/13571 .
2014-05-13 17:24:08 -07:00
Richo Healey
ef23fa17c3 docs: Add a not found page 2014-05-13 17:24:07 -07:00
Florian Zeitz
df802a2754 std: Rename str::Normalizations to str::Decompositions
The Normalizations iterator has been renamed to Decompositions.
It does not currently include all forms of Unicode normalization,
but only encompasses decompositions.
If implemented recomposition would likely be a separate iterator
which works on the result of this one.

[breaking-change]
2014-05-13 17:24:07 -07:00
Florian Zeitz
8c54d5bf40 core: Move Hangul decomposition into unicode.rs 2014-05-13 17:24:07 -07:00
Florian Zeitz
2f71b72a12 core: Use appropriately sized integers for codepoints and bytes 2014-05-13 17:24:07 -07:00
Florian Zeitz
74ad023674 std, core: Generate unicode.rs using unicode.py 2014-05-13 17:24:07 -07:00
Edward Wang
21867fa127 check_match: get rid of superfluous clones 2014-05-13 17:24:07 -07:00
Edward Wang
5bf268d0b0 Fix #8391
Closes #8391
2014-05-13 17:24:07 -07:00
Piotr Jawniak
655487b596 Implements Default trait for BigInt and BigUint 2014-05-13 17:24:07 -07:00
Adolfo Ochagavía
a390b5dd03 Replaced ~T by Box<T> in manual 2014-05-13 17:24:07 -07:00
OGINO Masanori
de2c48c30a Add tests for from_bits.
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-05-13 17:24:07 -07:00
Marvin Löbel
24ece07cec Allow blocks in const expressions
Only blocks with tail expressions that are const expressions
and items are allowed.
2014-05-13 17:24:07 -07:00
Alex Crichton
cbc31df4fc std: Move the owned module from core to std
The compiler was updated to recognize that implementations for ty_uniq(..) are
allowed if the Box lang item is located in the current crate. This enforces the
idea that libcore cannot allocated, and moves all related trait implementations
from libcore to libstd.

This is a breaking change in that the AnyOwnExt trait has moved from the any
module to the owned module. Any previous users of std::any::AnyOwnExt should now
use std::owned::AnyOwnExt instead. This was done because the trait is intended
for Box traits and only Box traits.

[breaking-change]
2014-05-13 17:24:07 -07:00
OGINO Masanori
7af5f646f1 Suppress warnings on 32bit platforms.
On 32bit platforms, int is the same as i32, so 0xffffffff is "out of
range." Annotating variables as u32 fixes the problems.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-05-14 09:14:45 +09:00
OGINO Masanori
6ce7dfb996 Suppress a "unused variable" warning.
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-05-14 09:14:45 +09:00
bors
cb115ac2d4 auto merge of #14075 : Rufflewind/rust/patch-3, r=alexcrichton
- Use Unicode-aware versions of `CreateProcess` (Fixes #13815) and `Get/FreeEnvironmentStrings`.
    - Includes a helper function `os::win32::as_mut_utf16_p`, which does the same thing as `os::win32::as_utf16_p` except the pointer is mutable.
    - Fixed `make_command_line` to handle Unicode correctly.
- Tests for the above.
2014-05-13 16:01:48 -07:00
Phil Ruffwind
b8e3f3a417 Test Unicode support of process spawning
Added a run-pass test to ensure that processes can be correctly spawned
using non-ASCII arguments, working directory, and environment variables.
It also tests Unicode support of os::env_as_bytes.

An additional assertion was added to the test for make_command_line to
verify it handles Unicode correctly.
2014-05-13 17:19:01 -04:00
Phil Ruffwind
d9eca56c06 Use Get/FreeEnvironmentStringsW instead of Get/FreeEnvironmentStringsA
Changed libstd to use Get/FreeEnvironmentStringsW instead of
Get/FreeEnvironmentStringsA to support Unicode environment variables.
2014-05-13 17:19:01 -04:00
Phil Ruffwind
b6cce7ea54 Fix make_command_line to handle Unicode correctly
Previously, make_command_line iterates over each u8 in the string and
then appends them as chars, so any non-ASCII string will get horribly
mangled by this function.  This fix should allow Unicode arguments to
work correctly in native::io::process::spawn.
2014-05-13 17:19:00 -04:00
Phil Ruffwind
e12aeb39bc Use CreateProcessW instead of CreateProcessA
Changed libnative to use CreateProcessW instead of CreateProcessA.  In
addition, the lpEnvironment parameter now uses Unicode.

Added a helper function os::win32::as_mut_utf16_p, which does basically
the same thing as os::win32::as_utf16_p except the pointer is mutable.
2014-05-13 17:19:00 -04:00
bors
5ad42b3ae9 auto merge of #14052 : dylanbraithwaite/rust/char-fns-for-strbuf, r=alexcrichton
Added functions pop_char and shift_char to StrBuf along with unit tests, using the same test cases as push_char.
2014-05-13 13:41:49 -07:00
Alex Crichton
af00c57379 serialize: Broaden ignores of json tests
It was thought that these failures only happened on windows, turns out they
happen on any 32-bit machine.

cc #14064
2014-05-13 09:28:26 -07:00
bors
4537f13a87 auto merge of #14158 : nikomatsakis/rust/issue-5527-refactor-foldable, r=pcwalton
Factor out foldable better to reduce code duplication. 

r? @pcwalton (probably want to let travis run...)
2014-05-13 08:57:33 -07:00
bors
04c23d3fc1 auto merge of #14168 : zwarich/rust/deriving-clone, r=alexcrichton 2014-05-13 06:11:45 -07:00
bors
463436ffeb auto merge of #14167 : cmr/rust/cmplx, r=alexcrichton
[breaking-change]
2014-05-13 04:06:50 -07:00
Dylan Braithwaite
1ca6b2cc66 Added functions pop_char and shift_char to StrBuf struct along with appropriate unit tests, using the same test case as push_char.
Changed StrBuf.shift_byte() that it no longer reallocates the buffer by just calling Vec.shift();

Added warning to shift_char()'s docs about it having to copy the whole buffer, as per the docs for
Vec.shift().
2014-05-13 11:01:12 +01:00
bors
e162438162 auto merge of #13919 : thomaslee/rust/thomaslee_proposed_tcpstream_open, r=alexcrichton
Been meaning to try my hand at something like this for a while, and noticed something similar mentioned as part of #13537. The suggestion on the original ticket is to use `TcpStream::open(&str)` to pass in a host + port string, but seems a little cleaner to pass in host and port separately -- so a signature like `TcpStream::open(&str, u16)`.

Also means we can use std::io::net::addrinfo directly instead of using e.g. liburl to parse the host+port pair from a string.

One outstanding issue in this PR that I'm not entirely sure how to address: in open_timeout, the timeout_ms will apply for every A record we find associated with a hostname -- probably not the intended behavior, but I didn't want to waste my time on elaborate alternatives until the general idea was a-OKed. :)

Anyway, perhaps there are other reasons for us to prefer the original proposed syntax, but thought I'd get some thoughts on this. Maybe there are some solid reasons to prefer using liburl to do this stuff.
2014-05-12 23:11:45 -07:00
Tom Lee
218d01ef33 Fix field ordering of addrinfo struct on Android 2014-05-12 21:48:02 -07:00
bors
967366e988 auto merge of #14164 : alexcrichton/rust/rollup, r=alexcrichton 2014-05-12 21:45:13 -07:00
Tom Lee
8252353916 Document a possible way in which connect_timout may change in the future 2014-05-12 21:41:48 -07:00
Tom Lee
611c2ae4f1 Try to parse TcpStream::connect 'host' parameter as an IP.
Fall back to get_host_addresses to try a DNS lookup if we can't
parse it as an IP address.
2014-05-12 21:41:48 -07:00
Tom Lee
a57889a580 Easier interface for TCP ::connect and ::bind.
Prior to this commit, TcpStream::connect and TcpListener::bind took a
single SocketAddr argument. This worked well enough, but the API felt a
little too "low level" for most simple use cases.

A great example is connecting to rust-lang.org on port 80. Rust users would
need to:

  1. resolve the IP address of rust-lang.org using
     io::net::addrinfo::get_host_addresses.

  2. check for errors

  3. if all went well, use the returned IP address and the port number
     to construct a SocketAddr

  4. pass this SocketAddr to TcpStream::connect.

I'm modifying the type signature of TcpStream::connect and
TcpListener::bind so that the API is a little easier to use.

TcpStream::connect now accepts two arguments: a string describing the
host/IP of the host we wish to connect to, and a u16 representing the
remote port number.

Similarly, TcpListener::bind has been modified to take two arguments:
a string describing the local interface address (e.g. "0.0.0.0" or
"127.0.0.1") and a u16 port number.

Here's how to port your Rust code to use the new TcpStream::connect API:

  // old ::connect API
  let addr = SocketAddr{ip: Ipv4Addr{127, 0, 0, 1}, port: 8080};
  let stream = TcpStream::connect(addr).unwrap()

  // new ::connect API (minimal change)
  let addr = SocketAddr{ip: Ipv4Addr{127, 0, 0, 1}, port: 8080};
  let stream = TcpStream::connect(addr.ip.to_str(), addr.port()).unwrap()

  // new ::connect API (more compact)
  let stream = TcpStream::connect("127.0.0.1", 8080).unwrap()

  // new ::connect API (hostname)
  let stream = TcpStream::connect("rust-lang.org", 80)

Similarly, for TcpListener::bind:

  // old ::bind API
  let addr = SocketAddr{ip: Ipv4Addr{0, 0, 0, 0}, port: 8080};
  let mut acceptor = TcpListener::bind(addr).listen();

  // new ::bind API (minimal change)
  let addr = SocketAddr{ip: Ipv4Addr{0, 0, 0, 0}, port: 8080};
  let mut acceptor = TcpListener::bind(addr.ip.to_str(), addr.port()).listen()

  // new ::bind API (more compact)
  let mut acceptor = TcpListener::bind("0.0.0.0", 8080).listen()

[breaking-change]
2014-05-12 21:41:48 -07:00
Cameron Zwarich
45b4ef4633 Remove a workaround for deriving(Clone) on unit structs. 2014-05-12 21:29:31 -07:00
Corey Richardson
2886938169 num: rename Cmplx to Complex
Cmplx is a uselessly short name. Change it to be more clear.

[breaking-change]
2014-05-12 21:27:40 -07:00
Alex Crichton
5001a66665 Test fixes from rollup
Closes #14163 (Fix typos in rustc manpage)
Closes #14161 (Add the patch number to version strings. Closes #13289)
Closes #14156 (rustdoc: Fix hiding implementations of traits)
Closes #14152 (add shebang to scripts that have execute bit set)
Closes #14150 (libcore: remove fails from slice.rs and remove duplicated length checking)
Closes #14147 (Make ProcessOutput Eq, TotalEq, Clone)
Closes #14142 (doc: updates rust manual (loop to continue))
Closes #14141 (doc: Update the linkage documentation)
Closes #14139 (Remove an unnecessary .move_iter().collect())
Closes #14136 (Two minor fixes in parser.rs)
Closes #14130 (Fixed typo in comments of driver.rs)
Closes #14128 (Add `stat` method to `std::io::fs::File` to stat without a Path.)
Closes #14114 (rustdoc: List macros in the sidebar)
Closes #14113 (shootout-nbody improvement)
Closes #14112 (Improved example code in Option)
Closes #14104 (Remove reference to MutexArc)
Closes #14087 (emacs: highlight `macro_name!` in macro invocations using [] delimiters)
2014-05-12 20:17:36 -07:00
bors
1ee5e7f185 auto merge of #13820 : klutzy/rust/urandom, r=alexcrichton
This patch adds document which explains when to use `OSRng` in
cryptographic context, and explains why we use `/dev/urandom` instead
of `/dev/random`.
2014-05-12 20:17:13 -07:00
Huon Wilson
13491dbadb emacs: highlight macro_name! in macro invocations using [] delimiters 2014-05-12 19:52:29 -07:00
Derek Chiang (Enchi Jiang)
5518071019 Remove reference to MutexArc 2014-05-12 19:52:29 -07:00
Adolfo Ochagavía
85e34b2396 Improved example code in Option 2014-05-12 19:52:29 -07:00
Guillaume Pinot
437338ab65 shootout-nbody improvement
- factorize operation
- factorize loop (and gain a level of indentation)
- ~5% faster

Thanks to @Ryman for the propositions :)
2014-05-12 19:52:29 -07:00
Seo Sanghyeon
48beab1205 rustdoc: List macros in the sidebar 2014-05-12 19:52:29 -07:00
Yuri Kunde Schlesner
8c55fcd1f2 Add stat method to std::io::fs::File to stat without a Path.
The `FileStat` struct contained a `path` field, which was filled by the
`stat` and `lstat` function. Since this field isn't in fact returned by
the operating system (it was copied from the paths passed to the
functions) it was removed, as in the `fstat` case we aren't working with
a `Path`, but directly with a fd.

If your code used the `path` field of `FileStat` you will now have to
manually store the path passed to `stat` along with the returned struct.

[breaking-change]
2014-05-12 19:52:29 -07:00
Adolfo Ochagavía
f096516d2b Fixed typo in comments of driver.rs 2014-05-12 19:52:29 -07:00
Paul Stansifer
cdd5893347 Cleanup some ugly variable names, now that we have let-hygiene. 2014-05-12 19:52:29 -07:00
Paul Stansifer
0aae5574ea Add some long-overdue documentation on the INTERPOLATED helper macros. 2014-05-12 19:52:29 -07:00
Simon Sapin
16351731ac Remove an unnecessary .move_iter().collect() 2014-05-12 19:52:29 -07:00
Alex Crichton
e798b97ce9 doc: Update the linkage documentation
After allowing mixing rlibs and dylibs in #13892, the documentation was not
updated accordingly to reflect this new capability.
2014-05-12 19:52:29 -07:00