diff options
| author | bors <bors@rust-lang.org> | 2021-01-17 14:50:24 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-01-17 14:50:24 +0000 |
| commit | edeb631ad0cd6fdf31e2e31ec90e105d1768be28 (patch) | |
| tree | 48c316c067559b3c58d2b652aa836953f0dced5b /library/alloc/src | |
| parent | 7d3818152d8ab5649d2e5cc6d7851ed7c03055fe (diff) | |
| parent | 801684620bd4e0bc12b98a071851e3d3064429e4 (diff) | |
| download | rust-edeb631ad0cd6fdf31e2e31ec90e105d1768be28.tar.gz rust-edeb631ad0cd6fdf31e2e31ec90e105d1768be28.zip | |
Auto merge of #81113 - m-ou-se:rollup-a1unz4x, r=m-ou-se
Rollup of 13 pull requests Successful merges: - #79298 (correctly deal with late-bound lifetimes in anon consts) - #80031 (resolve: Reject ambiguity built-in attr vs different built-in attr) - #80201 (Add benchmark and fast path for BufReader::read_exact) - #80635 (Improve diagnostics when closure doesn't meet trait bound) - #80765 (resolve: Simplify collection of traits in scope) - #80932 (Allow downloading LLVM on Windows and MacOS) - #80983 (Remove is_dllimport_foreign_item definition from cg_ssa) - #81064 (Support non-stage0 check) - #81080 (Force vec![] to expression position only) - #81082 (BTreeMap: clean up a few more comments) - #81084 (Use Option::map instead of open-coding it) - #81095 (Use Option::unwrap_or instead of open-coding it) - #81107 (Add NonZeroUn::is_power_of_two) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/alloc/src')
| -rw-r--r-- | library/alloc/src/collections/btree/node.rs | 11 | ||||
| -rw-r--r-- | library/alloc/src/collections/btree/search.rs | 3 | ||||
| -rw-r--r-- | library/alloc/src/lib.rs | 8 | ||||
| -rw-r--r-- | library/alloc/src/macros.rs | 8 |
4 files changed, 20 insertions, 10 deletions
diff --git a/library/alloc/src/collections/btree/node.rs b/library/alloc/src/collections/btree/node.rs index 220c98b294c..928c6f9a3a8 100644 --- a/library/alloc/src/collections/btree/node.rs +++ b/library/alloc/src/collections/btree/node.rs @@ -184,7 +184,7 @@ impl<K, V> NodeRef<marker::Owned, K, V, marker::LeafOrInternal> { /// Removes the internal root node, using its first child as the new root node. /// As it is intended only to be called when the root node has only one child, - /// no cleanup is done on any of the other children. + /// no cleanup is done on any of the keys, values and other children. /// This decreases the height by 1 and is the opposite of `push_internal_level`. /// /// Requires exclusive access to the `Root` object but not to the root node; @@ -225,7 +225,7 @@ impl<K, V> NodeRef<marker::Owned, K, V, marker::LeafOrInternal> { /// - When this is `Owned`, the `NodeRef` acts roughly like `Box<Node>`, /// but does not have a destructor, and must be cleaned up manually. /// Since any `NodeRef` allows navigating through the tree, `BorrowType` -/// effectively applies to the entire tree, not just the node itself. +/// effectively applies to the entire tree, not just to the node itself. /// - `K` and `V`: These are the types of keys and values stored in the nodes. /// - `Type`: This can be `Leaf`, `Internal`, or `LeafOrInternal`. When this is /// `Leaf`, the `NodeRef` points to a leaf node, when this is `Internal` the @@ -425,7 +425,7 @@ impl<'a, K: 'a, V: 'a, Type> NodeRef<marker::Immut<'a>, K, V, Type> { impl<K, V> NodeRef<marker::Owned, K, V, marker::LeafOrInternal> { /// Similar to `ascend`, gets a reference to a node's parent node, but also - /// deallocate the current node in the process. This is unsafe because the + /// deallocates the current node in the process. This is unsafe because the /// current node will still be accessible despite being deallocated. pub unsafe fn deallocate_and_ascend( self, @@ -661,7 +661,10 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> { /// Removes a key-value pair from the end of the node and returns the pair. /// Also removes the edge that was to the right of that pair and, if the node /// is internal, returns the orphaned subtree that this edge owned. - fn pop(&mut self) -> (K, V, Option<Root<K, V>>) { + /// + /// # Safety + /// The node must not be empty. + unsafe fn pop(&mut self) -> (K, V, Option<Root<K, V>>) { debug_assert!(self.len() > 0); let idx = self.len() - 1; diff --git a/library/alloc/src/collections/btree/search.rs b/library/alloc/src/collections/btree/search.rs index ed7f95fe632..efe94ef175c 100644 --- a/library/alloc/src/collections/btree/search.rs +++ b/library/alloc/src/collections/btree/search.rs @@ -12,8 +12,7 @@ pub enum SearchResult<BorrowType, K, V, FoundType, GoDownType> { /// Looks up a given key in a (sub)tree headed by the given node, recursively. /// Returns a `Found` with the handle of the matching KV, if any. Otherwise, -/// returns a `GoDown` with the handle of the possible leaf edge where the key -/// belongs. +/// returns a `GoDown` with the handle of the leaf edge where the key belongs. /// /// The result is meaningful only if the tree is ordered by key, like the tree /// in a `BTreeMap` is. diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index d0bfa038aa1..14a10aac061 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -140,6 +140,7 @@ #![feature(type_alias_impl_trait)] #![feature(associated_type_bounds)] #![feature(slice_group_by)] +#![feature(decl_macro)] // Allow testing this library #[cfg(test)] @@ -193,4 +194,11 @@ mod std { #[unstable(feature = "liballoc_internals", issue = "none", reason = "implementation detail")] pub mod __export { pub use core::format_args; + + /// Force AST node to an expression to improve diagnostics in pattern position. + #[rustc_macro_transparency = "semitransparent"] + #[unstable(feature = "liballoc_internals", issue = "none", reason = "implementation detail")] + pub macro force_expr($e:expr) { + $e + } } diff --git a/library/alloc/src/macros.rs b/library/alloc/src/macros.rs index 7d4eff6185d..3a46763c3f6 100644 --- a/library/alloc/src/macros.rs +++ b/library/alloc/src/macros.rs @@ -37,16 +37,16 @@ #[cfg(not(test))] #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] -#[allow_internal_unstable(box_syntax)] +#[allow_internal_unstable(box_syntax, liballoc_internals)] macro_rules! vec { () => ( - $crate::vec::Vec::new() + $crate::__export::force_expr!($crate::vec::Vec::new()) ); ($elem:expr; $n:expr) => ( - $crate::vec::from_elem($elem, $n) + $crate::__export::force_expr!($crate::vec::from_elem($elem, $n)) ); ($($x:expr),+ $(,)?) => ( - <[_]>::into_vec(box [$($x),+]) + $crate::__export::force_expr!(<[_]>::into_vec(box [$($x),+])) ); } |
