about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
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
2020-04-02Auto merge of #70362 - TimDiekmann:alloc-overhaul, r=Amanieubors-42/+74
Overhaul of the `AllocRef` trait to match allocator-wg's latest consens; Take 2 GitHub won't let me reopen #69889 so I make a new PR. In addition to #69889 this fixes the unsoundness of `RawVec::into_box` when using allocators supporting overallocating. Also it uses `MemoryBlock` in `AllocRef` to unify `_in_place` methods by passing `&mut MemoryBlock`. Additionally, `RawVec` now checks for `size_of::<T>()` again and ignore every ZST. The internal capacity of `RawVec` isn't used by ZSTs anymore, as `into_box` now requires a length to be specified. r? @Amanieu fixes rust-lang/wg-allocators#38 fixes rust-lang/wg-allocators#41 fixes rust-lang/wg-allocators#44 fixes rust-lang/wg-allocators#51
2020-04-02Use Self over specific type in return positionLzu Tao-7/+7
2020-04-01In Thread::new, add a comment that a panic could cause a memory leak.Vytautas Astrauskas-5/+14
2020-04-01Fix link to write_vectoredThomas de Zeeuw-1/+1
2020-04-01Use unspecified over undefined in io::Write::write_all_vectored docsThomas de Zeeuw-7/+9
2020-03-31Use Box::into_raw instead of ManuallyDrop in Thread::new.Vytautas Astrauskas-36/+20
2020-04-01Rollup merge of #70081 - lcnr:issue68387, r=varkorDylan DPC-3/+2
add `unused_braces` lint Add the lint `unused_braces` which is warn by default. `unused_parens` is also extended and now checks anon consts. closes #68387 r? @varkor
2020-03-31Inline start_thread into its callers.Vytautas Astrauskas-26/+30
2020-03-31Fix double-free and undefined behaviour in libstd::syn::unix::Thread::new.Vytautas Astrauskas-18/+43
2020-03-31Add io::Write::write_all_vectoredThomas de Zeeuw-1/+161
Similar to io::Write::write_all but uses io::Write::write_vectored instead.
2020-03-31fix internal lint falloutBastian Kauschke-3/+2
2020-03-31Rollup merge of #70613 - matthiaskrgr:cl5ppy_squashed, r=CentrilMazdak Farrokhzad-3/+3
more clippy fixes * use is_empty() instead of len comparison (clippy::len_zero) * use if let instead of while let loop that never loops (clippy::never_loop) * remove redundant returns (clippy::needless_return) * remove redundant closures (clippy::redundant_closure) * use if let instead of match and wildcard pattern (clippy::single_match) * don't repeat field names redundantly (clippy::redundant_field_names) r? @Centril
2020-03-31more clippy fixesMatthias Krüger-3/+3
use is_empty() instead of len comparison (clippy::len_zero) use if let instead of while let loop that never loops (clippy::never_loop) remove redundant returns (clippy::needless_return) remove redundant closures (clippy::redundant_closure) use if let instead of match and wildcard pattern (clippy::single_match) don't repeat field names redundantly (clippy::redundant_field_names)
2020-03-30std: Fix over-aligned allocations on wasm32-wasiAlex Crichton-1/+1
The wasm32-wasi target delegates its malloc implementation to the functions in wasi-libc, but the invocation of `aligned_alloc` was incorrect by passing the number of bytes requested first rather than the alignment. This commit swaps the order of these two arguments to ensure that we allocate over-aligned memory correctly.
2020-03-30Rollup merge of #70479 - RalfJung:win-env, r=Mark-SimulacrumDylan DPC-1/+1
avoid creating unnecessary reference in Windows Env iterator Discovered in https://github.com/rust-lang/miri/pull/1225: the Windows `Env` iterator violates Stacked Borrows by creating an `&u16`, turning it into a raw pointer, and then accessing memory outside the range of that type. There is no need to create a reference here in the first place, so the fix is trivial. Cc @JOE1994 Cc https://github.com/rust-lang/unsafe-code-guidelines/issues/134
2020-03-30move the definition of thread priorities to hermit-abiStefan Lankes-25/+2
2020-03-30reorder imports to pass the format checkStefan Lankes-1/+1
2020-03-30minor changes to pass the format checkStefan Lankes-2/+1