Skip to content

Commit 5bd451b

Browse files
committed
Auto merge of #56215 - pietroalbini:rollup, r=pietroalbini
Rollup of 14 pull requests Successful merges: - #56024 (Don't auto-inline const functions) - #56045 (Check arg/ret sizedness at ExprKind::Path) - #56072 (Stabilize macro_literal_matcher) - #56075 (Encode a custom "producers" section in wasm files) - #56100 (generator fields are not necessarily initialized) - #56101 (Incorporate `dyn` into more comments and docs.) - #56144 (Fix BTreeSet and BTreeMap gdb pretty-printers) - #56151 (Move a flaky process test out of libstd) - #56170 (Fix self profiler ICE on Windows) - #56176 (Panic setup msg) - #56204 (Suggest correct enum variant on typo) - #56207 (Stabilize the int_to_from_bytes feature) - #56210 (read_c_str should call the AllocationExtra hooks) - #56211 ([master] Forward-ports from beta) Failed merges: r? @ghost
2 parents e9bca7a + cd17b1d commit 5bd451b

File tree

65 files changed

+686
-374
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+686
-374
lines changed

src/doc/unstable-book/src/language-features/macro-literal-matcher.md

-17
This file was deleted.

src/doc/unstable-book/src/language-features/unsized-locals.md

-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ fn main() {
8080
}
8181
```
8282

83-
However, the current implementation allows `MyTupleStruct(..)` to be unsized. This will be fixed in the future.
84-
8583
## By-value trait objects
8684

8785
With this feature, you can have by-value `self` arguments without `Self: Sized` bounds.

src/etc/debugger_pretty_printers_common.py

-26
Original file line numberDiff line numberDiff line change
@@ -375,32 +375,6 @@ def extract_tail_head_ptr_and_cap_from_std_vecdeque(vec_val):
375375
assert data_ptr.type.get_dwarf_type_kind() == DWARF_TYPE_CODE_PTR
376376
return (tail, head, data_ptr, capacity)
377377

378-
379-
def extract_length_and_ptr_from_std_btreeset(vec_val):
380-
assert vec_val.type.get_type_kind() == TYPE_KIND_STD_BTREESET
381-
map = vec_val.get_child_at_index(0)
382-
root = map.get_child_at_index(0)
383-
length = map.get_child_at_index(1).as_integer()
384-
node = root.get_child_at_index(0)
385-
ptr = node.get_child_at_index(0)
386-
unique_ptr_val = ptr.get_child_at_index(0)
387-
data_ptr = unique_ptr_val.get_child_at_index(0)
388-
assert data_ptr.type.get_dwarf_type_kind() == DWARF_TYPE_CODE_PTR
389-
return (length, data_ptr)
390-
391-
392-
def extract_length_and_ptr_from_std_btreemap(vec_val):
393-
assert vec_val.type.get_type_kind() == TYPE_KIND_STD_BTREEMAP
394-
root = vec_val.get_child_at_index(0)
395-
length = vec_val.get_child_at_index(1).as_integer()
396-
node = root.get_child_at_index(0)
397-
ptr = node.get_child_at_index(0)
398-
unique_ptr_val = ptr.get_child_at_index(0)
399-
data_ptr = unique_ptr_val.get_child_at_index(0)
400-
assert data_ptr.type.get_dwarf_type_kind() == DWARF_TYPE_CODE_PTR
401-
return (length, data_ptr)
402-
403-
404378
def extract_length_and_ptr_from_slice(slice_val):
405379
assert (slice_val.type.get_type_kind() == TYPE_KIND_SLICE or
406380
slice_val.type.get_type_kind() == TYPE_KIND_STR_SLICE)

src/etc/gdb_rust_pretty_printing.py

+41-29
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,32 @@ def children(self):
319319
yield (str(index), (gdb_ptr + ((tail + index) % cap)).dereference())
320320

321321

322+
# Yield each key (and optionally value) from a BoxedNode.
323+
def children_of_node(boxed_node, height, want_values):
324+
ptr = boxed_node['ptr']['pointer']
325+
# This is written oddly because we don't want to rely on the field name being `__0`.
326+
node_ptr = ptr[ptr.type.fields()[0]]
327+
if height > 0:
328+
type_name = str(node_ptr.type.target()).replace('LeafNode', 'InternalNode')
329+
node_type = gdb.lookup_type(type_name)
330+
node_ptr = node_ptr.cast(node_type.pointer())
331+
leaf = node_ptr['data']
332+
else:
333+
leaf = node_ptr.dereference()
334+
keys = leaf['keys']['value']['value']
335+
if want_values:
336+
values = leaf['vals']['value']['value']
337+
length = int(leaf['len'])
338+
for i in xrange(0, length + 1):
339+
if height > 0:
340+
for child in children_of_node(node_ptr['edges'][i], height - 1, want_values):
341+
yield child
342+
if i < length:
343+
if want_values:
344+
yield (keys[i], values[i])
345+
else:
346+
yield keys[i]
347+
322348
class RustStdBTreeSetPrinter(object):
323349
def __init__(self, val):
324350
self.__val = val
@@ -328,21 +354,16 @@ def display_hint():
328354
return "array"
329355

330356
def to_string(self):
331-
(length, data_ptr) = \
332-
rustpp.extract_length_and_ptr_from_std_btreeset(self.__val)
333357
return (self.__val.type.get_unqualified_type_name() +
334-
("(len: %i)" % length))
358+
("(len: %i)" % self.__val.get_wrapped_value()['map']['length']))
335359

336360
def children(self):
337-
(length, data_ptr) = \
338-
rustpp.extract_length_and_ptr_from_std_btreeset(self.__val)
339-
leaf_node = GdbValue(data_ptr.get_wrapped_value().dereference())
340-
maybe_uninit_keys = leaf_node.get_child_at_index(3)
341-
manually_drop_keys = maybe_uninit_keys.get_child_at_index(1)
342-
keys = manually_drop_keys.get_child_at_index(0)
343-
gdb_ptr = keys.get_wrapped_value()
344-
for index in xrange(length):
345-
yield (str(index), gdb_ptr[index])
361+
root = self.__val.get_wrapped_value()['map']['root']
362+
node_ptr = root['node']
363+
i = 0
364+
for child in children_of_node(node_ptr, root['height'], False):
365+
yield (str(i), child)
366+
i = i + 1
346367

347368

348369
class RustStdBTreeMapPrinter(object):
@@ -354,26 +375,17 @@ def display_hint():
354375
return "map"
355376

356377
def to_string(self):
357-
(length, data_ptr) = \
358-
rustpp.extract_length_and_ptr_from_std_btreemap(self.__val)
359378
return (self.__val.type.get_unqualified_type_name() +
360-
("(len: %i)" % length))
379+
("(len: %i)" % self.__val.get_wrapped_value()['length']))
361380

362381
def children(self):
363-
(length, data_ptr) = \
364-
rustpp.extract_length_and_ptr_from_std_btreemap(self.__val)
365-
leaf_node = GdbValue(data_ptr.get_wrapped_value().dereference())
366-
maybe_uninit_keys = leaf_node.get_child_at_index(3)
367-
manually_drop_keys = maybe_uninit_keys.get_child_at_index(1)
368-
keys = manually_drop_keys.get_child_at_index(0)
369-
keys_ptr = keys.get_wrapped_value()
370-
maybe_uninit_vals = leaf_node.get_child_at_index(4)
371-
manually_drop_vals = maybe_uninit_vals.get_child_at_index(1)
372-
vals = manually_drop_vals.get_child_at_index(0)
373-
vals_ptr = vals.get_wrapped_value()
374-
for index in xrange(length):
375-
yield (str(index), keys_ptr[index])
376-
yield (str(index), vals_ptr[index])
382+
root = self.__val.get_wrapped_value()['root']
383+
node_ptr = root['node']
384+
i = 0
385+
for child in children_of_node(node_ptr, root['height'], True):
386+
yield (str(i), child[0])
387+
yield (str(i), child[1])
388+
i = i + 1
377389

378390

379391
class RustStdStringPrinter(object):

src/liballoc/boxed.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ impl Box<dyn Any> {
489489
/// ```
490490
/// use std::any::Any;
491491
///
492-
/// fn print_if_string(value: Box<Any>) {
492+
/// fn print_if_string(value: Box<dyn Any>) {
493493
/// if let Ok(string) = value.downcast::<String>() {
494494
/// println!("String ({}): {}", string.len(), string);
495495
/// }
@@ -523,7 +523,7 @@ impl Box<dyn Any + Send> {
523523
/// ```
524524
/// use std::any::Any;
525525
///
526-
/// fn print_if_string(value: Box<Any + Send>) {
526+
/// fn print_if_string(value: Box<dyn Any + Send>) {
527527
/// if let Ok(string) = value.downcast::<String>() {
528528
/// println!("String ({}): {}", string.len(), string);
529529
/// }
@@ -618,18 +618,18 @@ impl<I: FusedIterator + ?Sized> FusedIterator for Box<I> {}
618618

619619
/// `FnBox` is a version of the `FnOnce` intended for use with boxed
620620
/// closure objects. The idea is that where one would normally store a
621-
/// `Box<FnOnce()>` in a data structure, you should use
622-
/// `Box<FnBox()>`. The two traits behave essentially the same, except
621+
/// `Box<dyn FnOnce()>` in a data structure, you should use
622+
/// `Box<dyn FnBox()>`. The two traits behave essentially the same, except
623623
/// that a `FnBox` closure can only be called if it is boxed. (Note
624-
/// that `FnBox` may be deprecated in the future if `Box<FnOnce()>`
624+
/// that `FnBox` may be deprecated in the future if `Box<dyn FnOnce()>`
625625
/// closures become directly usable.)
626626
///
627627
/// # Examples
628628
///
629629
/// Here is a snippet of code which creates a hashmap full of boxed
630630
/// once closures and then removes them one by one, calling each
631631
/// closure as it is removed. Note that the type of the closures
632-
/// stored in the map is `Box<FnBox() -> i32>` and not `Box<FnOnce()
632+
/// stored in the map is `Box<dyn FnBox() -> i32>` and not `Box<dyn FnOnce()
633633
/// -> i32>`.
634634
///
635635
/// ```
@@ -638,8 +638,8 @@ impl<I: FusedIterator + ?Sized> FusedIterator for Box<I> {}
638638
/// use std::boxed::FnBox;
639639
/// use std::collections::HashMap;
640640
///
641-
/// fn make_map() -> HashMap<i32, Box<FnBox() -> i32>> {
642-
/// let mut map: HashMap<i32, Box<FnBox() -> i32>> = HashMap::new();
641+
/// fn make_map() -> HashMap<i32, Box<dyn FnBox() -> i32>> {
642+
/// let mut map: HashMap<i32, Box<dyn FnBox() -> i32>> = HashMap::new();
643643
/// map.insert(1, Box::new(|| 22));
644644
/// map.insert(2, Box::new(|| 44));
645645
/// map

src/liballoc/rc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -633,15 +633,15 @@ impl<T: Clone> Rc<T> {
633633
impl Rc<dyn Any> {
634634
#[inline]
635635
#[stable(feature = "rc_downcast", since = "1.29.0")]
636-
/// Attempt to downcast the `Rc<Any>` to a concrete type.
636+
/// Attempt to downcast the `Rc<dyn Any>` to a concrete type.
637637
///
638638
/// # Examples
639639
///
640640
/// ```
641641
/// use std::any::Any;
642642
/// use std::rc::Rc;
643643
///
644-
/// fn print_if_string(value: Rc<Any>) {
644+
/// fn print_if_string(value: Rc<dyn Any>) {
645645
/// if let Ok(string) = value.downcast::<String>() {
646646
/// println!("String ({}): {}", string.len(), string);
647647
/// }

0 commit comments

Comments
 (0)