about summary refs log tree commit diff
path: root/library
AgeCommit message (Collapse)AuthorLines
2020-08-03Rollup merge of #74974 - RalfJung:miri-tests, r=Mark-SimulacrumYuki Okushi-12/+18
Make tests faster in Miri Reduce some test iteration counts in Miri.
2020-08-03Rollup merge of #74874 - ssomers:btree_cleanup_8, r=Mark-SimulacrumYuki Okushi-8/+16
BTreeMap: define forget_type only when relevant Similar to `forget_node_type` for handles. No effect on generated code, apart maybe from the superfluous calls that might not have been optimized away. r? @Mark-Simulacrum
2020-08-03Rollup merge of #74762 - ssomers:btree_no_root_in_remove_kv_tracking, ↵Yuki Okushi-52/+405
r=Mark-Simulacrum BTreeMap::drain_filter should not touch the root during iteration Although Miri doesn't point it out, I believe there is undefined behaviour using `drain_filter` when draining the 11th-last element from a tree that was larger. When this happens, the last remaining child nodes are merged, the root becomes empty and is popped from the tree. That last step establishes a mutable reference to the node elected root and writes a pointer in `node::Root`, while iteration continues to visit the same node. This is mostly code from #74437, slightly adapted.
2020-08-03Rollup merge of #74686 - ssomers:btree_cleanup_3, r=Mark-SimulacrumYuki Okushi-10/+3
BTreeMap: remove into_slices and its unsafe block A small tweak to make BTreeMap code shorter and less unsafe. r? @Mark-Simulacrum
2020-08-02Auto merge of #74972 - second-state:wasi-right-fix, r=KodrAusbors-0/+1
Fix std::fs::File::metadata permission on WASI target Previously `std::fs::File::metadata` on wasm32-wasi would call `fd_filestat_get` to get metadata associated with fd, but that fd is opened without RIGHTS_FD_FILESTAT_GET right, so it will failed on correctly implemented WASI environment. This change instead to add the missing rights when opening an fd.
2020-08-02Auto merge of #75033 - Manishearth:rollup-d8afil1, r=Manishearthbors-3/+44
Rollup of 5 pull requests Successful merges: - #74602 (Clarify the doc for MaybeUninit::zeroed on incorrect use) - #74720 (Clean up E0728 explanation) - #74992 (fix rustdoc generic param order) - #75015 (Add Vec::spare_capacity_mut) - #75022 (Use a slice pattern instead of rchunks_exact(_).next()) Failed merges: r? @ghost
2020-08-01Rollup merge of #75015 - Amanieu:vec_spare, r=sfacklerManish Goregaokar-1/+42
Add Vec::spare_capacity_mut Returns the remaining spare capacity of the vector as a slice of `MaybeUninit<T>`. As suggested by @sfackler in https://github.com/rust-lang/rust/pull/70967#issuecomment-612659006. r? @sfackler
2020-08-01Rollup merge of #74602 - poliorcetics:maybe-uninit-zeroed-doc-clarification, ↵Manish Goregaokar-2/+2
r=jyn514 Clarify the doc for MaybeUninit::zeroed on incorrect use Fixes #74343. @rustbot modify labels: C-enhancement, T-doc
2020-08-01Auto merge of #74605 - rust-lang:vec-leak, r=Amanieubors-6/+4
Stabilize Vec::leak as a method Closes https://github.com/rust-lang/rust/issues/62195 The signature is changed to a method rather than an associated function: ```diff -pub fn leak<'a>(vec: Vec<T>) -> &'a mut [T] +pub fn leak<'a>(self) -> &'a mut [T] ``` The reason for `Box::leak` not to be a method (`Deref` to an arbitrary `T` which might have its own, different `leak` method) does not apply.
2020-08-01BTreeMap::drain_filter no longer touches the root during iterationStein Somers-30/+73
2020-08-01More benchmarks of BTreeMap mutationStein Somers-22/+332
2020-08-01Reword incorrect use of zeroed()Alexis Bourget-3/+2
2020-08-01Add Vec::spare_capacity_mutAmanieu d'Antras-1/+42
2020-08-01Define forget_type only when relevantStein Somers-8/+16
2020-08-01Auto merge of #74373 - lcnr:array_chunks, r=withoutboatsbors-5/+243
add `slice::array_chunks` to std Now that #74113 has landed, these methods are suddenly usable. A rebirth of #72334 Tests are directly copied from `chunks_exact` and some additional tests for type inference. r? @withoutboats as you are both part of t-libs and working on const generics. closes #60735
2020-08-01add tracking issueBastian Kauschke-10/+10
2020-08-01Rollup merge of #74644 - crlf0710:drop_old_stuff, r=AmanieuYuki Okushi-62/+10
Remove `linked_list_extras` methods. Removing these in favor of the `Cursor` API in https://github.com/rust-lang/rust/issues/58533 . Closes #27794. r? @Amanieu
2020-08-01Remove `linked_list_extras` methods.Charles Lew-62/+10
2020-07-31expand commentsRalf Jung-2/+2
2020-07-31also reduce some libcore test iteration countsRalf Jung-3/+4
2020-07-31reduce slice::panic_safe test size further in MiriRalf Jung-1/+1
2020-07-31make some vec_deque tests less exhaustive in MiriRalf Jung-6/+11
2020-07-31Fix std::fs::File::metadata permission on WASI targetShen-Ta Hsieh-0/+1
Previously `std::fs::File::metadata` on wasm32-wasi would call `fd_filestat_get` to get metadata associated with fd, but that fd is opened without RIGHTS_FD_FILESTAT_GET right, so it will failed on correctly implemented WASI environment. This change instead to add the missing rights when opening an fd.
2020-07-31Auto merge of #74956 - ecstatic-morse:const-option-unwrap, r=oli-obkbors-1/+3
Make `Option::unwrap` unstably const This is lumped into the `const_option` feature gate (#67441), which enables a potpourri of `Option` methods. cc @rust-lang/wg-const-eval r? @oli-obk
2020-07-31use Iter<'_, [T; N]> in array_chunksBastian Kauschke-58/+20
2020-07-31add note to array_chunksBastian Kauschke-1/+3
2020-07-31Auto merge of #74926 - Manishearth:rename-lint, r=jyn514bors-4/+0
Rename intra_doc_link_resolution_failure It should be plural to follow the conventions in https://github.com/rust-lang/rfcs/blob/master/text/0344-conventions-galore.md#lints
2020-07-30Auto merge of #74682 - alexcrichton:backtrace-gimli-round-2, r=Mark-Simulacrumbors-23/+31
std: Switch from libbacktrace to gimli (take 2) This is the second attempt to land https://github.com/rust-lang/rust/pull/73441 after being reverted in https://github.com/rust-lang/rust/pull/74613. Will be gathering precise perf numbers here in this take. Closes #71060
2020-07-30Rollup merge of #74782 - vorner:weak-into-raw-cnt-doc, r=dtolnayManish Goregaokar-20/+22
Don't use "weak count" around Weak::from_raw_ptr As `Rc/Arc::weak_count` returns 0 when having no strong counts, this could be confusing and it's better to avoid using that completely. Closes #73840.
2020-07-30Make `Option::unwrap` unstably constDylan MacKenzie-1/+3
`Result::unwrap` is not eligible becuase it formats the contents of the `Err` variant. `unwrap_or`, `unwrap_or_else` and friends are not eligible because they drop things or invoke closures.
2020-07-30Remove deny for intra doc link failures from library code, it's no longer ↵Manish Goregaokar-4/+0
necessary
2020-07-30Rename in libraryManish Goregaokar-4/+4
2020-07-30Auto merge of #74930 - ecstatic-morse:const-size-align-of-val, r=oli-obkbors-3/+9
Make `mem::size_of_val` and `mem::align_of_val` unstably const Implements #46571 but does not stabilize it. I wanted this while working on something today. The only reason not to immediately stabilize are concerns around [custom DSTs](https://github.com/rust-lang/rust/issues/46571#issuecomment-387669352). That proposal has made zero progress in the last two years and const eval is rich enough to support pretty much any user-defined `len` function as long as nightly features are allowed (`raw_ptr_deref`). Currently, this raises a `const_err` lint when passed an `extern type`. r? @oli-obk cc @rust-lang/wg-const-eval
2020-07-30liballoc export ArrayChunksBastian Kauschke-0/+3
2020-07-30add tests for array_chunksBastian Kauschke-1/+92
2020-07-30adds `slice::array_chunks`Bastian Kauschke-0/+180
2020-07-30improve chunks + windows err on size 0Bastian Kauschke-5/+5
2020-07-29Make `{align,size}_of_val` `const`Dylan MacKenzie-3/+9
2020-07-29Rollup merge of #74910 - RalfJung:fence, r=Mark-SimulacrumManish Goregaokar-1/+2
fence docs: fix example Mutex Fixes https://github.com/rust-lang/rust/issues/74808 Cc @pca006132
2020-07-29Rollup merge of #74902 - rust-lang:into_raw_non_null, r=dtolnayManish Goregaokar-91/+1
Remove deprecated unstable `{Box,Rc,Arc}::into_raw_non_null` functions FCP: https://github.com/rust-lang/rust/issues/47336#issuecomment-619369613
2020-07-29Rollup merge of #74852 - lzutao:inline-rm-tostring, r=nnethercoteManish Goregaokar-0/+3
Explain why inlining default ToString impl Trying to remove inline attribute from default ToString impl causes regression. Perf result at <https://github.com/rust-lang/rust/pull/74852#issuecomment-664812994>.
2020-07-29Rollup merge of #74819 - tmiasko:format-spec, r=joshtriplettManish Goregaokar-1/+1
Point towards `format_spec`; it is in other direction
2020-07-29Rollup merge of #74742 - poliorcetics:ip-addr-remove-rejected-errata, ↵Manish Goregaokar-4/+4
r=nikomatsakis Remove links to rejected errata 4406 for RFC 4291 Fixes #74198. For now I simply removed the links, the docs seems clear enough to me but I'm no expert in the domain so don't hesitate to correct me if more is needed. cc @ghanan94. @rustbot modify labels: T-doc, T-libs
2020-07-29Auto merge of #72488 - KodrAus:stabilize/const_type_id, r=nikomatsakisbors-3/+2
Stabilize const_type_id feature The tracking issue for `const_type_id` points to the ill-fated #41875. So I'm re-energizing `TypeId` shenanigans by opening this one up to see if there's anything blocking us from stabilizing the constification of type ids. Will wait for CI before pinging teams/groups. ----- This PR stabilizes the `const_type_id` feature, which allows `TypeId::of` (and the underlying unstable intrinsic) to be called in constant contexts. There are some [sanity tests](https://github.com/rust-lang/rust/blob/master/src/test/ui/consts/const-typeid-of-rpass.rs) that demonstrate its usage, but I’ve included some more below. As a simple example, you could create a constant item that contains some type ids: ```rust use std::any::TypeId; const TYPE_IDS: [TypeId; 2] = [ TypeId::of::<u32>(), TypeId::of::<i32>(), ]; assert_eq!(TypeId::of::<u32>(), TYPE_IDS[0]); ``` Type ids can also now appear in associated constants. You could create a trait that associates each type with its constant type id: ```rust trait Any where Self: 'static { const TYPE_ID: TypeId = TypeId::of::<Self>(); } impl<T: 'static> Any for T { } assert_eq!(TypeId::of::<usize>(), usize::TYPE_ID); ``` `TypeId::of` is generic, which we saw above in the way the generic `Self` argument was used. This has some implications for const evaluation. It means we can make trait impls evaluate differently depending on information that wasn't directly passed through the trait system. This violates the _parametricity_ property, which requires all instances of a generic function to behave the same way with respect to its generic parameters. That's not unique to `TypeId::of`, other generic const functions based on compiler intrinsics like `mem::align_of` can also violate parametricity. In practice Rust doesn't really have type parametricity anyway since it monomorphizes generics into concrete functions, so violating it using type ids isn’t new. As an example of how impls can behave differently, you could combine constant type ids with the `const_if_match` feature to dispatch calls based on the type id of the generic `Self`, rather than based on information about `Self` that was threaded through trait bounds. It's like a rough-and-ready form of specialization: ```rust #![feature(const_if_match)] trait Specialized where Self: 'static { // An associated constant that determines the function to call // at compile-time based on `TypeId::of::<Self>`. const CALL: fn(&Self) = { const USIZE: TypeId = TypeId::of::<usize>(); match TypeId::of::<Self>() { // Use a closure for `usize` that transmutes the generic `Self` to // a concrete `usize` and dispatches to `Self::usize`. USIZE => |x| Self::usize(unsafe { &*(x as *const Self as *const usize) }), // For other types, dispatch to the generic `Self::default`. _ => Self::default, } }; fn call(&self) { // Call the function we determined at compile-time (Self::CALL)(self) } fn default(x: &Self); fn usize(x: &usize); } // Implement our `Specialized` trait for any `Debug` type. impl<T: fmt::Debug + 'static> Specialized for T { fn default(x: &Self) { println!("default: {:?}", x); } fn usize(x: &usize) { println!("usize: {:?}", x); } } // Will print "usize: 42" Specialized::call(&42usize); // Will print "default: ()" Specialized::call(&()); ``` Type ids have some edges that this stabilization exposes to more contexts. It's possible for type ids to collide (but this is a bug). Since they can change between compiler versions, it's never valid to cast a type id to its underlying value.
2020-07-29fence docs: fix example MutexRalf Jung-1/+2
2020-07-29Remove deprecated unstable `{Box,Rc,Arc}::into_raw_non_null` functionsSimon Sapin-91/+1
FCP: https://github.com/rust-lang/rust/issues/47336#issuecomment-619369613
2020-07-29Stabilize `Vec::leak`Simon Sapin-3/+1
2020-07-29Make `Vec::leak` a method instead of an associated function.Simon Sapin-3/+3
The reason for `Box::leak` not to be a method (`Deref` to an arbitrary `T` which might have its own, different `leak` method) does not apply.
2020-07-29Link to syntax section when referencing itTomasz Miąsko-1/+1
2020-07-29Explain why inline default ToString implLzu Tao-0/+3