Commit Graph

28813 Commits

Author SHA1 Message Date
Alex Crichton
82a8a5ebb3 core: Document should_not_exist's existence
Explain why it should not exist, and the plan of attack for removing it.
2014-05-13 23:59:03 -07:00
Alex Crichton
57f3b6ee5c core: Add a crate doc block 2014-05-13 23:59:03 -07:00
Alex Crichton
325cc51502 core: Inherit the atomics module 2014-05-13 23:59:03 -07:00
bors
e4414739a5 auto merge of #13127 : kballard/rust/read_at_least, r=alexcrichton
Reader.read_at_least() ensures that at least a given number of bytes
have been read. The most common use-case for this is ensuring at least 1
byte has been read. If the reader returns 0 enough times in a row, a new
error kind NoProgress will be returned instead of looping infinitely.

This change is necessary in order to properly support Readers that
repeatedly return 0, either because they're broken, or because they're
attempting to do a non-blocking read on some resource that never becomes
available.

Also add .push() and .push_at_least() methods. push() is like read() but
the results are appended to the passed Vec.

Remove Reader.fill() and Reader.push_exact() as they end up being thin
wrappers around read_at_least() and push_at_least().

[breaking-change]
2014-05-13 20:01:28 -07:00
Kevin Ballard
972f2e5855 io: Add .read_at_least() to Reader
Reader.read_at_least() ensures that at least a given number of bytes
have been read. The most common use-case for this is ensuring at least 1
byte has been read. If the reader returns 0 enough times in a row, a new
error kind NoProgress will be returned instead of looping infinitely.

This change is necessary in order to properly support Readers that
repeatedly return 0, either because they're broken, or because they're
attempting to do a non-blocking read on some resource that never becomes
available.

Also add .push() and .push_at_least() methods. push() is like read() but
the results are appended to the passed Vec.

Remove Reader.fill() and Reader.push_exact() as they end up being thin
wrappers around read_at_least() and push_at_least().

[breaking-change]
2014-05-13 18:45:20 -07:00
bors
b2b383cab5 auto merge of #14187 : alexcrichton/rust/rollup, r=alexcrichton
Closes #14184 (std: Move the owned module from core to std)
Closes #14183 (Allow blocks in const expressions)
Closes #14176 (Add tests for from_bits.)
Closes #14175 (Replaced ~T by Box<T> in manual)
Closes #14173 (Implements Default trait for BigInt and BigUint)
Closes #14171 (Fix #8391)
Closes #14159 (Clean up unicode code in libstd)
Closes #14126 (docs: Add a not found page)
Closes #14123 (add a line to the example to clarify semantics)
Closes #14106 (Pretty printer improvements)
Closes #14083 (rustllvm: Add LLVMRustArrayType)
Closes #13957 (io: Implement process wait timeouts)
2014-05-13 18:31:51 -07:00
Alex Crichton
f09592a5d1 io: Implement process wait timeouts
This implements set_timeout() for std::io::Process which will affect wait()
operations on the process. This follows the same pattern as the rest of the
timeouts emerging in std::io::net.

The implementation was super easy for everything except libnative on unix
(backwards from usual!), which required a good bit of signal handling. There's a
doc comment explaining the strategy in libnative. Internally, this also required
refactoring the "helper thread" implementation used by libnative to allow for an
extra helper thread (not just the timer).

This is a breaking change in terms of the io::Process API. It is now possible
for wait() to fail, and subsequently wait_with_output(). These two functions now
return IoResult<T> due to the fact that they can time out.

Additionally, the wait_with_output() function has moved from taking `&mut self`
to taking `self`. If a timeout occurs while waiting with output, the semantics
are undesirable in almost all cases if attempting to re-wait on the process.
Equivalent functionality can still be achieved by dealing with the output
handles manually.

[breaking-change]

cc #13523
2014-05-13 17:27:42 -07:00
klutzy
9f7caed202 rustllvm: Add LLVMRustArrayType
LLVM internally uses `uint64_t` for array size, but the corresponding
C API (`LLVMArrayType`) uses `unsigned int` so ths value is truncated.
Therefore rustc generates wrong type for fixed-sized large vector e.g.
`[0 x i8]` for `[0u8, ..(1 << 32)]`.

This patch adds `LLVMRustArrayType` function for `uint64_t` support.
2014-05-13 17:24:08 -07:00
Alex Crichton
6878039c12 syntax: Improve --pretty normal slightly
When printing doc comments, always put a newline after them in a macro
invocation to ensure that a line-doc-comment doesn't consume remaining tokens on
the line.
2014-05-13 17:24:08 -07:00
Alex Crichton
25ac81eb89 syntax: Preserve attributes in #[deriving]
Now that the #[deriving] attribute is removed, the raw_pointers_deriving lint
was broken. This commit restores the lint by preserving lint attributes
across #[deriving] to the implementations and using #[automatically_derived] as
the trigger for activating the lint.
2014-05-13 17:24:08 -07:00
Alex Crichton
f912005ef3 test: Give a test a bigger stack for pretty printing 2014-05-13 17:24:08 -07:00
Alex Crichton
d92b9ae716 syntax: Print suffixed token literals correctly
Previously, literals "1i" were printed as "1". This fixes the
numeric-method-autoexport test for pretty printing.
2014-05-13 17:24:08 -07:00
Alex Crichton
1581fb8d6f test: Ignore a pretty expanded failing test
When expanding, an extra unsafe block is generated which is currently not
handled well.
2014-05-13 17:24:08 -07:00
Alex Crichton
560def1511 test: Fix a pretty printing test
The pretty printer handles inlines comments quite badly
2014-05-13 17:24:08 -07:00
Alex Crichton
ac1a27043a syntax: Fix parsing << with closure types
This uses the trick of replacing the << token with a < token to parse closure
types correctly.

Closes #13324
2014-05-13 17:24:08 -07:00
Alex Crichton
042c8ae40e syntax: Fix printing INT64_MIN
Integers are always parsed as a u64 in libsyntax, but they're stored as i64. The
parser and pretty printer both printed an i64 instead of u64, sometimes
introducing an extra negative sign.
2014-05-13 17:24:08 -07:00
Alex Crichton
1237530452 Touch up and rebase previous commits
* Added `// no-pretty-expanded` to pretty-print a test, but not run it through
  the `expanded` variant.
* Removed #[deriving] and other expanded attributes after they are expanded
* Removed hacks around &str and &&str and friends (from both the parser and the
  pretty printer).
* Un-ignored a bunch of tests
2014-05-13 17:24:08 -07:00
klutzy
ce8c467bd2 compiletest: Test --pretty expanded
After testing `--pretty normal`, it tries to run `--pretty expanded` and
typecheck output.
Here we don't check convergence since it really diverges: for every
iteration, some extra lines (e.g.`extern crate std`) are inserted.

Some tests are `ignore-pretty`-ed since they cause various issues
with `--pretty expanded`.
2014-05-13 17:24:08 -07:00
klutzy
96eeda9708 compiletest: Modernize typenames 2014-05-13 17:24:08 -07:00
klutzy
0350d8e6d0 test: Add missing #![feature(managed_boxes)]
The tests use managed boxes, but are not perfectly feature-gated because
they use `@` inside macros. (It causes issue after `--pretty expanded`.)
2014-05-13 17:24:08 -07:00
klutzy
bdd360bb13 libsyntax: Workaround pprust for issue 2014-05-13 17:24:08 -07:00
klutzy
90d976e8fc pprust: Remove unnecessary && of print_tt 2014-05-13 17:24:08 -07:00
klutzy
4675a87c8b pprust: Print &&e instead of & &e 2014-05-13 17:24:08 -07:00
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
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
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