Skip to content

Commit 53d19b3

Browse files
committed
Auto merge of rust-lang#79377 - jonas-schievink:rollup-ye81i66, r=jonas-schievink
Rollup of 10 pull requests Successful merges: - rust-lang#76858 (Add exploit mitigations chapter to the rustc book) - rust-lang#79310 (Make `fold_item_recur` non-nullable) - rust-lang#79312 (Get rid of `doctree::Impl`) - rust-lang#79321 (Accept '!' in intra-doc links) - rust-lang#79346 (Allow using `-Z fewer-names=no` to retain value names) - rust-lang#79351 (Fix typo in `keyword` docs for traits) - rust-lang#79354 (BTreeMap: cut out the ceremony around BoxedNode) - rust-lang#79358 (BTreeMap/BTreeSet: make public doc more consistent) - rust-lang#79367 (Allow disabling TrapUnreachable via -Ztrap-unreachable=no) - rust-lang#79374 (Add note to use nightly when using expr in const generics) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 6331023 + f049b0b commit 53d19b3

File tree

92 files changed

+999
-312
lines changed

Some content is hidden

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

92 files changed

+999
-312
lines changed

compiler/rustc_codegen_llvm/src/back/write.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ pub fn target_machine_factory(
152152
let features = features.join(",");
153153
let features = CString::new(features).unwrap();
154154
let abi = SmallCStr::new(&sess.target.llvm_abiname);
155-
let trap_unreachable = sess.target.trap_unreachable;
155+
let trap_unreachable =
156+
sess.opts.debugging_opts.trap_unreachable.unwrap_or(sess.target.trap_unreachable);
156157
let emit_stack_size_section = sess.opts.debugging_opts.emit_stack_sizes;
157158

158159
let asm_comments = sess.asm_comments();

compiler/rustc_interface/src/tests.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ fn test_debugging_options_tracking_hash() {
547547
tracked!(debug_macros, true);
548548
tracked!(dep_info_omit_d_target, true);
549549
tracked!(dual_proc_macros, true);
550-
tracked!(fewer_names, true);
550+
tracked!(fewer_names, Some(true));
551551
tracked!(force_overflow_checks, Some(true));
552552
tracked!(force_unstable_if_unmarked, true);
553553
tracked!(fuel, Some(("abc".to_string(), 99)));
@@ -592,6 +592,7 @@ fn test_debugging_options_tracking_hash() {
592592
tracked!(thinlto, Some(true));
593593
tracked!(tune_cpu, Some(String::from("abc")));
594594
tracked!(tls_model, Some(TlsModel::GeneralDynamic));
595+
tracked!(trap_unreachable, Some(false));
595596
tracked!(treat_err_as_bug, Some(1));
596597
tracked!(unleash_the_miri_inside_of_you, true);
597598
tracked!(use_ctors_section, Some(true));

compiler/rustc_resolve/src/diagnostics.rs

+1
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ impl<'a> Resolver<'a> {
481481
name
482482
));
483483
}
484+
err.help("use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions");
484485

485486
err
486487
}

compiler/rustc_session/src/options.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
900900
"emits a future-incompatibility report for lints (RFC 2834)"),
901901
emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED],
902902
"emit a section containing stack size metadata (default: no)"),
903-
fewer_names: bool = (false, parse_bool, [TRACKED],
903+
fewer_names: Option<bool> = (None, parse_opt_bool, [TRACKED],
904904
"reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR) \
905905
(default: no)"),
906906
force_overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
@@ -1113,6 +1113,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
11131113
"choose the TLS model to use (`rustc --print tls-models` for details)"),
11141114
trace_macros: bool = (false, parse_bool, [UNTRACKED],
11151115
"for every macro invocation, print its name and arguments (default: no)"),
1116+
trap_unreachable: Option<bool> = (None, parse_opt_bool, [TRACKED],
1117+
"generate trap instructions for unreachable intrinsics (default: use target setting, usually yes)"),
11161118
treat_err_as_bug: Option<usize> = (None, parse_treat_err_as_bug, [TRACKED],
11171119
"treat error number `val` that occurs as bug"),
11181120
trim_diagnostic_paths: bool = (true, parse_bool, [UNTRACKED],

compiler/rustc_session/src/session.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -734,12 +734,15 @@ impl Session {
734734
self.opts.cg.panic.unwrap_or(self.target.panic_strategy)
735735
}
736736
pub fn fewer_names(&self) -> bool {
737-
let more_names = self.opts.output_types.contains_key(&OutputType::LlvmAssembly)
738-
|| self.opts.output_types.contains_key(&OutputType::Bitcode)
739-
// AddressSanitizer and MemorySanitizer use alloca name when reporting an issue.
740-
|| self.opts.debugging_opts.sanitizer.intersects(SanitizerSet::ADDRESS | SanitizerSet::MEMORY);
741-
742-
self.opts.debugging_opts.fewer_names || !more_names
737+
if let Some(fewer_names) = self.opts.debugging_opts.fewer_names {
738+
fewer_names
739+
} else {
740+
let more_names = self.opts.output_types.contains_key(&OutputType::LlvmAssembly)
741+
|| self.opts.output_types.contains_key(&OutputType::Bitcode)
742+
// AddressSanitizer and MemorySanitizer use alloca name when reporting an issue.
743+
|| self.opts.debugging_opts.sanitizer.intersects(SanitizerSet::ADDRESS | SanitizerSet::MEMORY);
744+
!more_names
745+
}
743746
}
744747

745748
pub fn unstable_options(&self) -> bool {

compiler/rustc_typeck/src/check/wfcheck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) {
329329
),
330330
)
331331
.note("the only supported types are integers, `bool` and `char`")
332-
.note("more complex types are supported with `#[feature(const_generics)]`")
332+
.help("more complex types are supported with `#[feature(const_generics)]`")
333333
.emit()
334334
}
335335
};

library/alloc/src/collections/btree/map.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ impl<K: fmt::Debug, V: fmt::Debug> fmt::Debug for RangeMut<'_, K, V> {
458458
}
459459

460460
impl<K: Ord, V> BTreeMap<K, V> {
461-
/// Makes a new empty BTreeMap.
461+
/// Makes a new, empty `BTreeMap`.
462462
///
463463
/// Does not allocate anything on its own.
464464
///
@@ -1924,7 +1924,7 @@ impl<K: Hash, V: Hash> Hash for BTreeMap<K, V> {
19241924

19251925
#[stable(feature = "rust1", since = "1.0.0")]
19261926
impl<K: Ord, V> Default for BTreeMap<K, V> {
1927-
/// Creates an empty `BTreeMap<K, V>`.
1927+
/// Creates an empty `BTreeMap`.
19281928
fn default() -> BTreeMap<K, V> {
19291929
BTreeMap::new()
19301930
}

library/alloc/src/collections/btree/node.rs

+12-38
Original file line numberDiff line numberDiff line change
@@ -112,20 +112,8 @@ impl<K, V> InternalNode<K, V> {
112112
///
113113
/// However, `BoxedNode` contains no information as to which of the two types
114114
/// of nodes it actually contains, and, partially due to this lack of information,
115-
/// has no destructor.
116-
struct BoxedNode<K, V> {
117-
ptr: NonNull<LeafNode<K, V>>,
118-
}
119-
120-
impl<K, V> BoxedNode<K, V> {
121-
fn from_owned(ptr: NonNull<LeafNode<K, V>>) -> Self {
122-
BoxedNode { ptr }
123-
}
124-
125-
fn as_ptr(&self) -> NonNull<LeafNode<K, V>> {
126-
self.ptr
127-
}
128-
}
115+
/// is not a separate type and has no destructor.
116+
type BoxedNode<K, V> = NonNull<LeafNode<K, V>>;
129117

130118
/// An owned tree.
131119
///
@@ -168,11 +156,6 @@ impl<K, V, Type> NodeRef<marker::Owned, K, V, Type> {
168156
pub fn borrow_valmut(&mut self) -> NodeRef<marker::ValMut<'_>, K, V, Type> {
169157
NodeRef { height: self.height, node: self.node, _marker: PhantomData }
170158
}
171-
172-
/// Packs the reference, aware of type and height, into a type-agnostic pointer.
173-
fn into_boxed_node(self) -> BoxedNode<K, V> {
174-
BoxedNode::from_owned(self.node)
175-
}
176159
}
177160

178161
impl<K, V> NodeRef<marker::Owned, K, V, marker::LeafOrInternal> {
@@ -181,7 +164,7 @@ impl<K, V> NodeRef<marker::Owned, K, V, marker::LeafOrInternal> {
181164
/// and is the opposite of `pop_internal_level`.
182165
pub fn push_internal_level(&mut self) -> NodeRef<marker::Mut<'_>, K, V, marker::Internal> {
183166
let mut new_node = Box::new(unsafe { InternalNode::new() });
184-
new_node.edges[0].write(BoxedNode::from_owned(self.node));
167+
new_node.edges[0].write(self.node);
185168
let mut new_root = NodeRef::from_new_internal(new_node, self.height + 1);
186169
new_root.borrow_mut().first_edge().correct_parent_link();
187170
*self = new_root.forget_type();
@@ -288,13 +271,6 @@ unsafe impl<'a, K: Send + 'a, V: Send + 'a, Type> Send for NodeRef<marker::Mut<'
288271
unsafe impl<'a, K: Send + 'a, V: Send + 'a, Type> Send for NodeRef<marker::ValMut<'a>, K, V, Type> {}
289272
unsafe impl<K: Send, V: Send, Type> Send for NodeRef<marker::Owned, K, V, Type> {}
290273

291-
impl<BorrowType, K, V> NodeRef<BorrowType, K, V, marker::LeafOrInternal> {
292-
/// Unpack a node reference that was packed by `Root::into_boxed_node`.
293-
fn from_boxed_node(boxed_node: BoxedNode<K, V>, height: usize) -> Self {
294-
NodeRef { height, node: boxed_node.as_ptr(), _marker: PhantomData }
295-
}
296-
}
297-
298274
impl<BorrowType, K, V> NodeRef<BorrowType, K, V, marker::Internal> {
299275
/// Unpack a node reference that was packed as `NodeRef::parent`.
300276
fn from_internal(node: NonNull<InternalNode<K, V>>, height: usize) -> Self {
@@ -695,7 +671,7 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::Internal> {
695671
unsafe {
696672
self.reborrow_mut().into_key_area_mut_at(idx).write(key);
697673
self.reborrow_mut().into_val_area_mut_at(idx).write(val);
698-
self.reborrow_mut().into_edge_area_mut_at(idx + 1).write(edge.into_boxed_node());
674+
self.reborrow_mut().into_edge_area_mut_at(idx + 1).write(edge.node);
699675
Handle::new_edge(self.reborrow_mut(), idx + 1).correct_parent_link();
700676
}
701677
}
@@ -710,7 +686,7 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::Internal> {
710686
*self.reborrow_mut().into_len_mut() += 1;
711687
slice_insert(self.reborrow_mut().into_key_area_slice(), 0, key);
712688
slice_insert(self.reborrow_mut().into_val_area_slice(), 0, val);
713-
slice_insert(self.reborrow_mut().into_edge_area_slice(), 0, edge.into_boxed_node());
689+
slice_insert(self.reborrow_mut().into_edge_area_slice(), 0, edge.node);
714690
}
715691

716692
self.correct_all_childrens_parent_links();
@@ -732,8 +708,8 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> {
732708
let edge = match self.reborrow_mut().force() {
733709
ForceResult::Leaf(_) => None,
734710
ForceResult::Internal(internal) => {
735-
let boxed_node = ptr::read(internal.reborrow().edge_at(idx + 1));
736-
let mut edge = Root::from_boxed_node(boxed_node, internal.height - 1);
711+
let node = ptr::read(internal.reborrow().edge_at(idx + 1));
712+
let mut edge = Root { node, height: internal.height - 1, _marker: PhantomData };
737713
// In practice, clearing the parent is a waste of time, because we will
738714
// insert the node elsewhere and set its parent link again.
739715
edge.borrow_mut().clear_parent_link();
@@ -760,9 +736,8 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> {
760736
let edge = match self.reborrow_mut().force() {
761737
ForceResult::Leaf(_) => None,
762738
ForceResult::Internal(mut internal) => {
763-
let boxed_node =
764-
slice_remove(internal.reborrow_mut().into_edge_area_slice(), 0);
765-
let mut edge = Root::from_boxed_node(boxed_node, internal.height - 1);
739+
let node = slice_remove(internal.reborrow_mut().into_edge_area_slice(), 0);
740+
let mut edge = Root { node, height: internal.height - 1, _marker: PhantomData };
766741
// In practice, clearing the parent is a waste of time, because we will
767742
// insert the node elsewhere and set its parent link again.
768743
edge.borrow_mut().clear_parent_link();
@@ -1041,12 +1016,11 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>,
10411016
debug_assert!(self.node.len() < CAPACITY);
10421017
debug_assert!(edge.height == self.node.height - 1);
10431018

1044-
let boxed_node = edge.into_boxed_node();
10451019
unsafe {
10461020
*self.node.reborrow_mut().into_len_mut() += 1;
10471021
slice_insert(self.node.reborrow_mut().into_key_area_slice(), self.idx, key);
10481022
slice_insert(self.node.reborrow_mut().into_val_area_slice(), self.idx, val);
1049-
slice_insert(self.node.reborrow_mut().into_edge_area_slice(), self.idx + 1, boxed_node);
1023+
slice_insert(self.node.reborrow_mut().into_edge_area_slice(), self.idx + 1, edge.node);
10501024

10511025
self.node.correct_childrens_parent_links((self.idx + 1)..=self.node.len());
10521026
}
@@ -1135,8 +1109,8 @@ impl<BorrowType, K, V> Handle<NodeRef<BorrowType, K, V, marker::Internal>, marke
11351109
// reference (Rust issue #73987) and invalidate any other references
11361110
// to or inside the array, should any be around.
11371111
let parent_ptr = NodeRef::as_internal_ptr(&self.node);
1138-
let boxed_node = unsafe { (*parent_ptr).edges.get_unchecked(self.idx).assume_init_read() };
1139-
NodeRef::from_boxed_node(boxed_node, self.node.height - 1)
1112+
let node = unsafe { (*parent_ptr).edges.get_unchecked(self.idx).assume_init_read() };
1113+
NodeRef { node, height: self.node.height - 1, _marker: PhantomData }
11401114
}
11411115
}
11421116

library/alloc/src/collections/btree/set.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ impl<T: fmt::Debug> fmt::Debug for Union<'_, T> {
220220
const ITER_PERFORMANCE_TIPPING_SIZE_DIFF: usize = 16;
221221

222222
impl<T: Ord> BTreeSet<T> {
223-
/// Makes a new `BTreeSet` with a reasonable choice of B.
223+
/// Makes a new, empty `BTreeSet`.
224+
///
225+
/// Does not allocate anything on its own.
224226
///
225227
/// # Examples
226228
///
@@ -1121,7 +1123,7 @@ impl<'a, T: 'a + Ord + Copy> Extend<&'a T> for BTreeSet<T> {
11211123

11221124
#[stable(feature = "rust1", since = "1.0.0")]
11231125
impl<T: Ord> Default for BTreeSet<T> {
1124-
/// Makes an empty `BTreeSet<T>` with a reasonable choice of B.
1126+
/// Creates an empty `BTreeSet`.
11251127
fn default() -> BTreeSet<T> {
11261128
BTreeSet::new()
11271129
}

library/std/src/keyword_docs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1739,7 +1739,7 @@ mod super_keyword {}
17391739
///
17401740
/// # Differences between the 2015 and 2018 editions
17411741
///
1742-
/// In the 2015 edition parameters pattern where not needed for traits:
1742+
/// In the 2015 edition the parameters pattern was not needed for traits:
17431743
///
17441744
/// ```rust,edition2015
17451745
/// trait Tr {

src/doc/rustc/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@
1818
- [Known Issues](targets/known-issues.md)
1919
- [Profile-guided Optimization](profile-guided-optimization.md)
2020
- [Linker-plugin based LTO](linker-plugin-lto.md)
21+
- [Exploit Mitigations](exploit-mitigations.md)
2122
- [Contributing to `rustc`](contributing.md)

0 commit comments

Comments
 (0)