]> git.lizzy.rs Git - rust.git/log
rust.git
10 years agoadd `#[thread_local]` attribute
Daniel Micay [Wed, 6 Nov 2013 05:38:08 +0000 (00:38 -0500)]
add `#[thread_local]` attribute

This provides a building block for fast thread-local storage. It does
not change the safety semantics of `static mut`.

Closes #10310

10 years agoauto merge of #10664 : alexcrichton/rust/issue-10663, r=luqmana
bors [Tue, 26 Nov 2013 17:17:58 +0000 (09:17 -0800)]
auto merge of #10664 : alexcrichton/rust/issue-10663, r=luqmana

It turns out that libuv was returning ENOSPC to us in our usage of the
uv_ipX_name functions. It also turns out that there may be an off-by-one in
libuv. For now just add one to the buffer size and handle the return value
correctly.

Closes #10663

10 years agoCorrectly handle libuv errors in addrinfo calls
Alex Crichton [Tue, 26 Nov 2013 05:59:08 +0000 (21:59 -0800)]
Correctly handle libuv errors in addrinfo calls

It turns out that libuv was returning ENOSPC to us in our usage of the
uv_ipX_name functions. It also turns out that there may be an off-by-one in
libuv. For now just add one to the buffer size and handle the return value
correctly.

Closes #10663

10 years agoauto merge of #10668 : vky/rust/closure-doc-update, r=alexcrichton
bors [Tue, 26 Nov 2013 12:56:49 +0000 (04:56 -0800)]
auto merge of #10668 : vky/rust/closure-doc-update, r=alexcrichton

10 years agoauto merge of #10660 : alexcrichton/rust/little-scope, r=pcwalton
bors [Tue, 26 Nov 2013 10:52:04 +0000 (02:52 -0800)]
auto merge of #10660 : alexcrichton/rust/little-scope, r=pcwalton

This moves the locking/waiting methods to returning an RAII struct instead of
relying on closures. Additionally, this changes the methods to all take
'&mut self' to discourage recursive locking. The new method to block is to call
`wait` on the returned RAII structure instead of calling it on the lock itself
(this enforces that the lock is held).

At the same time, this improves the Mutex interface a bit by allowing
destruction of non-initialized members and by allowing construction of an empty
mutex (nothing initialized inside).

10 years agoauto merge of #10622 : Kimundi/rust/str_de_iter, r=alexcrichton
bors [Tue, 26 Nov 2013 09:07:40 +0000 (01:07 -0800)]
auto merge of #10622 : Kimundi/rust/str_de_iter, r=alexcrichton

This PR removes almost all `_iter` suffixes in various APIs of the codebase that return Iterators, as discussed in #9440.

As a summarize for the intend behind this PR:

- Iterators are the recommended way to provide a potentially lazy list of values, no need to name them painfully verbose. If anything, functions that return a specific container type should have more verbose names.
- We have a static type system, so no need to encode the return value of a constructor function into its name.

Following is a possibly incomplete list of all renamings I performed in the codebase. For a few of them I'm a bit unsure whether the new name still properly expresses their functionality, so feedback would be welcome:

~~~
&str : word_iter()             -> words()
       line_iter()             -> lines()
       any_line_iter()         -> lines_any()
       iter()                  -> chars()
       char_offset_iter()      -> char_indices()
       byte_iter()             -> bytes()
       split_iter()            -> split()
       splitn_iter()           -> splitn()
       split_str_iter()        -> split_str()
       split_terminator_iter() -> split_terminator()
       matches_index_iter()    -> match_indices()
       nfd_iter()              -> nfd_chars()
       nfkd_iter()             -> nfkd_chars()

&[T] : split_iter()        -> split()
       splitn_iter()       -> splitn()
       window_iter()       -> windows()
       chunk_iter()        -> chunks()
       permutations_iter() -> permutations()

extra:bitv::Bitv :  rev_liter()    -> rev_iter()
                    common_iter()  -> commons()
                    outlier_iter() -> outliers()

extra::treemap::{...} : lower_bound_iter() -> lower_bound()
                        upper_bound_iter() -> upper_bound()

std::trie::{...} : bound_iter()       -> bound()
                   lower_bound_iter() -> lower_bound()
                   upper_bound_iter() -> upper_bound()

rustpkg::package_id::{...} : prefixes_iter() -> prefixes()

std::hashmap::{...} : difference_iter()           -> difference()
                      symmetric_difference_iter() -> symmetric_difference()
                      intersection_iter()         -> intersection()
                      union_iter()                -> union()

std::path::{posix, windows} : component_iter()     -> components()
                              str_component_iter() -> str_components()

... not showing all identical renamings for reverse versions
~~~

---

I'm also planning a few more changes, like removing all unnecessary `_rev` constructors (#9391), or reducing the `split` variants on `&str` to a more versatile and concise system.

10 years agoRemoved unneccessary `_iter` suffixes from various APIs
Marvin Löbel [Sat, 23 Nov 2013 10:18:51 +0000 (11:18 +0100)]
Removed unneccessary `_iter` suffixes from various APIs

10 years agoUpdating docs with updated closure syntax, `&fn` -> `||`
Vijay Korapaty [Tue, 26 Nov 2013 08:02:39 +0000 (00:02 -0800)]
Updating docs with updated closure syntax, `&fn` -> `||`

10 years agoauto merge of #10631 : klutzy/rust/win-fixes, r=alexcrichton
bors [Tue, 26 Nov 2013 07:02:29 +0000 (23:02 -0800)]
auto merge of #10631 : klutzy/rust/win-fixes, r=alexcrichton

This patchset fixes some parts broken on Win64.

This also adds `--disable-pthreads` flags to llvm on mingw-w64 archs (both 32-bit and 64-bit, not mingw) due to bad performance. See #8996 for discussion.

10 years agoauto merge of #10316 : klutzy/rust/attr-lint, r=cmr
bors [Tue, 26 Nov 2013 05:47:16 +0000 (21:47 -0800)]
auto merge of #10316 : klutzy/rust/attr-lint, r=cmr

This patchset makes warning if crate-level attribute is used at other places, obsolete attributed is used, or unknown attribute is used, since they are usually from mistakes.

Closes #3348

10 years agorustc: Add crate-level attribute lint
klutzy [Mon, 25 Nov 2013 15:22:40 +0000 (00:22 +0900)]
rustc: Add crate-level attribute lint

10 years agorustc: Update obsolete attribute list
klutzy [Mon, 25 Nov 2013 14:17:01 +0000 (23:17 +0900)]
rustc: Update obsolete attribute list

10 years agoAdd test for unknown attribute lint
klutzy [Mon, 11 Nov 2013 08:51:27 +0000 (17:51 +0900)]
Add test for unknown attribute lint

10 years agorustc: Add lint for unknown attributes
klutzy [Mon, 11 Nov 2013 06:21:51 +0000 (15:21 +0900)]
rustc: Add lint for unknown attributes

10 years agoauto merge of #10652 : jld/rust/enum-unstruct, r=thestinger
bors [Tue, 26 Nov 2013 04:32:22 +0000 (20:32 -0800)]
auto merge of #10652 : jld/rust/enum-unstruct, r=thestinger

This is needed so that the FFI works as expected on platforms that don't
flatten aggregates the way the AMD64 ABI does, especially for `#[repr(C)]`.

This moves more of `type_of` into `trans::adt`, because the type might
or might not be an LLVM struct.

Closes #10308.

10 years agoAdd tests for attribute lint
klutzy [Wed, 6 Nov 2013 06:30:19 +0000 (15:30 +0900)]
Add tests for attribute lint

10 years agostd: Remove unused attributes
klutzy [Wed, 6 Nov 2013 03:16:47 +0000 (12:16 +0900)]
std: Remove unused attributes

This also enables two tests properly.

10 years agorustc: Add lint for obsolete attributes
klutzy [Wed, 6 Nov 2013 03:16:19 +0000 (12:16 +0900)]
rustc: Add lint for obsolete attributes

This also moves `#[auto_{en,de}code]` checker from syntax to lint.

10 years agorustc: Add lint for misplaced crate attributes
klutzy [Mon, 4 Nov 2013 15:35:56 +0000 (00:35 +0900)]
rustc: Add lint for misplaced crate attributes

10 years agoFix the usual check-fast scoping mistake.
Jed Davis [Tue, 26 Nov 2013 03:42:57 +0000 (19:42 -0800)]
Fix the usual check-fast scoping mistake.

10 years agoMove LittleLock to using RAII
Alex Crichton [Tue, 26 Nov 2013 01:55:41 +0000 (17:55 -0800)]
Move LittleLock to using RAII

This moves the locking/waiting methods to returning an RAII struct instead of
relying on closures. Additionally, this changes the methods to all take
'&mut self' to discourage recursive locking. The new method to block is to call
`wait` on the returned RAII structure instead of calling it on the lock itself
(this enforces that the lock is held).

At the same time, this improves the Mutex interface a bit by allowing
destruction of non-initialized members and by allowing construction of an empty
mutex (nothing initialized inside).

10 years agoauto merge of #10650 : andreasots/rust/ipv6-is-in-hex, r=alexcrichton
bors [Tue, 26 Nov 2013 01:46:32 +0000 (17:46 -0800)]
auto merge of #10650 : andreasots/rust/ipv6-is-in-hex, r=alexcrichton

Without this the assert in <tt>rust_malloc_ip6_addr</tt> is triggered as it expects a correctly formatted IPv6 address.

10 years agoauto merge of #10658 : LeoTestard/rust/serialize-rc, r=cmr
bors [Mon, 25 Nov 2013 21:11:43 +0000 (13:11 -0800)]
auto merge of #10658 : LeoTestard/rust/serialize-rc, r=cmr

Implement various traits (IterBytes and extra's Encodable and Decodable) for Rc<T> when T alreay implements the trait.

10 years agoauto merge of #10657 : sanxiyn/rust/pat, r=cmr
bors [Mon, 25 Nov 2013 19:56:40 +0000 (11:56 -0800)]
auto merge of #10657 : sanxiyn/rust/pat, r=cmr

10 years agoImplement IterBytes for Rc<T>.
Léo Testard [Mon, 25 Nov 2013 18:47:09 +0000 (19:47 +0100)]
Implement IterBytes for Rc<T>.

10 years agoAdd an implementation of Encodable and Decodable for Rc. This will be needed to use...
Léo Testard [Mon, 25 Nov 2013 18:35:03 +0000 (19:35 +0100)]
Add an implementation of Encodable and Decodable for Rc. This will be needed to use Rc in place of @ in libsyntax.

10 years agoTake &Pat in visit_pat
Seo Sanghyeon [Mon, 25 Nov 2013 18:22:21 +0000 (03:22 +0900)]
Take &Pat in visit_pat

10 years agoauto merge of #10653 : thestinger/rust/meaningless, r=huonw
bors [Mon, 25 Nov 2013 18:16:42 +0000 (10:16 -0800)]
auto merge of #10653 : thestinger/rust/meaningless, r=huonw

10 years agoauto merge of #10648 : sfackler/rust/base64-test, r=alexcrichton
bors [Mon, 25 Nov 2013 14:56:40 +0000 (06:56 -0800)]
auto merge of #10648 : sfackler/rust/base64-test, r=alexcrichton

We want a 1000 element array, not a 2 element array

10 years agoTake &Pat
Seo Sanghyeon [Mon, 25 Nov 2013 14:37:03 +0000 (23:37 +0900)]
Take &Pat

10 years agoRemove arms_have_move_bindings
Seo Sanghyeon [Mon, 25 Nov 2013 14:36:20 +0000 (23:36 +0900)]
Remove arms_have_move_bindings

10 years agoauto merge of #10646 : alexcrichton/rust/issue-10645, r=luqmana
bors [Mon, 25 Nov 2013 13:46:37 +0000 (05:46 -0800)]
auto merge of #10646 : alexcrichton/rust/issue-10645, r=luqmana

This is a behavioral difference in libuv between different platforms in
different situations. It turns out that libuv on windows will immediately
allocate a buffer instead of waiting for data to be ready. What this implies is
that we must have our custom data set on the handle before we call
uv_read_start.

I wish I knew of a way to test this, but this relies to being on the windows
platform *and* reading from a true TTY handle which only happens when this is
actually attached to a terminal. I have manually verified this works.

Closes #10645

10 years agorm #[mutable_doc]
Daniel Micay [Mon, 25 Nov 2013 12:44:47 +0000 (07:44 -0500)]
rm #[mutable_doc]

10 years agoauto merge of #10644 : cmr/rust/rustdoc_cfg, r=alexcrichton
bors [Mon, 25 Nov 2013 11:42:40 +0000 (03:42 -0800)]
auto merge of #10644 : cmr/rust/rustdoc_cfg, r=alexcrichton

Closes #10623

10 years agoauto merge of #10643 : jorendorff/rust/master, r=alexcrichton
bors [Mon, 25 Nov 2013 10:27:01 +0000 (02:27 -0800)]
auto merge of #10643 : jorendorff/rust/master, r=alexcrichton

10 years agoauto merge of #10628 : huonw/rust/3614, r=alexcrichton
bors [Mon, 25 Nov 2013 09:12:36 +0000 (01:12 -0800)]
auto merge of #10628 : huonw/rust/3614, r=alexcrichton

Fixes #3614.

10 years agosyntax: parse inner attributes on impls.
Huon Wilson [Sun, 24 Nov 2013 00:48:46 +0000 (11:48 +1100)]
syntax: parse inner attributes on impls.

Fixes #3614.

10 years agoFix typo in base64 test
Steven Fackler [Mon, 25 Nov 2013 08:10:31 +0000 (00:10 -0800)]
Fix typo in base64 test

We want a 1000 element array, not a 2 element array

10 years agoauto merge of #10641 : cmr/rust/close_delims, r=alexcrichton
bors [Mon, 25 Nov 2013 07:56:46 +0000 (23:56 -0800)]
auto merge of #10641 : cmr/rust/close_delims, r=alexcrichton

Currently, the parser doesn't give any context when it finds an unclosed
delimiter and it's not EOF. Report the most recent unclosed delimiter, to help
the user along.

Closes #10636

10 years agoauto merge of #10635 : alexcrichton/rust/issue-10626, r=cmr
bors [Mon, 25 Nov 2013 06:47:10 +0000 (22:47 -0800)]
auto merge of #10635 : alexcrichton/rust/issue-10626, r=cmr

This is both useful for performance (otherwise logging is unbuffered), but also
useful for correctness. Because when a task is destroyed we can't block the task
waiting for the logger to close, loggers are opened with a 'CloseAsynchronously'
specification. This causes libuv do defer the call to close() until the next
turn of the event loop.

If you spin in a tight loop around printing, you never yield control back to the
libuv event loop, meaning that you simply enqueue a large number of close
requests but nothing is actually closed. This queue ends up never getting
closed, meaning that if you keep trying to create handles one will eventually
fail, which the runtime will attempt to print the failure, causing mass
destruction.

Caching will provide better performance as well as prevent creation of too many
handles.

Closes #10626

10 years agoRepresent C-like enums with a plain LLVM integer, not a struct.
Jed Davis [Fri, 22 Nov 2013 09:16:17 +0000 (01:16 -0800)]
Represent C-like enums with a plain LLVM integer, not a struct.

This is needed so that the FFI works as expected on platforms that don't
flatten aggregates the way the AMD64 ABI does, especially for `#[repr(C)]`.

This moves more of `type_of` into `trans::adt`, because the type might
or might not be an LLVM struct.

10 years agostd: IPv6 addresses are represented as eight groups of four HEXADECIMAL digits
Andreas Ots [Mon, 25 Nov 2013 05:55:58 +0000 (07:55 +0200)]
std: IPv6 addresses are represented as eight groups of four HEXADECIMAL digits

10 years agoSet uv's custom data before uv_read_start
Alex Crichton [Mon, 25 Nov 2013 05:47:13 +0000 (21:47 -0800)]
Set uv's custom data before uv_read_start

This is a behavioral difference in libuv between different platforms in
different situations. It turns out that libuv on windows will immediately
allocate a buffer instead of waiting for data to be ready. What this implies is
that we must have our custom data set on the handle before we call
uv_read_start.

I wish I knew of a way to test this, but this relies to being on the windows
platform *and* reading from a true TTY handle which only happens when this is
actually attached to a terminal. I have manually verified this works.

Closes #10645

10 years agoauto merge of #10603 : alexcrichton/rust/no-linked-failure, r=brson
bors [Mon, 25 Nov 2013 05:32:13 +0000 (21:32 -0800)]
auto merge of #10603 : alexcrichton/rust/no-linked-failure, r=brson

The reasons for doing this are:

* The model on which linked failure is based is inherently complex
* The implementation is also very complex, and there are few remaining who
  fully understand the implementation
* There are existing race conditions in the core context switching function of
  the scheduler, and possibly others.
* It's unclear whether this model of linked failure maps well to a 1:1 threading
  model

Linked failure is often a desired aspect of tasks, but we would like to take a
much more conservative approach in re-implementing linked failure if at all.

Closes #8674
Closes #8318
Closes #8863

10 years agoCache a task's stderr logger
Alex Crichton [Sun, 24 Nov 2013 18:55:17 +0000 (10:55 -0800)]
Cache a task's stderr logger

This is both useful for performance (otherwise logging is unbuffered), but also
useful for correctness. Because when a task is destroyed we can't block the task
waiting for the logger to close, loggers are opened with a 'CloseAsynchronously'
specification. This causes libuv do defer the call to close() until the next
turn of the event loop.

If you spin in a tight loop around printing, you never yield control back to the
libuv event loop, meaning that you simply enqueue a large number of close
requests but nothing is actually closed. This queue ends up never getting
closed, meaning that if you keep trying to create handles one will eventually
fail, which the runtime will attempt to print the failure, causing mass
destruction.

Caching will provide better performance as well as prevent creation of too many
handles.

Closes #10626

10 years agoRemove linked failure from the runtime
Alex Crichton [Fri, 22 Nov 2013 00:55:40 +0000 (16:55 -0800)]
Remove linked failure from the runtime

The reasons for doing this are:

* The model on which linked failure is based is inherently complex
* The implementation is also very complex, and there are few remaining who
  fully understand the implementation
* There are existing race conditions in the core context switching function of
  the scheduler, and possibly others.
* It's unclear whether this model of linked failure maps well to a 1:1 threading
  model

Linked failure is often a desired aspect of tasks, but we would like to take a
much more conservative approach in re-implementing linked failure if at all.

Closes #8674
Closes #8318
Closes #8863

10 years agorustdoc: pass through --cfg to rustc
Corey Richardson [Mon, 25 Nov 2013 04:31:21 +0000 (23:31 -0500)]
rustdoc: pass through --cfg to rustc

Closes #10623

10 years agoFix spelling of "vacuum" in one of the abort quotes.
Jason Orendorff [Mon, 25 Nov 2013 04:29:48 +0000 (22:29 -0600)]
Fix spelling of "vacuum" in one of the abort quotes.

10 years agoauto merge of #10639 : jix/rust/fix_find_mut_in_trie, r=thestinger
bors [Mon, 25 Nov 2013 04:22:03 +0000 (20:22 -0800)]
auto merge of #10639 : jix/rust/fix_find_mut_in_trie, r=thestinger

Make TrieMap/TrieSet's find_mut check the key for external nodes.
Without this find_mut sometimes returns a reference to another key when
querying for a non-present key.

10 years agoauto merge of #10637 : luqmana/rust/nmt, r=cmr
bors [Mon, 25 Nov 2013 03:07:44 +0000 (19:07 -0800)]
auto merge of #10637 : luqmana/rust/nmt, r=cmr

There's no need for it to be @mut.

10 years agoAdd a note for unclosed delimiters
Corey Richardson [Mon, 25 Nov 2013 02:18:20 +0000 (21:18 -0500)]
Add a note for unclosed delimiters

Currently, the parser doesn't give any context when it finds an unclosed
delimiter and it's not EOF. Report the most recent unclosed delimiter, to help
the user along.

Closes #10636

10 years agoauto merge of #10600 : ktt3ja/rust/add-doc, r=huonw
bors [Mon, 25 Nov 2013 00:46:50 +0000 (16:46 -0800)]
auto merge of #10600 : ktt3ja/rust/add-doc, r=huonw

I received a lot of helpful explanations when I was going through rustc's middle-end code. I document some of them here.

10 years agoAdd comments to ast, ast_map, ty, and pat_util
Kiet Tran [Sun, 24 Nov 2013 23:38:41 +0000 (18:38 -0500)]
Add comments to ast, ast_map, ty, and pat_util

10 years agolibextra: Remove @mut from term.
Luqman Aden [Sun, 24 Nov 2013 11:53:08 +0000 (06:53 -0500)]
libextra: Remove @mut from term.

10 years agostd::trie: Fix find_mut for non-present keys
Jannis Harder [Sun, 24 Nov 2013 22:41:33 +0000 (23:41 +0100)]
std::trie: Fix find_mut for non-present keys

Make TrieMap/TrieSet's find_mut check the key for external nodes.
Without this find_mut sometimes returns a reference to another key when
querying for a non-present key.

10 years agoauto merge of #10475 : astrieanna/rust/issue8763, r=alexcrichton
bors [Sun, 24 Nov 2013 18:17:03 +0000 (10:17 -0800)]
auto merge of #10475 : astrieanna/rust/issue8763, r=alexcrichton

Issue #8763 is about improving a particular error message.

* added case & better error message for "impl trait for module"
* added compile-fail test trait-impl-for-module.rs
* updated copyright dates
* revised compile-fail test trait-or-new-type-instead
   (the error message for the modified test is still unclear, but that's a different bug https://github.com/mozilla/rust/issues/8767)

10 years agoFix issue #8763
Leah Hanson [Thu, 14 Nov 2013 03:29:37 +0000 (21:29 -0600)]
Fix issue #8763

* added case & better error message for "impl trait for module"
* used better way to print the module
* switched from //error-pattern to //~ ERROR
* added compile-fail test trait-impl-for-module.rs
* revised compile-fail test trait-or-new-type-instead
    (the error message for the modified test is still unclear, but that's a different bug)
* added FIXME to trait-or-new-type-instead

10 years agoauto merge of #10634 : LeoTestard/rust/rc-eq, r=cmr
bors [Sun, 24 Nov 2013 16:42:35 +0000 (08:42 -0800)]
auto merge of #10634 : LeoTestard/rust/rc-eq, r=cmr

10 years agoImplement cmp traits for Rc<T> and add a ptr_eq method.
Léo Testard [Sun, 24 Nov 2013 16:29:44 +0000 (17:29 +0100)]
Implement cmp traits for Rc<T> and add a ptr_eq method.

10 years agoauto merge of #10633 : cmr/rust/linker_opts, r=thestinger
bors [Sun, 24 Nov 2013 13:56:28 +0000 (05:56 -0800)]
auto merge of #10633 : cmr/rust/linker_opts, r=thestinger

r? @Luqmana

10 years agoUse -O1 for non-GNU linkers
Corey Richardson [Sun, 24 Nov 2013 13:50:16 +0000 (08:50 -0500)]
Use -O1 for non-GNU linkers

10 years agostd::rt: Fix crate_map on Win64
klutzy [Sun, 24 Nov 2013 09:42:40 +0000 (18:42 +0900)]
std::rt: Fix crate_map on Win64

10 years agostd::rt: Fix record_stack_bounds on win64
klutzy [Sun, 24 Nov 2013 07:04:55 +0000 (16:04 +0900)]
std::rt: Fix record_stack_bounds on win64

10 years agollvm: Disable pthreads on mingw-w64 platforms
klutzy [Sun, 24 Nov 2013 05:21:35 +0000 (14:21 +0900)]
llvm: Disable pthreads on mingw-w64 platforms

10 years agostd: Fix transmute error on win64
klutzy [Sat, 23 Nov 2013 20:48:45 +0000 (05:48 +0900)]
std: Fix transmute error on win64

10 years agostd::libc: Simplify win32/win64 type definitions
klutzy [Sat, 23 Nov 2013 15:51:46 +0000 (00:51 +0900)]
std::libc: Simplify win32/win64 type definitions

10 years agostd::libc: Remove TCHAR types
klutzy [Sat, 23 Nov 2013 13:42:51 +0000 (22:42 +0900)]
std::libc: Remove TCHAR types

10 years agoauto merge of #10625 : huonw/rust/json-errors, r=alexcrichton
bors [Sun, 24 Nov 2013 09:26:30 +0000 (01:26 -0800)]
auto merge of #10625 : huonw/rust/json-errors, r=alexcrichton

Fixes #4244.

10 years agoauto merge of #10620 : cmr/rust/linker_opts, r=thestinger
bors [Sun, 24 Nov 2013 07:56:30 +0000 (23:56 -0800)]
auto merge of #10620 : cmr/rust/linker_opts, r=thestinger

10 years agoauto merge of #10578 : luqmana/rust/mingw64, r=alexcrichton
bors [Sun, 24 Nov 2013 05:36:50 +0000 (21:36 -0800)]
auto merge of #10578 : luqmana/rust/mingw64, r=alexcrichton

With these changes I was able to cross compile for windows from a linux box. (Using the mingw-w64 package on Debian Testing).

Fixed a bug where the `target_family` cfg would be wrong when targeting something with a different value than the host. (i.e windows -> unix or unix -> windows).

Also, removed `LIBUV_FLAGS` in `mk/rt.mk` because of the redundancy between it and `CFG_GCCISH_CFLAGS_(target)`.

After this we can create a snapshot and migrate to mingw64 instead of mingw32.

10 years agoauto merge of #10514 : sfackler/rust/mut, r=cmr
bors [Sun, 24 Nov 2013 04:01:42 +0000 (20:01 -0800)]
auto merge of #10514 : sfackler/rust/mut, r=cmr

This is based off of @blake2-ppc's work on #9429. That PR bitrotted and I haven't been able to contact the original author so I decided to take up the cause.

Overview
======
`Mut` encapsulates a mutable, non-nullable slot. The `Cell` type is currently used to do this, but `Cell` is much more commonly used as a workaround for the inability to move values into non-once functions. `Mut` provides a more robust API.

`Mut` duplicates the semantics of borrowed pointers with enforcement at runtime instead of compile time.
```rust
let x = Mut::new(0);

{
    // make some immutable borrows
    let p = x.borrow();
    let y = *p.get() + 10;

    // multiple immutable borrows are allowed simultaneously
    let p2 = x.borrow();

    // this would throw a runtime failure
    // let p_mut = x.borrow_mut();
}

// now we can mutably borrow
let p = x.borrow_mut();
*p.get() = 10;
```
`borrow` returns a `Ref` type and `borrow_mut` returns a `RefMut` type, both of which are simple smart pointer types with a single method, `get`, which returns a reference to the wrapped data.

This also allows `RcMut<T>` to be deleted, as it can be replaced with `Rc<Mut<T>>`.

Changes
======
I've done things a little bit differently than the original proposal.

* I've added `try_borrow` and `try_borrow_mut` methods that return `Option<Ref<T>>` and `Option<RefMut<T>>` respectively instead of failing on a borrow check failure. I'm not totally sure when that'd be useful, but I don't see any reason to not put them in and @cmr requested them.
* `ReadPtr` and `WritePtr` have been renamed to `Ref` and `RefMut` respectively, as `Ref` is to `ref foo` and `RefMut` is to `ref mut foo` as `Mut` is to `mut foo`.
* `get` on `MutRef` now takes `&self` instead of `&mut self` for consistency with `&mut`. As @alexcrichton pointed, out this violates soundness by allowing aliasing `&mut` references.
* `Cell` is being left as is. It solves a different problem than `Mut` is designed to solve.
* There are no longer methods implemented for `Mut<Option<T>>`. Since `Cell` isn't going away, there's less of a need for these, and I didn't feel like they provided a huge benefit, especially as that kind of `impl` is very uncommon in the standard library.

Open Questions
============
* `Cell` should now be used exclusively for movement into closures. Should this be enforced by reducing its API to `new` and `take`? It seems like this use case will be completely going away once the transition to `proc` and co. finishes.
* Should there be `try_map` and `try_map_mut` methods along with `map` and `map_mut`?

10 years agoextra: improve the errors for the JSON Decoder.
Huon Wilson [Sat, 23 Nov 2013 23:17:34 +0000 (10:17 +1100)]
extra: improve the errors for the JSON Decoder.

Fixes #4244.

10 years agoMove mutable::Mut to cell::RefCell
Steven Fackler [Fri, 22 Nov 2013 05:30:34 +0000 (21:30 -0800)]
Move mutable::Mut to cell::RefCell

10 years agoUse linker optimizations on Linux
Corey Richardson [Sat, 23 Nov 2013 14:14:44 +0000 (09:14 -0500)]
Use linker optimizations on Linux

10 years agoUse CXX not CC for linking.
Luqman Aden [Sat, 23 Nov 2013 09:49:16 +0000 (04:49 -0500)]
Use CXX not CC for linking.

10 years agoauto merge of #10611 : cmr/rust/ascii_flesh, r=pcwalton
bors [Sat, 23 Nov 2013 07:06:24 +0000 (23:06 -0800)]
auto merge of #10611 : cmr/rust/ascii_flesh, r=pcwalton

These are super boring. I can add tests if really desired, but they'd be long
and even more boring than the methods.

10 years agoAdd ctype-likes to Ascii
Corey Richardson [Fri, 22 Nov 2013 16:38:50 +0000 (11:38 -0500)]
Add ctype-likes to Ascii

10 years agoRemove sjlj stuff from rust_upcall and don't pass -Werror to libuv.
Luqman Aden [Sat, 23 Nov 2013 02:21:37 +0000 (21:21 -0500)]
Remove sjlj stuff from rust_upcall and don't pass -Werror to libuv.

10 years agoAdd Rc::from_mut
Steven Fackler [Sun, 17 Nov 2013 05:59:42 +0000 (21:59 -0800)]
Add Rc::from_mut

10 years agoMore Mut tests
Steven Fackler [Sat, 16 Nov 2013 22:35:35 +0000 (14:35 -0800)]
More Mut tests

10 years agoStrip down Cell functionality
Steven Fackler [Sat, 16 Nov 2013 21:26:15 +0000 (13:26 -0800)]
Strip down Cell functionality

10 years agoChange Mut::map to Mut::with
Steven Fackler [Sat, 16 Nov 2013 19:19:25 +0000 (11:19 -0800)]
Change Mut::map to Mut::with

10 years agoMake MutRef more consistent with &mut
Steven Fackler [Sat, 16 Nov 2013 07:48:02 +0000 (23:48 -0800)]
Make MutRef more consistent with &mut

10 years agoCell -> Mut switch in comm
Steven Fackler [Sat, 16 Nov 2013 05:08:31 +0000 (21:08 -0800)]
Cell -> Mut switch in comm

10 years agoMove Rc tests away from Cell
Steven Fackler [Fri, 15 Nov 2013 07:25:00 +0000 (23:25 -0800)]
Move Rc tests away from Cell

10 years agoRemove RcMut
Steven Fackler [Fri, 15 Nov 2013 03:57:11 +0000 (19:57 -0800)]
Remove RcMut

Rc<Mut<T>> should be used instead

10 years agoIntroduce Mut<T> to libstd
Steven Fackler [Thu, 14 Nov 2013 07:46:47 +0000 (23:46 -0800)]
Introduce Mut<T> to libstd

Based off of blake2-ppc's work in #9429.

10 years agomk: Get rid of redundant LIBUV_FLAGS.
Luqman Aden [Wed, 20 Nov 2013 11:00:49 +0000 (06:00 -0500)]
mk: Get rid of redundant LIBUV_FLAGS.

10 years agoFix up mingw64 target.
Luqman Aden [Wed, 20 Nov 2013 06:30:51 +0000 (01:30 -0500)]
Fix up mingw64 target.

10 years agoauto merge of #10605 : huonw/rust/ascii-ident-gate, r=pcwalton
bors [Fri, 22 Nov 2013 21:51:34 +0000 (13:51 -0800)]
auto merge of #10605 : huonw/rust/ascii-ident-gate, r=pcwalton

cf. https://mail.mozilla.org/pipermail/rust-dev/2013-November/006920.html

10 years agoPut non-ascii identifiers behind a feature gate.
Huon Wilson [Fri, 22 Nov 2013 12:25:14 +0000 (23:25 +1100)]
Put non-ascii identifiers behind a feature gate.

cf. https://mail.mozilla.org/pipermail/rust-dev/2013-November/006920.html

10 years agoauto merge of #10612 : pnkfelix/rust/remove-cut-and-pasted-rt-fixme, r=pcwalton
bors [Fri, 22 Nov 2013 20:41:36 +0000 (12:41 -0800)]
auto merge of #10612 : pnkfelix/rust/remove-cut-and-pasted-rt-fixme, r=pcwalton

I cannot tell whether the original comment was unsure about the
arithmetic calculations, or if it was unsure about the assumptions
being made about the alignment of the current allocation pointer.

The arithmetic calculation looks fine to me, though.  This technique
is documented e.g. in Henry Warren's "Hacker's Delight" (section 3-1).

(I am sure one can find it elsewhere too, its not an obscure
property.)

10 years agoauto merge of #10583 : alexcrichton/rust/privacy-reexport, r=pcwalton
bors [Fri, 22 Nov 2013 18:06:35 +0000 (10:06 -0800)]
auto merge of #10583 : alexcrichton/rust/privacy-reexport, r=pcwalton

I added a test case which does not compile today, and required changes on
privacy's side of things to get right. Additionally, this moves a good bit of
logic which did not belong in reachability into privacy.

All of reachability should solely be responsible for determining what the
reachable surface area of a crate is given the exported surface area (where the
exported surface area is that which is usable by external crates).

Privacy will now correctly figure out what's exported by deeply looking
through reexports. Previously if a module were reexported under another name,
nothing in the module would actually get exported in the executable. I also
consolidated the phases of privacy to be clearer about what's an input to what.
The privacy checking pass no longer uses the notion of an "all public" path, and
the embargo visitor is no longer an input to the checking pass.

Currently the embargo visitor is built as a saturating analysis because it's
unknown what portions of the AST are going to get re-exported.

This also cracks down on exported methods from impl blocks and trait blocks. If you implement a private trait, none of the symbols are exported, and if you have an impl for a private type none of the symbols are exported either. On the other hand, if you implement a public trait for a private type, the symbols are still exported. I'm unclear on whether this last part is correct, but librustc will fail to link unless it's in place.

10 years agoMove more of the exportation burden into privacy
Alex Crichton [Wed, 20 Nov 2013 23:15:34 +0000 (15:15 -0800)]
Move more of the exportation burden into privacy

I added a test case which does not compile today, and required changes on
privacy's side of things to get right. Additionally, this moves a good bit of
logic which did not belong in reachability into privacy.

All of reachability should solely be responsible for determining what the
reachable surface area of a crate is given the exported surface area (where the
exported surface area is that which is usable by external crates).

Privacy will now correctly figure out what's exported by deeply looking
through reexports. Previously if a module were reexported under another name,
nothing in the module would actually get exported in the executable. I also
consolidated the phases of privacy to be clearer about what's an input to what.
The privacy checking pass no longer uses the notion of an "all public" path, and
the embargo visitor is no longer an input to the checking pass.

Currently the embargo visitor is built as a saturating analysis because it's
unknown what portions of the AST are going to get re-exported.

10 years agoThe original fixme #2699 was removed back in PR #6053.
Felix S. Klock II [Fri, 22 Nov 2013 17:00:21 +0000 (18:00 +0100)]
The original fixme #2699 was removed back in PR #6053.

I cannot tell whether the original comment was unsure about the
arithmetic calculations, or if it was unsure about the assumptions
being made about the alignment of the current allocation pointer.

The arithmetic calculation looks fine to me, though.  This technique
is documented e.g. in Henry Warren's "Hacker's Delight" (section 3-1).

(I am sure one can find it elsewhere too, its not an obscure
property.)

10 years agoauto merge of #10610 : thestinger/rust/breakpoint, r=pnkfelix
bors [Fri, 22 Nov 2013 15:31:35 +0000 (07:31 -0800)]
auto merge of #10610 : thestinger/rust/breakpoint, r=pnkfelix

This can be used to grab the attention of a debugger, and unlike
`abort` execution can be resumed.

10 years agoadd a breakpoint intrinsic for debugging
Daniel Micay [Fri, 22 Nov 2013 15:12:56 +0000 (10:12 -0500)]
add a breakpoint intrinsic for debugging

This can be used to grab the attention of a debugger, and unlike
`abort` execution can be resumed.

10 years agoauto merge of #10608 : thestinger/rust/managed, r=huonw
bors [Fri, 22 Nov 2013 13:52:01 +0000 (05:52 -0800)]
auto merge of #10608 : thestinger/rust/managed, r=huonw

10 years agoauto merge of #10606 : huonw/rust/lint-unsafe-in-macro, r=thestinger
bors [Fri, 22 Nov 2013 12:41:33 +0000 (04:41 -0800)]
auto merge of #10606 : huonw/rust/lint-unsafe-in-macro, r=thestinger

Add a test for the case I mentioned on #10599.

10 years agosyntax: add a visit_ident method to the Visitor.
Huon Wilson [Fri, 22 Nov 2013 12:24:49 +0000 (23:24 +1100)]
syntax: add a visit_ident method to the Visitor.