summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2020-04-20Rollup merge of #71328 - Mark-Simulacrum:stabilize-pathbuf-capacity, r=sfacklerDylan DPC-8/+7
Stabilize PathBuf capacity methods Closes https://github.com/rust-lang/rust/issues/58234. Stabilization FCP finished in https://github.com/rust-lang/rust/issues/58234#issuecomment-616048777.
2020-04-20Auto merge of #71007 - Amanieu:deprecate_asm, r=Mark-Simulacrumbors-0/+2
Deprecate the asm! macro in favor of llvm_asm! Since we will be changing the syntax of `asm!` soon, deprecate it and encourage people to use `llvm_asm!` instead (which preserves the old syntax). This will avoid breakage when `asm!` is changed. RFC: https://github.com/rust-lang/rfcs/pull/2843
2020-04-19Stabilize PathBuf capacity methodsMark Rousskov-8/+7
2020-04-17Rollup merge of #71167 - RalfJung:big-o, r=shepmasterDylan DPC-6/+6
big-O notation: parenthesis for function calls, explicit multiplication I saw `O(n m log n)` in the docs and found that really hard to parse. In particular, I don't think we should use blank space as syntax for *both* multiplication and function calls, that is just confusing. This PR makes both multiplication and function calls explicit using Rust-like syntax. If you prefer, I can also leave one of them implicit, but I believe explicit is better here. While I was at it I also added backticks consistently.
2020-04-16Dogfood or_patterns in the standard libraryJosh Stone-2/+3
2020-04-15Deprecate the asm! macroAmanieu d'Antras-0/+2
2020-04-15big-O notation: parenthesis, multiplication and backticksRalf Jung-6/+6
2020-04-15Use fcntl() to set nonblock for solarish socketsPatrick Mooney-0/+8
The ioctl(FIONBIO) method of setting a file descriptor to be non-blocking does not notify the underlying resource in the same way that fcntl(F_SETFL, O_NONBLOCK) does on illumos and Solaris.
2020-04-14Add illumos triplePatrick Mooney-16/+275
Co-Authored-By: Jason King <jason.brian.king@gmail.com> Co-Authored-By: Joshua M. Clulow <jmc@oxide.computer>
2020-04-14Add missing commaYoungsuk Kim-1/+1
2020-04-12Rollup merge of #71029 - Mark-Simulacrum:cargo-build, r=Mark-SimulacrumDylan DPC-1/+1
Partial work on building with Cargo This cherry picks the commits I'm directly approving from #70999, I want to land them so that that PR is smaller.
2020-04-11Make panic-unwind a default feature for libstdLuca Barbieri-1/+1
x.py sets it unconditionally, so want it for plain "cargo build". We need to load one of the panic runtimes that is in src (vs. pre-built in the compiler's sysroot) to ensure that we don't load libpanic_unwind from the sysroot. That would lead to a load of libcore, also from the sysroot, and create lots of errors about duplicate lang items.
2020-04-11Change issue number to point to tracking issueChai T. Rex-1/+1
2020-04-10Fixed doc tests for added methodsChai T. Rex-0/+1
2020-04-10Add or_insert_with_key to Entry of HashMap/BTreeMapChai T. Rex-0/+27
Going along with or_insert_with, or_insert_with_key provides the Entry's key to the lambda, avoiding the need to either clone the key or the need to reimplement this body of this method from scratch each time. This is useful when the initial value for a map entry is derived from the key. For example, the introductory Rust book has an example Cacher struct that takes an expensive-to-compute lambda and then can, given an argument to the lambda, produce either the cached result or execute the lambda.
2020-04-09Rollup merge of #67705 - lzutao:wmemchr, r=wesleywiserMazdak Farrokhzad-2/+46
Use unrolled loop for searching NULL in [u16] on Windows
2020-04-08Rollup merge of #70565 - Zoxc:inlines-query-system, r=davidtwcoDylan DPC-0/+1
Add inline attributes for functions used in the query system
2020-04-08Rollup merge of #70134 - hermitcore:osstrext, r=dtolnayDylan DPC-1/+54
add basic support of OsStrExt for HermitCore - this patch increases the compatibility to other operating systems - in principle `ffi.rs` is derived from `src/libstd/sys/unix/ext/ffi.rs`
2020-04-07Rollup merge of #70857 - faern:use-assoc-int-float-consts, r=dtolnayDylan DPC-1/+0
Don't import integer and float modules, use assoc consts 2 Follow up to #70777. I missed quite a lot of places. Partially because I wanted to keep the size of the last PR down, and partially because my regexes were not good enough :) r? @dtolnay
2020-04-07Rollup merge of #70201 - cuviper:clone_into, r=dtolnayDylan DPC-2/+30
Small tweaks in ToOwned::clone_into - `<[T]>::clone_into` is slightly more optimized. - `CStr::clone_into` is new, letting it reuse its allocation. - `OsStr::clone_into` now forwards to the underlying slice/`Vec`.
2020-04-06Forward OsStr::clone_into to the inner VecJosh Stone-2/+13
Despite OS differences, they're all just `Vec<u8>` inside, so we can just forward `clone_into` calls to that optimized implementation.
2020-04-06Implement ToOwned::clone_into for CStrJosh Stone-0/+17
It can try to keep its allocation by converting the inner `Box` to `Vec`, using `clone_into` on the bytes, then convert back to `Box`.
2020-04-07Rollup merge of #70612 - Thomasdezeeuw:issue_70436, r=LukasKalbertodtDylan DPC-1/+169
Add io::Write::write_all_vectored Similar to io::Write::write_all but uses io::Write::write_vectored instead. Updates #70436 /cc @cramertj @sfackler
2020-04-07Put reference to write_vectored in quotes in docThomas de Zeeuw-1/+1
2020-04-06Don't import integer module in libstdLinus Färnstrand-1/+0
2020-04-06Improve io::Write::write_all_vectored docsThomas de Zeeuw-11/+17
Also adds some more tests with different length IoSlices.
2020-04-06Rollup merge of #70824 - yoshuawuyts:fix-labels-in-std-macro-imports, ↵Mazdak Farrokhzad-14/+2
r=Mark-Simulacrum Remove marker comments in libstd/lib.rs macro imports These comments were probably moved around when rustfmt was introduced. They don't correctly denote what they were intended for, so I propose we remove them instead. Thanks!
2020-04-06Rollup merge of #70808 - hermitcore:tls, r=dtolnayMazdak Farrokhzad-44/+48
Simplify dtor registration for HermitCore by using a list of destructors The implementation is similar to the macOS version and doesn't depend on additional OS support
2020-04-06Rollup merge of #70782 - faern:use-assoc-float-consts, r=dtolnayMazdak Farrokhzad-126/+30
Stop importing the float modules in documentation Follow up to #69860. I realized I had not searched for and fixed this for the float values. So with this PR they also use the associated constants instead of the module level constants. For the documentation where it also was using the `consts` submodule I opted to change it to import that directly. This becomes more in line with how other docs that use the `consts` submodule looks. And it also makes it so there are not two `f32` or `f64` things in the current namespace (both the module and the primitive type) and then hopefully confusing documentation readers less. r? @dtolnay
2020-04-06Rollup merge of #70553 - hermitcore:abi, r=dtolnayMazdak Farrokhzad-34/+4
move OS constants to platform crate to reduce platform specific constants move O_RDONLY etc. and the definition of thread priorities to hermit-abi
2020-04-05Remove labels in libstd/lib.rs macro importsYoshua Wuyts-14/+2
These labels were probably moved around when rustfmt was introduced.
2020-04-05Rollup merge of #70812 - rossmacarthur:fix/unit-called-nil, r=LukasKalbertodtDylan DPC-1/+1
Do not use "nil" to refer to `()` "nil" is not used in the [book](https://doc.rust-lang.org/book) or in the [standard library](https://doc.rust-lang.org/std) anywhere else. Because "nil" is often used in programming languages to refer to "None" or "null" I think it could be a little confusing for newcomers to see this type referred to as "nil".
2020-04-05Do not use "nil" to refer to `()`Ross MacArthur-1/+1
2020-04-05Simplify dtor registration for HermitCore by using a list of destructorsStefan Lankes-44/+48
The implementation is similiar to macOS solution doesn't depend on additional OS support
2020-04-05Remove more std::f32 imports in libstdLinus Färnstrand-78/+30
2020-04-05Stop importing the float modules. Use assoc constsLinus Färnstrand-48/+0
2020-04-05Stop importing integer modules in libstdLinus Färnstrand-4/+0
2020-04-04Merge branch 'master' into abiStefan Lankes-87/+156
2020-04-04Auto merge of #70136 - hermitcore:network_tcp, r=dtolnaybors-87/+156
add basic IP support in HermitCore - add initial version to support sockets - use TcpStream as test case - HermitCore uses smoltcp as IP stack for pure Rust applications - further functionalities (e.g. UDP support) will be added step by step - in principle, the current PR is a revision of #69404
2020-04-04Merge branch 'master' into abiStefan Lankes-139/+152
2020-04-03Rollup merge of #70597 - vakaras:thread_new_double_free_bug_fix, r=AmanieuMazdak Farrokhzad-77/+59
Fix double-free and undefined behaviour in libstd::syn::unix::Thread::new While working on concurrency support for Miri, I found that the `libstd::syn::unix::Thread::new` method has two potential problems: double-free and undefined behaviour. **Double-free** could occur if the following events happened (credit for pointing this out goes to @RalfJung): 1. The call to `pthread_create` successfully launched a new thread that executed to completion and deallocated `p`. 2. The call to `pthread_attr_destroy` returned a non-zero value causing the `assert_eq!` to panic. 3. Since `mem::forget(p)` was not yet executed, the destructor of `p` would be executed and cause a double-free. As far as I understand, this code also violates the stacked-borrows aliasing rules and thus would result in **undefined behaviour** if these rules were adopted. The problem is that the ownership of `p` is passed to the newly created thread before the call to `mem::forget`. Since the call to `mem::forget` is still a call, it counts as a use of `p` and triggers UB. This pull request changes the code to use `mem::ManuallyDrop` instead of `mem::forget`. As a consequence, in case of a panic, `p` would be potentially leaked, which while undesirable is probably better than double-free or undefined behaviour.
2020-04-03Rollup merge of #69860 - faern:use-assoc-int-consts, r=dtolnayMazdak Farrokhzad-4/+4
Use associated numeric consts in documentation Now when the associated constants on int/float types are stabilized and the recommended way of accessing said constants (#68952). We can start using it in this repository, and recommend it via documentation example code. This PR is the reincarnation of #67913 minus the actual adding + stabilization of said constants. (EDIT: Now it's only changing the documentation. So users will see the new consts, but we don't yet update the internal code) Because of how fast bit rot happens to PRs that touch this many files, it does not try to replace 100% of the old usage of the constants in the entire repo, but a good chunk of them.
2020-04-03Delete unnecessary stub stack overflow handler for cloudabi.Vytautas Astrauskas-13/+1
2020-04-03Delete unnecessary stub stack overflow handler for hermit.Vytautas Astrauskas-12/+0
2020-04-03Minor follow-up after renaming librustc(_middle)Yuki Okushi-2/+2
2020-04-03Replace float module consts with assoc consts in documentationLinus Färnstrand-4/+4
2020-04-02Remove unnecessary stack overflow handler stub for sgx.Vytautas Astrauskas-8/+0
2020-04-03Rollup merge of #70694 - lzutao:self, r=CentrilMazdak Farrokhzad-7/+7
Use Self over specific type in return position
2020-04-02Remove unnecessary intermediate pointer cast in Thread::new.Vytautas Astrauskas-1/+1
2020-04-02Remove stack overflow handler stub for wasm.Vytautas Astrauskas-8/+0