about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2017-12-04Give compile_error macro examplesHavvy-2/+2
2017-12-04Document behavior of `ptr::swap` with overlapping regions of memory.Corey Farwell-2/+40
Fixes https://github.com/rust-lang/rust/issues/44479.
2017-12-03Rollup merge of #46473 - frewsxcv:frewsxcv-param-name, r=TimNNCorey Farwell-69/+69
Consistent parameter name for numeric ‘checked’ operations. Some checked operations use `rhs` as a parameter name, and some use `other`. For the sake of consistency, unify everything under the `rhs` name. Fixes https://github.com/rust-lang/rust/issues/46308.
2017-12-03Rollup merge of #46260 - ExpHP:builtin-macro-doc-sync, r=steveklabnikCorey Farwell-6/+14
Make doc stubs for builtin macros reflect existing support for trailing commas This modifies the `macro_rules!` stubs in `std` for some of the compiler builtin macros in order to better reflect their currently supported grammar. To my understanding these stubs have no impact on compiler output whatsoever, and only exist so that they may appear in the documentation. P.S. It is in fact true that `env!` supports trailing commas while `option_env!` currently does not. (I have another issue for this) I don't imagine there's any way to automatically test these stubs, but I did *informally* test the new definitions on the playpen to see that they accept the desired invocations, as well as inspect the updated doc output.
2017-12-03Consistent parameter name for numeric ‘checked’ operations.Corey Farwell-69/+69
Some checked operations use `rhs` as a parameter name, and some use `other`. For the sake of consistency, unify everything under the `rhs` name. Fixes https://github.com/rust-lang/rust/issues/46308.
2017-12-02Mark ascii methods on primitive types stable in 1.23.0.Ralph Giles-6/+6
The ascii_methods_on_intrinsics feature stabilization didn't land in time for 1.21.0. Update the annotation so the documentation is correct about when these methods became available.
2017-12-01doc: macro `cfg!` evaluating at compile-timeLiigo Zhuang-1/+1
2017-11-29Update bootstrap compilerAlex Crichton-2/+1
Also remove a number of `stage0` annotations and such
2017-11-29Rollup merge of #46356 - daboross:patch-2, r=sfacklerkennytm-1/+1
Reject '2' as a binary digit in internals of b: number formatting The `radix!` macro generates an implementation of the private trait `GenericRadix`, and the code replaced changes Binary's implementation to no longer accept '2' as a valid digit to print. Granted, this code is literally only ever called from another method in this private trait, and that method has logic to never hand a '2' to the printing function. Even given this, the code's there, I thought it would be best to fix this for clarity of anyone reading it.
2017-11-29Rollup merge of #46293 - ollie27:atomic_bool_from, r=BurntSushikennytm-0/+7
impl From<bool> for AtomicBool This seems like an obvious omission from #45610. ~~I've used the same feature name and version in the hope that this can be backported to beta so it's stabilized with the other impls. If it can't be I'll change it to `1.24.0`.~~
2017-11-29Rollup merge of #46287 - SimonSapin:stable-constness, r=aturonkennytm-66/+1
Stabilize const-calling existing const-fns in std Fixes #46038
2017-11-29Rollup merge of #46077 - LukasKalbertodt:stabilize-ascii-ctype, r=alexcrichtonkennytm-10/+10
Stabilize some `ascii_ctype` methods As discussed in #39658, this PR stabilizes those methods for `u8` and `char`. All inherent `ascii_ctype` for `[u8]` and `str` are removed as we prefer the more explicit version `s.chars().all(|c| c.is_ascii_())`. This PR doesn't modify the `AsciiExt` trait. There, the `ascii_ctype` methods are still unstable. It is planned to remove those in the future (I think). I had to modify some code in `ascii.rs` to properly implement `AsciiExt` for all types. Fixes #39658.
2017-11-28Reject '2' as a binary digit in internals of 'b' formattingDavid Ross-1/+1
I don't believe the previous code `0 ... 2` would run into any real problems, but it seems confusing to read, given that '2' is never a valid binary digit. As far as I can tell this code is only ever called from within another private method in the trait which has logic to never hand it '2' anyways. I thought we could change this for clarity anyways.
2017-11-28Auto merge of #46094 - dtolnay:is_null, r=alexcrichtonbors-15/+55
Remove `T: Sized` on `ptr::is_null()` Originally from #44932 -- this is purely a revert of the last commit of that PR, which was removing some changes from the previous commits in the PR. So a revert of a revert means this is code written by @cuviper! @mikeyhew makes a compelling case in https://github.com/rust-lang/rfcs/issues/433#issuecomment-345495505 for why this is the right way to implement `is_null` for trait objects. And the behavior for slices makes sense to me as well. ```diff impl<T: ?Sized> *const T { - pub fn is_null(self) -> bool where T: Sized; + pub fn is_null(self) -> bool; } impl<T: ?Sized> *mut T { - pub fn is_null(self) -> bool where T: Sized; + pub fn is_null(self) -> bool; }
2017-11-28Change `since` attribute from ctype methods from 1.23 to 1.24Lukas Kalbertodt-10/+10
The changes didn't land in time for 1.23 and stabilizations won't be backported to beta.
2017-11-27Change version number for `impl From<bool> for AtomicBool` to 1.24.0Oliver Middleton-1/+1
2017-11-28Rollup merge of #46285 - SimonSapin:twos-complement, r=GuillaumeGomezkennytm-0/+20
Document non-obvious behavior of fmt::UpperHex & co for negative integers Before stabilization I’d have suggested changing the behavior, but that time is past.
2017-11-28Rollup merge of #46240 - SimonSapin:from_str_radix-docs, r=estebankkennytm-0/+18
Expand docs of <$Int>::from_str_radix, based on that of char::to_digit
2017-11-28Rollup merge of #46174 - stjepang:stabilize-spinloophint, r=sfacklerkennytm-3/+2
Stabilize spin_loop_hint Stabilize `spin_loop_hint` in release `1.23.0`. I've also renamed feature `hint_core_should_pause` to `spin_loop_hint`. cc #41196
2017-11-27Change the stabilization version to 1.24.0Stjepan Glavina-1/+1
2017-11-27Keep access to private Formatter fields in Formatter methodsSimon Sapin-43/+49
2017-11-27Auto merge of #46284 - SimonSapin:deprecate-formatter-flags, r=sfacklerbors-0/+3
Deprecate the Formatter::flags method, fix #46237 This fixes #46237.
2017-11-27impl From<bool> for AtomicBoolOliver Middleton-0/+7
2017-11-26Update libcore macro stubs like libstdMichael Lamparski-6/+14
2017-11-26Stabilize const-calling existing const-fns in stdSimon Sapin-66/+1
Fixes #46038
2017-11-26Document non-obvious behavior of fmt::UpperHex & co for negative integersSimon Sapin-0/+20
Before stabilization I’d have suggested changing the behavior, but that time is past.
2017-11-26Deprecate the Formatter::flags method, fix #46237Simon Sapin-0/+3
2017-11-26Rollup merge of #46234 - lucasem:core-marker-typo, r=frewsxcvkennytm-1/+1
core::marker fix typo
2017-11-25rustc: Add support for some more x86 SIMD opsAlex Crichton-0/+5
This commit adds compiler support for two basic operations needed for binding SIMD on x86 platforms: * First, a `nontemporal_store` intrinsic was added for the `_mm_stream_ps`, seen in rust-lang-nursery/stdsimd#114. This was relatively straightforward and is quite similar to the volatile store intrinsic. * Next, and much more intrusively, a new type to the backend was added. The `x86_mmx` type is used in LLVM for a 64-bit vector register and is used in various intrinsics like `_mm_abs_pi8` as seen in rust-lang-nursery/stdsimd#74. This new type was added as a new layout option as well as having support added to the trans backend. The type is enabled with the `#[repr(x86_mmx)]` attribute which is intended to just be an implementation detail of SIMD in Rust. I'm not 100% certain about how the `x86_mmx` type was added, so any extra eyes or thoughts on that would be greatly appreciated!
2017-11-24Expand docs of <$Int>::from_str_radix, based on that of char::to_digitSimon Sapin-0/+18
2017-11-24Make fmt::DebugList and friends forward formatting parametersSimon Sapin-28/+113
For example, formatting slice of integers with `{:04?}` should zero-pad each integer.
2017-11-24core::marker fix typoLucas Morales-1/+1
2017-11-22Auto merge of #45198 - oli-obk:fmt_args, r=sfacklerbors-0/+8
Prevent fmt::Arguments from being shared across threads Fixes #45197 This is a **breaking change**! Without doing this it's very easy to create race conditions. There's probably a way to do this without breaking valid use cases, but it would require quite an overhaul of the formatting machinery.
2017-11-22Stabilize spin_loop_hintStjepan Glavina-3/+2
2017-11-21fix some typosMartin Lindhe-1/+1
2017-11-21Document the size of boolSimon Sapin-0/+1
2017-11-21Auto merge of #45039 - QuietMisdreavus:doc-spotlight, ↵bors-0/+19
r=GuillaumeGomez,QuietMisdreavus show in docs whether the return type of a function impls Iterator/Read/Write Closes #25928 This PR makes it so that when rustdoc documents a function, it checks the return type to see whether it implements a handful of specific traits. If so, it will print the impl and any associated types. Rather than doing this via a whitelist within rustdoc, i chose to do this by a new `#[doc]` attribute parameter, so things like `Future` could tap into this if desired. ### Known shortcomings ~~The printing of impls currently uses the `where` class over the whole thing to shrink the font size relative to the function definition itself. Naturally, when the impl has a where clause of its own, it gets shrunken even further:~~ (This is no longer a problem because the design changed and rendered this concern moot.) The lookup currently just looks at the top-level type, not looking inside things like Result or Option, which renders the spotlights on Read/Write a little less useful: <details><summary>`File::{open, create}` don't have spotlight info (pic of old design)</summary> ![image](https://user-images.githubusercontent.com/5217170/31209495-e59d027e-a950-11e7-9998-ceefceb71c07.png) </details> All three of the initially spotlighted traits are generically implemented on `&mut` references. Rustdoc currently treats a `&mut T` reference-to-a-generic as an impl on the reference primitive itself. `&mut Self` counts as a generic in the eyes of rustdoc. All this combines to create this lovely scene on `Iterator::by_ref`: <details><summary>`Iterator::by_ref` spotlights Iterator, Read, and Write (pic of old design)</summary> ![image](https://user-images.githubusercontent.com/5217170/31209554-50b271ca-a951-11e7-928b-4f83416c8681.png) </details>
2017-11-20Auto merge of #46130 - kennytm:rollup, r=kennytmbors-1/+1
Rollup of 9 pull requests - Successful merges: #46082, #46088, #46092, #46107, #46119, #46121, #46122, #46124, #46128 - Failed merges:
2017-11-20Fix some docs summary nitsMarco A L Barbosa-1/+1
2017-11-20Update books for next releasesteveklabnik-1/+1
Also includes a fix in std::ops
2017-11-20Auto merge of #45905 - alexcrichton:add-wasm-target, r=aturonbors-205/+1
std: Add a new wasm32-unknown-unknown target This commit adds a new target to the compiler: wasm32-unknown-unknown. This target is a reimagining of what it looks like to generate WebAssembly code from Rust. Instead of using Emscripten which can bring with it a weighty runtime this instead is a target which uses only the LLVM backend for WebAssembly and a "custom linker" for now which will hopefully one day be direct calls to lld. Notable features of this target include: * There is zero runtime footprint. The target assumes nothing exists other than the wasm32 instruction set. * There is zero toolchain footprint beyond adding the target. No custom linker is needed, rustc contains everything. * Very small wasm modules can be generated directly from Rust code using this target. * Most of the standard library is stubbed out to return an error, but anything related to allocation works (aka `HashMap`, `Vec`, etc). * Naturally, any `#[no_std]` crate should be 100% compatible with this new target. This target is currently somewhat janky due to how linking works. The "linking" is currently unconditional whole program LTO (aka LLVM is being used as a linker). Naturally that means compiling programs is pretty slow! Eventually though this target should have a linker. This target is also intended to be quite experimental. I'm hoping that this can act as a catalyst for further experimentation in Rust with WebAssembly. Breaking changes are very likely to land to this target, so it's not recommended to rely on it in any critical capacity yet. We'll let you know when it's "production ready". ### Building yourself First you'll need to configure the build of LLVM and enable this target ``` $ ./configure --target=wasm32-unknown-unknown --set llvm.experimental-targets=WebAssembly ``` Next you'll want to remove any previously compiled LLVM as it needs to be rebuilt with WebAssembly support. You can do that with: ``` $ rm -rf build ``` And then you're good to go! A `./x.py build` should give you a rustc with the appropriate libstd target. ### Test support Currently testing-wise this target is looking pretty good but isn't complete. I've got almost the entire `run-pass` test suite working with this target (lots of tests ignored, but many passing as well). The `core` test suite is [still getting LLVM bugs fixed](https://reviews.llvm.org/D39866) to get that working and will take some time. Relatively simple programs all seem to work though! In general I've only tested this with a local fork that makes use of LLVM 5 rather than our current LLVM 4 on master. The LLVM 4 WebAssembly backend AFAIK isn't broken per se but is likely missing bug fixes available on LLVM 5. I'm hoping though that we can decouple the LLVM 5 upgrade and adding this wasm target! ### But the modules generated are huge! It's worth nothing that you may not immediately see the "smallest possible wasm module" for the input you feed to rustc. For various reasons it's very difficult to get rid of the final "bloat" in vanilla rustc (again, a real linker should fix all this). For now what you'll have to do is: cargo install --git https://github.com/alexcrichton/wasm-gc wasm-gc foo.wasm bar.wasm And then `bar.wasm` should be the smallest we can get it! --- In any case for now I'd love feedback on this, particularly on the various integration points if you've got better ideas of how to approach them!
2017-11-20Auto merge of #45819 - Havvy:cell, r=aturonbors-13/+38
Add RefCell<T>::replace_with I also moved the `Panic` sections to before examples in the other two functions also under this feature gate, and changed the variable names in `replace` to be more readable. r? @rust-libs
2017-11-19std: Add a new wasm32-unknown-unknown targetAlex Crichton-205/+1
This commit adds a new target to the compiler: wasm32-unknown-unknown. This target is a reimagining of what it looks like to generate WebAssembly code from Rust. Instead of using Emscripten which can bring with it a weighty runtime this instead is a target which uses only the LLVM backend for WebAssembly and a "custom linker" for now which will hopefully one day be direct calls to lld. Notable features of this target include: * There is zero runtime footprint. The target assumes nothing exists other than the wasm32 instruction set. * There is zero toolchain footprint beyond adding the target. No custom linker is needed, rustc contains everything. * Very small wasm modules can be generated directly from Rust code using this target. * Most of the standard library is stubbed out to return an error, but anything related to allocation works (aka `HashMap`, `Vec`, etc). * Naturally, any `#[no_std]` crate should be 100% compatible with this new target. This target is currently somewhat janky due to how linking works. The "linking" is currently unconditional whole program LTO (aka LLVM is being used as a linker). Naturally that means compiling programs is pretty slow! Eventually though this target should have a linker. This target is also intended to be quite experimental. I'm hoping that this can act as a catalyst for further experimentation in Rust with WebAssembly. Breaking changes are very likely to land to this target, so it's not recommended to rely on it in any critical capacity yet. We'll let you know when it's "production ready". --- Currently testing-wise this target is looking pretty good but isn't complete. I've got almost the entire `run-pass` test suite working with this target (lots of tests ignored, but many passing as well). The `core` test suite is still getting LLVM bugs fixed to get that working and will take some time. Relatively simple programs all seem to work though! --- It's worth nothing that you may not immediately see the "smallest possible wasm module" for the input you feed to rustc. For various reasons it's very difficult to get rid of the final "bloat" in vanilla rustc (again, a real linker should fix all this). For now what you'll have to do is: cargo install --git https://github.com/alexcrichton/wasm-gc wasm-gc foo.wasm bar.wasm And then `bar.wasm` should be the smallest we can get it! --- In any case for now I'd love feedback on this, particularly on the various integration points if you've got better ideas of how to approach them!
2017-11-19Remove `T: Sized` on `ptr::is_null()`Josh Stone-15/+55
This reverts commit 604f049cd5060129cf14f7bd340d442811345ea8. This is purely a revert of cuviper's revert "Restore `T: Sized` on `ptr::is_null`". So double revert means this is code written by cuviper!
2017-11-18Stabilize `ascii_ctype` methods for `u8` and `char`Lukas Kalbertodt-10/+10
The feature of those methods was renamed to "ascii_ctype_on_intrinsics".
2017-11-18Undo the Sized specialization from Iterator::nthScott McMurray-26/+6
2017-11-17add doc_highlight feature flag and testsQuietMisdreavus-0/+18
2017-11-17spotlight Iterator/Read/Write impls on function return typesQuietMisdreavus-0/+1
2017-11-17Auto merge of #45595 - scottmcm:iter-try-fold, r=dtolnaybors-182/+929
Short-circuiting internal iteration with Iterator::try_fold & try_rfold These are the core methods in terms of which the other methods (`fold`, `all`, `any`, `find`, `position`, `nth`, ...) can be implemented, allowing Iterator implementors to get the full goodness of internal iteration by only overriding one method (per direction). Based off the `Try` trait, so works with both `Result` and `Option` (:tada: https://github.com/rust-lang/rust/pull/42526). The `try_fold` rustdoc examples use `Option` and the `try_rfold` ones use `Result`. AKA continuing in the vein of PRs https://github.com/rust-lang/rust/pull/44682 & https://github.com/rust-lang/rust/pull/44856 for more of `Iterator`. New bench following the pattern from the latter of those: ``` test iter::bench_take_while_chain_ref_sum ... bench: 1,130,843 ns/iter (+/- 25,110) test iter::bench_take_while_chain_sum ... bench: 362,530 ns/iter (+/- 391) ``` I also ran the benches without the `fold` & `rfold` overrides to test their new default impls, with basically no change. I left them there, though, to take advantage of existing overrides and because `AlwaysOk` has some sub-optimality due to https://github.com/rust-lang/rust/issues/43278 (which 45225 should fix). If you're wondering why there are three type parameters, see issue https://github.com/rust-lang/rust/issues/45462 Thanks for @bluss for the [original IRLO thread](https://internals.rust-lang.org/t/pre-rfc-fold-ok-is-composable-internal-iteration/4434) and the rfold PR and to @cuviper for adding so many folds, [encouraging me](https://github.com/rust-lang/rust/pull/45379#issuecomment-339424670) to make this PR, and finding a catastrophic bug in a pre-review.
2017-11-14Rollup merge of #45977 - kennytm:fix-pulldown-warnings, r=steveklabnikGuillaume Gomez-1/+1
Fixed several pulldown warnings when documenting libstd.