about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2016-05-30Prevent the borrow counter from overflowing in `Ref::clone`Tobias Bucher-1/+3
Fixes #33880.
2016-05-28Rollup merge of #33849 - ranma42:escape-iters-count, r=alexcrichtonManish Goregaokar-28/+50
Implement `count` for `EscapeUnicode` and cleanup the code for `count` for `EscapeDefault` (instead of repeating the `match` for `size_hint` and `count`). This PR marks EscapeUnicode and EscapeDefault as ExactSizeIterator. The constraints for the trait implementations held even before this PR, but I am not sure if this is something we want to guarantee/expose (I would love feedback on this, especially on what would be the appropriate way to handle stabilisation, if needed). Part of #24214, split from #31049. The test for `count` was added in #33103.
2016-05-27make core::str::next_code_point work on arbitrary iteratorM Farkas-Dyck-2/+3
2016-05-27Rollup merge of #33815 - carols10cents:trait-documentation-clarifications, ↵Guillaume Gomez-100/+313
r=steveklabnik Trait documentation clarifications Hi! I've felt a bit of friction lately in figuring out how to write custom implementations of the `derive`able traits, so I decided to add to the docs :) The docs for `Copy` are already excellent-- clear, useful sections that I only reordered a bit-- they're now: * General explanation * When can my type be `Copy`? * When can my type _not_ be `Copy`? * When should my type be `Copy`? * Derivable * How can I implement `Copy`? I didn't add all these sections for all the traits, but I did make sure all the derivable traits had a consistent "Derivable" section that explained what the derived implementation does and a "How can I implement" section that has an example. Please check me for correctness-- I tried to do research to make sure I was saying accurate things but I'm still learning! ❤️ I'd also love suggestions on information to add that is still missing-- I think these traits are important and deserve to have awesome docs!
2016-05-26core: check pointer equality when comparing byte slicesSean McArthur-0/+3
2016-05-26Explain the order of the enumeration itemsAndrea Canciani-0/+3
Simply a micro-optimization to reduce code size and to open up inlining opportunities.
2016-05-26Move length computation to `ExactSizeIterator` implsAndrea Canciani-24/+36
and reuse it in `size_hint`.
2016-05-26Implement `count` for `EscapeDefault` and `EscapeUnicode`Andrea Canciani-6/+7
Trivial implementation, as both are `ExactSizeIterator`s. Part of #24214.
2016-05-26`EscapeUnicode` and `EscapeDefault` are `ExactSizeIterator`sAndrea Canciani-0/+6
In #28662, `size_hint` was made exact for `EscapeUnicode` and `EscapeDefault`, but neither was marked as `ExactSizeIterator`.
2016-05-25Auto merge of #33699 - alexcrichton:stabilize-1.10, r=aturonbors-21/+13
std: Stabilize APIs for the 1.10 release This commit applies the FCP decisions made by the libs team for the 1.10 cycle, including both new stabilizations and deprecations. Specifically, the list of APIs is: Stabilized: * `os::windows::fs::OpenOptionsExt::access_mode` * `os::windows::fs::OpenOptionsExt::share_mode` * `os::windows::fs::OpenOptionsExt::custom_flags` * `os::windows::fs::OpenOptionsExt::attributes` * `os::windows::fs::OpenOptionsExt::security_qos_flags` * `os::unix::fs::OpenOptionsExt::custom_flags` * `sync::Weak::new` * `Default for sync::Weak` * `panic::set_hook` * `panic::take_hook` * `panic::PanicInfo` * `panic::PanicInfo::payload` * `panic::PanicInfo::location` * `panic::Location` * `panic::Location::file` * `panic::Location::line` * `ffi::CStr::from_bytes_with_nul` * `ffi::CStr::from_bytes_with_nul_unchecked` * `ffi::FromBytesWithNulError` * `fs::Metadata::modified` * `fs::Metadata::accessed` * `fs::Metadata::created` * `sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange` * `sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange_weak` * `collections::{btree,hash}_map::{Occupied,Vacant,}Entry::key` * `os::unix::net::{UnixStream, UnixListener, UnixDatagram, SocketAddr}` * `SocketAddr::is_unnamed` * `SocketAddr::as_pathname` * `UnixStream::connect` * `UnixStream::pair` * `UnixStream::try_clone` * `UnixStream::local_addr` * `UnixStream::peer_addr` * `UnixStream::set_read_timeout` * `UnixStream::set_write_timeout` * `UnixStream::read_timeout` * `UnixStream::write_Timeout` * `UnixStream::set_nonblocking` * `UnixStream::take_error` * `UnixStream::shutdown` * Read/Write/RawFd impls for `UnixStream` * `UnixListener::bind` * `UnixListener::accept` * `UnixListener::try_clone` * `UnixListener::local_addr` * `UnixListener::set_nonblocking` * `UnixListener::take_error` * `UnixListener::incoming` * RawFd impls for `UnixListener` * `UnixDatagram::bind` * `UnixDatagram::unbound` * `UnixDatagram::pair` * `UnixDatagram::connect` * `UnixDatagram::try_clone` * `UnixDatagram::local_addr` * `UnixDatagram::peer_addr` * `UnixDatagram::recv_from` * `UnixDatagram::recv` * `UnixDatagram::send_to` * `UnixDatagram::send` * `UnixDatagram::set_read_timeout` * `UnixDatagram::set_write_timeout` * `UnixDatagram::read_timeout` * `UnixDatagram::write_timeout` * `UnixDatagram::set_nonblocking` * `UnixDatagram::take_error` * `UnixDatagram::shutdown` * RawFd impls for `UnixDatagram` * `{BTree,Hash}Map::values_mut` * `<[_]>::binary_search_by_key` Deprecated: * `StaticCondvar` - this, and all other static synchronization primitives below, are usable today through the lazy-static crate on stable Rust today. Additionally, we'd like the non-static versions to be directly usable in a static context one day, so they're unlikely to be the final forms of the APIs in any case. * `CONDVAR_INIT` * `StaticMutex` * `MUTEX_INIT` * `StaticRwLock` * `RWLOCK_INIT` * `iter::Peekable::is_empty` Closes #27717 Closes #27720 Closes #30014 Closes #30425 Closes #30449 Closes #31190 Closes #31399 Closes #31767 Closes #32111 Closes #32281 Closes #32312 Closes #32551 Closes #33018
2016-05-25Auto merge of #33667 - pnkfelix:fixes-to-mir-dataflow, r=arielb1bors-0/+10
Fixes to mir dataflow Fixes to mir dataflow This collects a bunch of changes to `rustc_borrowck::borrowck::dataflow` (which others have pointed out should probably migrate to some crate that isn't tied to the borrow-checker -- but I have not attempted that here, especially since there are competing approaches to dataflow that we should also evaluate). These changes: 1. Provide a family of related analyses: MovingOutStatements (which is what the old AST-based dataflo computed), as well as MaybeInitialized, MaybeUninitalized, and DefinitelyInitialized. * (The last two are actually inverses of each other; we should pick one and drop the other.) 2. Fix bugs in the pre-existing analysis implementation, which was untested and thus some obvious bugs went unnoticed, which brings us to the third point: 3. Add a unit test infrastructure for the MIR dataflow analysis. * The tests work by adding a new intrinsic that is able to query the analysis state for a particular expression (technically, a particular L-value). * See the examples in compile-fail/mir-dataflow/inits-1.rs and compile-fail/mir-dataflow/uninits-1.rs * These tests are only checking the results for MaybeInitialized, MaybeUninitalized, and DefinitelyInitialized; I am not sure if it will be feasible to generalize this testing strategy to the MovingOutStatements dataflow operator.
2016-05-24std: Stabilize APIs for the 1.10 releaseAlex Crichton-21/+13
This commit applies the FCP decisions made by the libs team for the 1.10 cycle, including both new stabilizations and deprecations. Specifically, the list of APIs is: Stabilized: * `os::windows::fs::OpenOptionsExt::access_mode` * `os::windows::fs::OpenOptionsExt::share_mode` * `os::windows::fs::OpenOptionsExt::custom_flags` * `os::windows::fs::OpenOptionsExt::attributes` * `os::windows::fs::OpenOptionsExt::security_qos_flags` * `os::unix::fs::OpenOptionsExt::custom_flags` * `sync::Weak::new` * `Default for sync::Weak` * `panic::set_hook` * `panic::take_hook` * `panic::PanicInfo` * `panic::PanicInfo::payload` * `panic::PanicInfo::location` * `panic::Location` * `panic::Location::file` * `panic::Location::line` * `ffi::CStr::from_bytes_with_nul` * `ffi::CStr::from_bytes_with_nul_unchecked` * `ffi::FromBytesWithNulError` * `fs::Metadata::modified` * `fs::Metadata::accessed` * `fs::Metadata::created` * `sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange` * `sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange_weak` * `collections::{btree,hash}_map::{Occupied,Vacant,}Entry::key` * `os::unix::net::{UnixStream, UnixListener, UnixDatagram, SocketAddr}` * `SocketAddr::is_unnamed` * `SocketAddr::as_pathname` * `UnixStream::connect` * `UnixStream::pair` * `UnixStream::try_clone` * `UnixStream::local_addr` * `UnixStream::peer_addr` * `UnixStream::set_read_timeout` * `UnixStream::set_write_timeout` * `UnixStream::read_timeout` * `UnixStream::write_Timeout` * `UnixStream::set_nonblocking` * `UnixStream::take_error` * `UnixStream::shutdown` * Read/Write/RawFd impls for `UnixStream` * `UnixListener::bind` * `UnixListener::accept` * `UnixListener::try_clone` * `UnixListener::local_addr` * `UnixListener::set_nonblocking` * `UnixListener::take_error` * `UnixListener::incoming` * RawFd impls for `UnixListener` * `UnixDatagram::bind` * `UnixDatagram::unbound` * `UnixDatagram::pair` * `UnixDatagram::connect` * `UnixDatagram::try_clone` * `UnixDatagram::local_addr` * `UnixDatagram::peer_addr` * `UnixDatagram::recv_from` * `UnixDatagram::recv` * `UnixDatagram::send_to` * `UnixDatagram::send` * `UnixDatagram::set_read_timeout` * `UnixDatagram::set_write_timeout` * `UnixDatagram::read_timeout` * `UnixDatagram::write_timeout` * `UnixDatagram::set_nonblocking` * `UnixDatagram::take_error` * `UnixDatagram::shutdown` * RawFd impls for `UnixDatagram` * `{BTree,Hash}Map::values_mut` * `<[_]>::binary_search_by_key` Deprecated: * `StaticCondvar` - this, and all other static synchronization primitives below, are usable today through the lazy-static crate on stable Rust today. Additionally, we'd like the non-static versions to be directly usable in a static context one day, so they're unlikely to be the final forms of the APIs in any case. * `CONDVAR_INIT` * `StaticMutex` * `MUTEX_INIT` * `StaticRwLock` * `RWLOCK_INIT` * `iter::Peekable::is_empty` Closes #27717 Closes #27720 cc #27784 (but encode methods still exist) Closes #30014 Closes #30425 Closes #30449 Closes #31190 Closes #31399 Closes #31767 Closes #32111 Closes #32281 Closes #32312 Closes #32551 Closes #33018
2016-05-23"the trait `Hash`" => "the `Hash` trait"Carol (Nichols || Goulding)-2/+2
2016-05-23Complete `PartialOrd`'s example so it passes make check-docsCarol (Nichols || Goulding)-0/+21
2016-05-23Move all `Default` docs from module to traitCarol (Nichols || Goulding)-73/+42
I had already copied the implementation example in a previous commit; this copies the explanation and usage examples to the general trait description.
2016-05-23Prefer `ClassName` over `Self` in example trait implementationsCarol (Nichols || Goulding)-9/+9
2016-05-23Use `()` when referring to functionsCarol (Nichols || Goulding)-4/+4
2016-05-23Add some newlines in some code examplesCarol (Nichols || Goulding)-0/+2
2016-05-23"non equal" => "not equal"; consistent with the surrounding textCarol (Nichols || Goulding)-1/+1
2016-05-23"more than 32" => "more than 32 elements"Carol (Nichols || Goulding)-2/+2
2016-05-23Emphasize semantic differences of Copy/Clone rather than implCarol (Nichols || Goulding)-3/+4
2016-05-23Shorten, yet clarify, initial summary sentencesCarol (Nichols || Goulding)-2/+6
2016-05-23Make the Default docs more like the other traitsCarol (Nichols || Goulding)-3/+26
Add explicit "Derivable" and "How can I implement `Default`" sections. Copied relevant sections from the module-level documentation, but also linked to there-- it has a more comprehensive narrative with examples that show implementation AND use. Decided to just put implementation example in the trait documentation.
2016-05-23Add an explicit "How can I implement `PartialOrd`" doc sectionCarol (Nichols || Goulding)-2/+44
Similar to the `Ord` examples but calling out that it can be defined using `cmp` from `Ord` or using `partial_cmp` in a situation that demands that.
2016-05-23Add an explicit "How can I implement `Ord`" doc sectionCarol (Nichols || Goulding)-0/+40
References: - http://stackoverflow.com/q/29884402/51683 - http://stackoverflow.com/q/28387711/51683
2016-05-23Add more information about implementing `Hash`Carol (Nichols || Goulding)-0/+24
A bit of duplication from the module documentation, but simplified to be closer to being trivially copy-paste-able.
2016-05-23Add more detail to `Clone`'s documentationCarol (Nichols || Goulding)-1/+25
Used as resources: - https://users.rust-lang.org/t/whats-the-difference-between-trait-copy-and-clone/2609/2?u=carols10cents
2016-05-23Add an explicit "How can I implement `Eq`" doc sectionCarol (Nichols || Goulding)-1/+24
Building on the example in PartialEq.
2016-05-23Add an explicit "How can I implement `PartialEq`"? doc sectionCarol (Nichols || Goulding)-4/+31
Including an example of a custom implementation. I put this expanded section after the `Derivable` section to encourage use of that first.
2016-05-23Reorder `Copy` doc sectionsCarol (Nichols || Goulding)-20/+20
The new order puts all the "when" questions together and puts the "how" question with the "derivable" section. So you have to scroll past (and hopefully read) the can/cannot/should caveats and guidelines to get to the information about how to actually go about doing it once you've determined that you can and should, with derivable information first so that you can just use the derived implementation if that applies. Previous order: * General explanation * When can my type be `Copy`? * How can I implement `Copy`? * When can my type _not_ be `Copy`? * When should my type be `Copy`? * Derivable New order: * General explanation * When can my type be `Copy`? * When can my type _not_ be `Copy`? * When should my type be `Copy`? * Derivable * How can I implement `Copy`?
2016-05-23Make `Derivable` header be an h2 instead of an h1Carol (Nichols || Goulding)-1/+1
This matches the other subsections.
2016-05-23`derive` explanation for PartialOrd should match that for OrdCarol (Nichols || Goulding)-2/+2
I think these just got out of sync, but both use a lexicographic ordering. Relevant commits in the history of these explanations: * 8b81f76 on 2015-06-30 * e22770b on 2016-02-09
2016-05-23Add explanations about what derived trait implementations doCarol (Nichols || Goulding)-6/+19
2016-05-20Rollup merge of #33683 - sanxiyn:paren-span, r=nikomatsakisGuillaume Gomez-1/+1
Preserve span when lowering ExprKind::Paren Fix #33681.
2016-05-20Rollup merge of #33668 - dns2utf8:catch_thread, r=steveklabnikGuillaume Gomez-3/+8
Catch thread in example Since this is an example, the code will be copied by many people and should be over correct. ?r @steveklabnik
2016-05-19Auto merge of #33103 - ranma42:escape-unicode-last, r=alexcrichtonbors-0/+12
Implement `last` for `EscapeUnicode` The implementation is quite trivial as the last character is always `'{'`. As a side-effect it also improves the implementation of `last` for `EscapeUnicode`. Part of #24214, split from #31049. Maybe this (and the other changes that I will split from #31049) should wait for a test like `ed_iterator_specializations` to be added. Would it be sufficient to do the same for each possible escape length?
2016-05-19Catch thread in exampleStefan Schindler-3/+8
- Consume result of thread join() - Add link to threading model
2016-05-19Support 16-bit pointers as well as i/usizeJake Goulding-0/+46
This is based on the original work of Dylan McKay for the [avr-rust project][ar]. [ar]: https://github.com/avr-rust/rust
2016-05-18address review commentsAriel Ben-Yehuda-12/+12
2016-05-18implement fuzzy matching in on_unimplementedAriel Ben-Yehuda-5/+12
2016-05-18Remove unnecessary parens in macroSeo Sanghyeon-1/+1
2016-05-16Auto merge of #33429 - ranma42:fix-x87-parsing, r=alexcrichtonbors-10/+81
Fix fast path of float parsing on x87 The fast path of the float parser relies on the rounding to happen exactly and directly to the correct number of bits. On x87, instead, double rounding would occour as the FPU stack defaults to 80 bits of precision. This can be fixed by setting the precision of the FPU stack before performing the int to float conversion. This can be achieved by changing the value of the x87 control word. This is a somewhat common operation that is in fact performed whenever a float needs to be truncated to an integer, but it is undesirable to add its overhead for code that does not rely on x87 for computations (i.e. on non-x86 architectures, or x86 architectures which perform FPU computations on using SSE). Fixes `num::dec2flt::fast_path_correct` (on x87).
2016-05-16core::intrinsics: fix typo noted during review.Felix S. Klock II-1/+1
2016-05-16Fix `asm!` blocksAndrea Canciani-2/+2
The `volatile` modifier was incorrectly written outside of the `asm!` blocks.
2016-05-16Cleanup documentationAndrea Canciani-31/+10
Remove irrelevant information (and instead provide pointer to reference documentation), replace ASCII-art table with the corresponding MarkDown one, and minor fixes.
2016-05-16Adding magic `rustc_peek` intrinsic that other code can repurpose toFelix S. Klock II-0/+10
its own needs based on attributes attached to the function where it appears.
2016-05-15Rollup merge of #33534 - dns2utf8:atomic_docs, r=GuillaumeGomezManish Goregaokar-2/+2
Simplify text This way it should be clear: Any number of other threads have this guaranty not just one other thread.
2016-05-14Auto merge of #33579 - Amanieu:atomic_bool2, r=alexcrichtonbors-58/+36
Make AtomicBool the same size as bool Reopening #32365 This allows `AtomicBool` to be transmuted to a `bool`, which makes it more consistent with the other atomic types. Note that this now guarantees that the atomic type will always contain a valid `bool` value, which wasn't the case before (due to `fetch_nand`). r? @alexcrichton
2016-05-13Make AtomicBool the same size as boolAmanieu d'Antras-58/+36
2016-05-13Document the x87 control wordAndrea Canciani-5/+62
Explain the meaning of the fields of the control word and provide more details about how the relevant one (Precision Control) is updated in the fast path.