Commit Graph

29136 Commits

Author SHA1 Message Date
bors
ea87f126bd auto merge of #14275 : kballard/rust/bytes-return-static, r=huonw
Change `bytes!()` to return

    {
        static BYTES: &'static [u8] = &[...];
        BYTES
    }

This gives it the `'static` lifetime, whereas before it had an rvalue
lifetime. Until recently this would have prevented assigning `bytes!()`
to a static, as in

    static FOO: &'static [u8] = bytes!(1,2,3);

but #14183 fixed it so blocks are now allowed in constant expressions
(with restrictions).

Fixes #11641.
2014-05-18 13:06:30 -07:00
Kevin Ballard
bcabcf53cf Make bytes!() return 'static
Change `bytes!()` to return

    {
        static BYTES: &'static [u8] = &[...];
        BYTES
    }

This gives it the `'static` lifetime, whereas before it had an rvalue
lifetime. Until recently this would have prevented assigning `bytes!()`
to a static, as in

    static FOO: &'static [u8] = bytes!(1,2,3);

but #14183 fixed it so blocks are now allowed in constant expressions
(with restrictions).

Fixes #11641.
2014-05-18 13:03:38 -07:00
Adolfo Ochagavía
9a8ef9197b Removed unnecessary transmute 2014-05-18 11:48:46 -07:00
bors
63287eef27 auto merge of #14274 : youknowone/rust/advice-tilt-to-box, r=thestinger 2014-05-18 05:36:27 -07:00
bors
2b4cdea7f1 auto merge of #14258 : alexcrichton/rust/dox-format-writer, r=cmr
This commit fills in the documentation holes for the FormatWriter trait which
were previously accidentally left blank. Additionally, this adds the `write_fmt`
method to the trait to allow usage of the `write!` macro with implementors of
the `FormatWriter` trait. This is not useful for consumers of the standard
library who should generally avoid the `FormatWriter` trait, but it is useful
for consumers of the core library who are not using the standard library.
2014-05-18 02:51:30 -07:00
bors
bf8648dbda auto merge of #14121 : luqmana/rust/option-ffi, r=alexcrichton
This slightly adjusts the NullablePointer representation for some enums in the case where the non-nullable variant has a single field (the ptr field) to be just that, the pointer. This is in contrast to the current behaviour where we'd wrap that single pointer in a LLVM struct.

Fixes #11040 & #11303.
2014-05-18 01:16:27 -07:00
Luqman Aden
be79edba71 Update debuginfo tests. 2014-05-18 03:04:50 -04:00
bors
a62395f01c auto merge of #14249 : alexcrichton/rust/issue-14246, r=huonw
Closes #14246
2014-05-17 23:41:28 -07:00
Jeong YunWon
2ee0ca5132 Advice to use Box<T> not ~T 2014-05-18 15:30:41 +09:00
Alex Crichton
14d3dbe292 core: Document FormatWriter and allow write!
This commit fills in the documentation holes for the FormatWriter trait which
were previously accidentally left blank. Additionally, this adds the `write_fmt`
method to the trait to allow usage of the `write!` macro with implementors of
the `FormatWriter` trait. This is not useful for consumers of the standard
library who should generally avoid the `FormatWriter` trait, but it is useful
for consumers of the core library who are not using the standard library.
2014-05-17 22:10:39 -07:00
Alex Crichton
0989f5c2e7 core: Clarify the documentation on core's prelude
Closes #14246
2014-05-17 22:08:49 -07:00
bors
134f797a63 auto merge of #14230 : alexcrichton/rust/liballoc, r=cmr,huonw
This commit is part of the libstd facade RFC, issue #13851. This creates a new
library, liballoc, which is intended to be the core allocation library for all
of Rust. It is pinned on the basic assumption that an allocation failure is an
abort or failure.

This module has inherited the heap/libc_heap modules from std::rt, the owned/rc
modules from std, and the arc module from libsync. These three pointers are
currently the three most core pointer implementations in Rust.

The UnsafeArc type in std::sync should be considered deprecated and replaced by
`Arc<Unsafe<T>>`. This commit does not currently migrate to this type, but future
commits will continue this refactoring.
2014-05-17 22:01:28 -07:00
Alex Crichton
4a1d21ab7b Register new snapshots 2014-05-17 21:54:11 -07:00
Alex Crichton
639759b7f4 std: Refactor liballoc out of lib{std,sync}
This commit is part of the libstd facade RFC, issue #13851. This creates a new
library, liballoc, which is intended to be the core allocation library for all
of Rust. It is pinned on the basic assumption that an allocation failure is an
abort or failure.

This module has inherited the heap/libc_heap modules from std::rt, the owned/rc
modules from std, and the arc module from libsync. These three pointers are
currently the three most core pointer implementations in Rust.

The UnsafeArc type in std::sync should be considered deprecated and replaced by
Arc<Unsafe<T>>. This commit does not currently migrate to this type, but future
commits will continue this refactoring.
2014-05-17 21:52:23 -07:00
Michael Dagitses
4353e44563 adding move_iter() function to collections::treemap::TreeSet 2014-05-18 00:47:01 -04:00
Corey Richardson
154dfb59fe term: update example to be right (thanks @SiegeLord) 2014-05-17 20:16:21 -07:00
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