Commit Graph

29013 Commits

Author SHA1 Message Date
bors
5327218013 auto merge of #14257 : alexcrichton/rust/fix-snap, r=huonw
This is blocking a snapshot because apparently the test fails on the bots.
2014-05-16 19:21:26 -07:00
Alex Crichton
99a9cc5331 term: Don't run the code example, just compile it
This is blocking a snapshot because apparently the test fails on the bots.
2014-05-16 18:45:59 -07:00
bors
2216eceea5 auto merge of #14216 : kballard/rust/macos_precise_time_ns, r=alexcrichton
Use sync:1️⃣:Once to fetch the mach_timebase_info only once when
running precise_time_ns(). This helps because mach_timebase_info() is
surprisingly inefficient. Also fix the order of operations when applying
the timebase to the mach absolute time value.

This improves the time on my machine from

```
test tests::bench_precise_time_ns ... bench:       157 ns/iter (+/- 4)
```

to

```
test tests::bench_precise_time_ns ... bench:        38 ns/iter (+/- 3)
```

and it will get even faster once #14174 lands.
2014-05-16 16:31:24 -07:00
Alex Crichton
7cbec5566c rustc: Stop leaking enum variants into children
This plugs a leak where resolve was treating enums defined in parent modules as
in-scope for all children modules when resolving a pattern identifier. This
eliminates the code path in resolve entirely.

If this breaks any existing code, then it indicates that the variants need to be
explicitly imported into the module.

Closes #14221

[breaking-change]
2014-05-16 16:16:57 -07:00
bors
cea4803d4c auto merge of #14135 : gereeter/rust/two-way-search, r=brson
This changes the previously naive string searching algorithm to a two-way search like glibc, which should be faster on average while still maintaining worst case linear time complexity. This fixes #14107. Note that I don't think this should be merged yet, as this is the only approach to speeding up search I've tried - it's worth considering options like Boyer-Moore or adding a bad character shift table to this. However, the benchmarks look quite good so far:

    test str::bench::bench_contains_bad_naive                   ... bench:       290 ns/iter (+/- 12)     from 1309 ns/iter (+/- 36)
    test str::bench::bench_contains_equal                       ... bench:       479 ns/iter (+/- 10)     from  137 ns/iter (+/- 2)
    test str::bench::bench_contains_short_long                  ... bench:      2844 ns/iter (+/- 105)    from 5473 ns/iter (+/- 14)
    test str::bench::bench_contains_short_short                 ... bench:        55 ns/iter (+/- 4)      from   57 ns/iter (+/- 6)

Except for the case specifically designed to be optimal for the naive case (`bench_contains_equal`), this gets as good or better performance as the previous code.
2014-05-16 14:46:24 -07:00
Luqman Aden
28243a5c0e librustc: Separate NullablePointer into RawNullablePointer and StructWrappedNullablePointer. 2014-05-16 17:24:49 -04:00
Luqman Aden
d104dabae9 Make some NullablePointer enums FFI-compatible with the base pointer type. 2014-05-16 17:24:49 -04:00
Kevin Ballard
8ef3e22719 Optimize and fix time::precise_time_ns() on macos
Use sync:1️⃣:Once to fetch the mach_timebase_info only once when
running precise_time_ns(). This helps because mach_timebase_info() is
surprisingly inefficient. Also fix the order of operations when applying
the timebase to the mach absolute time value.

This improves the time on my machine from

```
test tests::bench_precise_time_ns ... bench:       157 ns/iter (+/- 4)
```

to

```
test tests::bench_precise_time_ns ... bench:        38 ns/iter (+/- 3)
```

and it will get even faster once #14174 lands.
2014-05-16 14:02:14 -07:00
bors
5e10686aab auto merge of #14233 : pcwalton/rust/detildestr-morelibs, r=alexcrichton
r? @alexcrichton
2014-05-16 13:11:23 -07:00
bors
25c54226c3 auto merge of #13401 : cmr/rust/docs, r=brson
Adds docs where previously there were no docs. Also adds windows support to libterm.
2014-05-16 11:41:30 -07:00
Patrick Walton
b84c0dc2d6 doc: Remove all uses of ~str from the documentation. 2014-05-16 11:41:27 -07:00
Patrick Walton
1fb08f11b7 libgetopts: Remove all uses of ~str from libgetopts 2014-05-16 11:41:27 -07:00
Patrick Walton
28bcef85e4 libserialize: Remove all uses of ~str from libserialize.
Had to make `struct Tm` in `libtime` not serializable for now.
2014-05-16 11:41:27 -07:00
Patrick Walton
67e39a8e76 libfmt_macros: Remove all uses of ~str from libfmt_macros 2014-05-16 11:41:27 -07:00
Patrick Walton
ce11f19695 librustuv: Remove all uses of ~str from librustuv 2014-05-16 11:41:27 -07:00
Patrick Walton
78bc758c94 compiletest: Remove all uses of ~str from compiletest 2014-05-16 11:41:26 -07:00
Corey Richardson
3da99c5d8a Some fixes 2014-05-16 10:59:25 -07:00
Corey Richardson
1fe15b95cb Fix example 2014-05-16 10:00:14 -07:00
Corey Richardson
26238c9a24 Flush before applying console attributes 2014-05-16 10:00:14 -07:00
Corey Richardson
2cd32a8c88 Add a bang 2014-05-16 10:00:14 -07:00
Corey Richardson
2afa42a32e Update for Box 2014-05-16 10:00:13 -07:00
Corey Richardson
c4cf6ca8ad Update for master 2014-05-16 10:00:13 -07:00
Corey Richardson
67aea1f8bd Add WinConsole docs 2014-05-16 10:00:13 -07:00
Corey Richardson
3af7755909 test: update for term fallout 2014-05-16 10:00:13 -07:00
Corey Richardson
7bf1de5283 workcache: add crate doc block 2014-05-16 10:00:13 -07:00
Corey Richardson
6ef2169bac time: crate description 2014-05-16 10:00:13 -07:00
Corey Richardson
e3d0e5e2f2 syntax: update for libterm fallout 2014-05-16 09:59:31 -07:00
Corey Richardson
f923b93694 term: add docs and windows support
Closes #2807
2014-05-16 09:57:32 -07:00
Corey Richardson
e30198d9d4 num: expand crate documentation + add example 2014-05-16 09:55:29 -07:00
Corey Richardson
91fa8e5f2a arena: add docs for Arena 2014-05-16 09:55:29 -07:00
Corey Richardson
30250d3de8 flate: add documentation 2014-05-16 09:55:29 -07:00
Alex Crichton
6959b4f7b0 rustc: Stop calling error! in resolve
These are taken care of with compiler errors later on, no need to spam with
extra unformatted information unconditionally.

Closes #14225
2014-05-16 09:15:51 -07:00
Kevin Butler
6bfe361de2 guide-pointers: minor nits 2014-05-16 15:40:21 +01:00
bors
bbd034c3a6 auto merge of #14237 : alexcrichton/rust/issue-14144, r=cmr
By default, jemalloc is building itself with -g3 if the local compiler supports
it. It looks like this is generating a good deal of debug info that windows
isn't optimizing out (on the order of 18MB). Windows gcc/ld is also not
optimizing this data away, causing hello world to be 18MB in size.

There's no current real need for debugging jemalloc to a great extent, so this
commit manually passes -g1 to override -g3 which jemalloc is using. This is
confirmed to drop the size of executables on windows back to a more reasonable
size (2.0MB, as they were before).

Closes #14144
2014-05-16 02:46:25 -07:00
bors
d92926ca3b auto merge of #14235 : Ryman/rust/simplify_arcs_doc, r=alexcrichton 2014-05-16 01:06:25 -07:00
bors
b545a499fa auto merge of #14115 : alexcrichton/rust/core-fmt, r=brson
This was a more difficult change than I thought it would be, and it is unfortunately a breaking change rather than a drop-in replacement. Most of the rationale can be found in the third commit.

cc #13851
2014-05-15 23:26:26 -07:00
Alex Crichton
2e2160b026 core: Update all tests for fmt movement 2014-05-15 23:22:15 -07:00
Alex Crichton
d12a136b22 std: Fix float tests 2014-05-15 23:22:06 -07:00
Alex Crichton
c365252002 std: Delegate some integer formatting to core::fmt
In an attempt to phase out the std::num::strconv module's string formatting
functionality, this commit reimplements some provided methods for formatting
integers on top of format!() instead of the custom (and slower) implementation
inside of num::strconv.

Primarily, this deprecates int_to_str_bytes_common
2014-05-15 23:22:06 -07:00
Alex Crichton
bcab97a32e core: Implement f32/f64 formatting
This is a migration of the std::{f32, f64}::to_str* functionality to the core
library. This removes the growable `Vec` used in favor of a large stack buffer.
The maximum base 10 exponent for f64 is 308, so a stack buffer of 512 bytes
should be sufficient to store all floats.
2014-05-15 23:22:06 -07:00
Alex Crichton
1de4b65d2a Updates with core::fmt changes
1. Wherever the `buf` field of a `Formatter` was used, the `Formatter` is used
   instead.
2. The usage of `write_fmt` is minimized as much as possible, the `write!` macro
   is preferred wherever possible.
3. Usage of `fmt::write` is minimized, favoring the `write!` macro instead.
2014-05-15 23:22:06 -07:00
Alex Crichton
8767093eb9 std: Rewrite the write! and writeln! macros
These are reimplemented using the new `core::fmt` module.
2014-05-15 23:22:06 -07:00
Alex Crichton
854d95f9ff syntax: Add a macro, format_args_method!()
Currently, the format_args!() macro takes as its first argument an expression
which is the callee of an ExprCall. This means that if format_args!() is used
with calling a method a closure must be used. Consider this code, however:

    format_args!(|args| { foo.writer.write_fmt(args) }, "{}", foo.field)

The closure borrows the entire `foo` structure, disallowing the later borrow of
`foo.field`. To preserve the semantics of the `write!` macro, it is also
impossible to borrow specifically the `writer` field of the `foo` structure
because it must be borrowed mutably, but the `foo` structure is not guaranteed
to be mutable itself.

This new macro is invoked like:

    format_args_method!(foo.writer, write_fmt, "{}", foo.field)

This macro will generate an ExprMethodCall which allows the borrow checker to
understand that `writer` and `field` should be borrowed separately.

This macro is not strictly necessary, with DST or possibly UFCS other
workarounds could be used. For now, though, it looks like this is required to
implement the `write!` macro.
2014-05-15 23:22:06 -07:00
Alex Crichton
00f9263914 std: Add an adaptor for Writer => FormatWriter
This new method, write_fmt(), is the one way to write a formatted list of
arguments into a Writer stream. This has a special adaptor to preserve errors
which occur on the writer.

All macros will be updated to use this method explicitly.
2014-05-15 23:22:06 -07:00
Alex Crichton
3c06a0328a core: Derive Show impls wherever possible
These were temporarily moved to explicit implementations, but now that fmt is in
core it's possible to derive again.
2014-05-15 23:22:06 -07:00
Alex Crichton
27d8ea05a2 core: Implement and export the try! macro
This is used quite extensively by core::fmt
2014-05-15 23:22:06 -07:00
Alex Crichton
f2af4ca3e6 core: Allow formatted failure and assert in core
With std::fmt having migrated, the failure macro can be expressed in its full
glory.
2014-05-15 23:22:06 -07:00
Alex Crichton
c255568652 core: Implement unwrap()/unwrap_err() on Result
Now that std::fmt is in libcore, it's possible to implement this as an inherit
method rather than through extension traits.

This commit also tweaks the failure interface of libcore to libstd to what it
should be, one method taking &fmt::Arguments
2014-05-15 23:22:06 -07:00
Alex Crichton
cf0619383d core: Inherit the std::fmt module
This commit moves all possible functionality from the standard library's string
formatting utilities into the core library. This is a breaking change, due to a
few tweaks in the semantics of formatting:

1. In order to break the dependency on the std::io module, a new trait,
   FormatWriter was introduced in core::fmt. This is the trait which is used
   (instead of Writer) to format data into a stream.
2. The new FormatWriter trait has one method, write(), which takes some bytes
   and can return an error, but the error contains very little information. The
   intent for this trait is for an adaptor writer to be used around the standard
   library's Writer trait.
3. The fmt::write{,ln,_unsafe} methods no longer take &mut io::Writer, but
   rather &mut FormatWriter. Since this trait is less common, all functions were
   removed except fmt::write, and it is not intended to be invoked directly.

The main API-breaking change here is that the fmt::Formatter structure will no
longer expose its `buf` field. All previous code writing directly to `f.buf`
using writer methods or the `write!` macro will now instead use `f` directly.

The Formatter object itself implements the `Writer` trait itself for
convenience, although it does not implement the `FormatWriter` trait. The
fallout of these changes will be in the following commits.

[breaking-change]
2014-05-15 23:22:06 -07:00
Alex Crichton
ba0a984a86 core: Move intrinsic float functionality from std
The Float trait in libstd is quite a large trait which has dependencies on cmath
(libm) and such, which libcore cannot satisfy. It also has many functions that
libcore can implement, however, as LLVM has intrinsics or they're just bit
twiddling.

This commit moves what it can of the Float trait from the standard library into
libcore to allow floats to be usable in the core library. The remaining
functions are now resident in a FloatMath trait in the standard library (in the
prelude now). Previous code which was generic over just the Float trait may now
need to be generic over the FloatMath trait.

[breaking-change]
2014-05-15 23:22:06 -07:00