Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #75122

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
784dd22
add `unsigned_abs` to signed integers
carbotaniuman Jul 25, 2020
35d6a2e
Lint path statements to use drop for drop types
Veykril Aug 2, 2020
532e7f4
Separate off a leafy insert function instead of lying, and split spli…
ssomers Jul 28, 2020
e97e6fb
Fix logging for rustdoc
jyn514 Aug 3, 2020
2e5c501
Do not trigger `unused_braces` for `while let`
JohnTitor Aug 3, 2020
d2fc809
Disable building rust-analyzer on riscv64
Mark-Simulacrum Aug 3, 2020
22161c3
Completes support for coverage in external crates
richkadel Aug 2, 2020
6deda6a
Stabilize Ident::new_raw
Aaron1011 Aug 3, 2020
0a88346
rustc_ast: `(Nested)MetaItem::check_name` -> `has_name`
petrochenkov Aug 2, 2020
05f414b
rustc_ast: More detailed docs for `Attribute::check_name`
petrochenkov Aug 3, 2020
98cc093
Rollup merge of #74759 - carbotaniuman:uabs, r=shepmaster
JohnTitor Aug 3, 2020
7abacbe
Rollup merge of #75037 - richkadel:llvm-coverage-map-gen-5.2, r=wesle…
JohnTitor Aug 3, 2020
c9dff69
Rollup merge of #75043 - petrochenkov:hasname, r=nnethercote
JohnTitor Aug 3, 2020
2ebd068
Rollup merge of #75056 - Veykril:path_statements_lint, r=oli-obk
JohnTitor Aug 3, 2020
48f7c38
Rollup merge of #75058 - ssomers:btree_cleanup_insert_2, r=Mark-Simul…
JohnTitor Aug 3, 2020
bd00490
Rollup merge of #75081 - jyn514:fix-logging, r=Mark-Simulacrum
JohnTitor Aug 3, 2020
ac39b9d
Rollup merge of #75083 - JohnTitor:follow-up-unused-braces, r=lcnr
JohnTitor Aug 3, 2020
885d481
Rollup merge of #75084 - Aaron1011:stabilize/ident-new-raw, r=petroch…
JohnTitor Aug 3, 2020
55a2261
Rollup merge of #75103 - Mark-Simulacrum:no-ra-for-riscv64, r=matklad
JohnTitor Aug 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 42 additions & 44 deletions library/alloc/src/collections/btree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,13 +819,13 @@ impl<BorrowType, K, V, NodeType> Handle<NodeRef<BorrowType, K, V, NodeType>, mar
}
}

impl<'a, K, V> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, marker::Edge> {
impl<'a, K, V, NodeType> Handle<NodeRef<marker::Mut<'a>, K, V, NodeType>, marker::Edge> {
/// Helps implementations of `insert_fit` for a particular `NodeType`,
/// by taking care of leaf data.
/// Inserts a new key/value pair between the key/value pairs to the right and left of
/// this edge. This method assumes that there is enough space in the node for the new
/// pair to fit.
///
/// The returned pointer points to the inserted value.
fn insert_fit(&mut self, key: K, val: V) -> *mut V {
fn leafy_insert_fit(&mut self, key: K, val: V) {
// Necessary for correctness, but in a private module
debug_assert!(self.node.len() < CAPACITY);

Expand All @@ -834,11 +834,23 @@ impl<'a, K, V> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, marker::Edge
slice_insert(self.node.vals_mut(), self.idx, val);

(*self.node.as_leaf_mut()).len += 1;

self.node.vals_mut().get_unchecked_mut(self.idx)
}
}
}

impl<'a, K, V> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, marker::Edge> {
/// Inserts a new key/value pair between the key/value pairs to the right and left of
/// this edge. This method assumes that there is enough space in the node for the new
/// pair to fit.
///
/// The returned pointer points to the inserted value.
fn insert_fit(&mut self, key: K, val: V) -> *mut V {
self.leafy_insert_fit(key, val);
unsafe { self.node.vals_mut().get_unchecked_mut(self.idx) }
}
}

impl<'a, K, V> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, marker::Edge> {
/// Inserts a new key/value pair between the key/value pairs to the right and left of
/// this edge. This method splits the node if there isn't enough room.
///
Expand Down Expand Up @@ -880,14 +892,6 @@ impl<'a, K, V> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>, marker::
}
}

/// Unsafely asserts to the compiler some static information about whether the underlying
/// node of this handle is a `Leaf` or an `Internal`.
unsafe fn cast_unchecked<NewType>(
&mut self,
) -> Handle<NodeRef<marker::Mut<'_>, K, V, NewType>, marker::Edge> {
unsafe { Handle::new_edge(self.node.cast_unchecked(), self.idx) }
}

/// Inserts a new key/value pair and an edge that will go to the right of that new pair
/// between this edge and the key/value pair to the right of this edge. This method assumes
/// that there is enough space in the node for the new pair to fit.
Expand All @@ -897,8 +901,7 @@ impl<'a, K, V> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>, marker::
debug_assert!(edge.height == self.node.height - 1);

unsafe {
// This cast is a lie, but it allows us to reuse the key/value insertion logic.
self.cast_unchecked::<marker::Leaf>().insert_fit(key, val);
self.leafy_insert_fit(key, val);

slice_insert(
slice::from_raw_parts_mut(
Expand Down Expand Up @@ -1030,18 +1033,11 @@ impl<'a, K, V, NodeType> Handle<NodeRef<marker::Mut<'a>, K, V, NodeType>, marker
}
}

impl<'a, K, V> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, marker::KV> {
/// Splits the underlying node into three parts:
///
/// - The node is truncated to only contain the key/value pairs to the right of
/// this handle.
/// - The key and value pointed to by this handle and extracted.
/// - All the key/value pairs to the right of this handle are put into a newly
/// allocated node.
pub fn split(mut self) -> (NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, K, V, Root<K, V>) {
impl<'a, K, V, NodeType> Handle<NodeRef<marker::Mut<'a>, K, V, NodeType>, marker::KV> {
/// Helps implementations of `split` for a particular `NodeType`,
/// by taking care of leaf data.
fn leafy_split(&mut self, new_node: &mut LeafNode<K, V>) -> (K, V, usize) {
unsafe {
let mut new_node = Box::new(LeafNode::new());

let k = ptr::read(self.node.keys().get_unchecked(self.idx));
let v = ptr::read(self.node.vals().get_unchecked(self.idx));

Expand All @@ -1060,6 +1056,24 @@ impl<'a, K, V> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, marker::KV>

(*self.node.as_leaf_mut()).len = self.idx as u16;
new_node.len = new_len as u16;
(k, v, new_len)
}
}
}

impl<'a, K, V> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, marker::KV> {
/// Splits the underlying node into three parts:
///
/// - The node is truncated to only contain the key/value pairs to the right of
/// this handle.
/// - The key and value pointed to by this handle and extracted.
/// - All the key/value pairs to the right of this handle are put into a newly
/// allocated node.
pub fn split(mut self) -> (NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, K, V, Root<K, V>) {
unsafe {
let mut new_node = Box::new(LeafNode::new());

let (k, v, _) = self.leafy_split(&mut new_node);

(self.node, k, v, Root { node: BoxedNode::from_leaf(new_node), height: 0 })
}
Expand Down Expand Up @@ -1091,31 +1105,15 @@ impl<'a, K, V> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>, marker::
unsafe {
let mut new_node = Box::new(InternalNode::new());

let k = ptr::read(self.node.keys().get_unchecked(self.idx));
let v = ptr::read(self.node.vals().get_unchecked(self.idx));

let (k, v, new_len) = self.leafy_split(&mut new_node.data);
let height = self.node.height;
let new_len = self.node.len() - self.idx - 1;

ptr::copy_nonoverlapping(
self.node.keys().as_ptr().add(self.idx + 1),
new_node.data.keys.as_mut_ptr() as *mut K,
new_len,
);
ptr::copy_nonoverlapping(
self.node.vals().as_ptr().add(self.idx + 1),
new_node.data.vals.as_mut_ptr() as *mut V,
new_len,
);
ptr::copy_nonoverlapping(
self.node.as_internal().edges.as_ptr().add(self.idx + 1),
new_node.edges.as_mut_ptr(),
new_len + 1,
);

(*self.node.as_leaf_mut()).len = self.idx as u16;
new_node.data.len = new_len as u16;

let mut new_root = Root { node: BoxedNode::from_internal(new_node), height };

for i in 0..(new_len + 1) {
Expand Down
36 changes: 27 additions & 9 deletions library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1950,15 +1950,20 @@ extern "rust-intrinsic" {
pub fn ptr_offset_from<T>(ptr: *const T, base: *const T) -> isize;

/// Internal placeholder for injecting code coverage counters when the "instrument-coverage"
/// option is enabled. The placeholder is replaced with `llvm.instrprof.increment` during code
/// generation.
/// option is enabled. The source code region information is extracted prior to code generation,
/// and added to the "coverage map", which is injected into the generated code as additional
/// data. This intrinsic then triggers the generation of LLVM intrinsic call
/// `instrprof.increment`, using the remaining args (`function_source_hash` and `index`).
#[cfg(not(bootstrap))]
#[lang = "count_code_region"]
pub fn count_code_region(
function_source_hash: u64,
index: u32,
start_byte_pos: u32,
end_byte_pos: u32,
file_name: &'static str,
start_line: u32,
start_col: u32,
end_line: u32,
end_col: u32,
);

/// Internal marker for code coverage expressions, injected into the MIR when the
Expand All @@ -1973,8 +1978,11 @@ extern "rust-intrinsic" {
index: u32,
left_index: u32,
right_index: u32,
start_byte_pos: u32,
end_byte_pos: u32,
file_name: &'static str,
start_line: u32,
start_col: u32,
end_line: u32,
end_col: u32,
);

/// This marker identifies a code region and two other counters or counter expressions
Expand All @@ -1986,14 +1994,24 @@ extern "rust-intrinsic" {
index: u32,
left_index: u32,
right_index: u32,
start_byte_pos: u32,
end_byte_pos: u32,
file_name: &'static str,
start_line: u32,
start_col: u32,
end_line: u32,
end_col: u32,
);

/// This marker identifies a code region to be added to the "coverage map" to indicate source
/// code that can never be reached.
/// (See `coverage_counter_add` for more information.)
pub fn coverage_unreachable(start_byte_pos: u32, end_byte_pos: u32);
#[cfg(not(bootstrap))]
pub fn coverage_unreachable(
file_name: &'static str,
start_line: u32,
start_col: u32,
end_line: u32,
end_col: u32,
);

/// See documentation of `<*const T>::guaranteed_eq` for details.
#[rustc_const_unstable(feature = "const_raw_ptr_comparison", issue = "53020")]
Expand Down
23 changes: 23 additions & 0 deletions library/core/src/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1601,6 +1601,29 @@ $EndFeature, "
}
}

doc_comment! {
concat!("Computes the absolute value of `self` without any wrapping
or panicking.


# Examples

Basic usage:

```
", $Feature, "#![feature(unsigned_abs)]
assert_eq!(100", stringify!($SelfT), ".unsigned_abs(), 100", stringify!($UnsignedT), ");
assert_eq!((-100", stringify!($SelfT), ").unsigned_abs(), 100", stringify!($UnsignedT), ");
assert_eq!((-128i8).unsigned_abs(), 128u8);",
$EndFeature, "
```"),
#[unstable(feature = "unsigned_abs", issue = "74913")]
#[inline]
pub const fn unsigned_abs(self) -> $UnsignedT {
self.wrapping_abs() as $UnsignedT
}
}

doc_comment! {
concat!("Wrapping (modular) exponentiation. Computes `self.pow(exp)`,
wrapping around at the boundary of the type.
Expand Down
7 changes: 5 additions & 2 deletions library/proc_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ impl Ident {
/// Creates a new `Ident` with the given `string` as well as the specified
/// `span`.
/// The `string` argument must be a valid identifier permitted by the
/// language, otherwise the function will panic.
/// language (including keywords, e.g. `self` or `fn`). Otherwise, the function will panic.
///
/// Note that `span`, currently in rustc, configures the hygiene information
/// for this identifier.
Expand All @@ -870,7 +870,10 @@ impl Ident {
}

/// Same as `Ident::new`, but creates a raw identifier (`r#ident`).
#[unstable(feature = "proc_macro_raw_ident", issue = "54723")]
/// The `string` argument be a valid identifier permitted by the language
/// (including keywords, e.g. `fn`). Keywords which are usable in path segments
/// (e.g. `self`, `super`) are not supported, and will cause a panic.
#[stable(feature = "proc_macro_raw_ident", since = "1.47.0")]
pub fn new_raw(string: &str, span: Span) -> Ident {
Ident(bridge::client::Ident::new(string, span.0, true))
}
Expand Down
Loading