Commit Graph

29370 Commits

Author SHA1 Message Date
bors
3da5a5cd18 auto merge of #14253 : alexcrichton/rust/issue-14221, r=pcwalton
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
2014-05-17 05:06:27 -07:00
bors
20b502b241 auto merge of #14247 : Ryman/rust/minor_ptr_nit, r=alexcrichton
Not too hot on the second change, welcome a better suggestion/wording.
2014-05-17 02:41:20 -07:00
Alex Crichton
4e9e091e91 syntax: Tighten search paths for inner modules
This is an implementation of RFC 16. A module can now only be loaded if the
module declaring `mod name;` "owns" the current directory. A module is
considered as owning its directory if it meets one of the following criteria:

* It is the top-level crate file
* It is a `mod.rs` file
* It was loaded via `#[path]`
* It was loaded via `include!`
* The module was declared via an inline `mod foo { ... }` statement

For example, this directory structure is now invalid

    // lib.rs
    mod foo;

    // foo.rs
    mod bar;

    // bar.rs;
    fn bar() {}

With this change `foo.rs` must be renamed to `foo/mod.rs`, and `bar.rs` must be
renamed to `foo/bar.rs`. This makes it clear that `bar` is a submodule of `foo`,
and can only be accessed through `foo`.

RFC: 0016-module-file-system-hierarchy
Closes #14180

[breaking-change]
2014-05-17 01:01:47 -07:00
bors
8befaba9ef auto merge of #14239 : alexcrichton/rust/issue-14225, r=huonw
These are taken care of with compiler errors later on, no need to spam with
extra unformatted information unconditionally.

Closes #14225
2014-05-17 01:01:22 -07:00
bors
1e0379f05b auto merge of #14224 : michaelwoerister/rust/simd-update, r=alexcrichton
This is a small change that improves the DWARF description of SIMD types by exposing their type name to debuginfo.
2014-05-16 23:16:22 -07:00
bors
11e17c8705 auto merge of #14236 : alexcrichton/rust/issue-14082, r=brson
The reexport didn't switch the privacy, so the reexport was actually considered
private, erroneously failing to resolve imports later on.

Closes #14082
2014-05-16 21:36:23 -07:00
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