Skip to content

Commit df2f45c

Browse files
committed
Auto merge of #92090 - matthiaskrgr:rollup-pbyqddi, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #91834 (Update browser-ui-test version and improve rustdoc-gui tests readability) - #91894 (Remove `in_band_lifetimes` from `rustc_incremental`) - #91932 (Add user seed to `-Z randomize-layout`) - #91956 (fix(rustc_lint): better detect when parens are necessary) - #92020 (Remove P: Unpin bound on impl Stream for Pin) - #92063 (docs: fix typo) - #92082 (rustdoc: Write doc-comments directly instead of using FromIterator) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents daf2204 + d486e68 commit df2f45c

27 files changed

+374
-99
lines changed

compiler/rustc_incremental/src/assert_dep_graph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ struct IfThisChanged<'tcx> {
103103
then_this_would_need: Targets,
104104
}
105105

106-
impl IfThisChanged<'tcx> {
106+
impl<'tcx> IfThisChanged<'tcx> {
107107
fn argument(&self, attr: &ast::Attribute) -> Option<Symbol> {
108108
let mut value = None;
109109
for list_item in attr.meta_item_list().unwrap_or_default() {
@@ -172,7 +172,7 @@ impl IfThisChanged<'tcx> {
172172
}
173173
}
174174

175-
impl Visitor<'tcx> for IfThisChanged<'tcx> {
175+
impl<'tcx> Visitor<'tcx> for IfThisChanged<'tcx> {
176176
type Map = Map<'tcx>;
177177

178178
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {

compiler/rustc_incremental/src/assert_module_sources.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct AssertModuleSource<'tcx> {
5656
available_cgus: BTreeSet<String>,
5757
}
5858

59-
impl AssertModuleSource<'tcx> {
59+
impl<'tcx> AssertModuleSource<'tcx> {
6060
fn check_attr(&self, attr: &ast::Attribute) {
6161
let (expected_reuse, comp_kind) = if attr.has_name(sym::rustc_partition_reused) {
6262
(CguReuse::PreLto, ComparisonKind::AtLeast)

compiler/rustc_incremental/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
#![deny(missing_docs)]
44
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
5-
#![feature(in_band_lifetimes)]
65
#![feature(let_else)]
76
#![feature(nll)]
87
#![recursion_limit = "256"]

compiler/rustc_incremental/src/persist/dirty_clean.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ pub struct DirtyCleanVisitor<'tcx> {
155155
checked_attrs: FxHashSet<ast::AttrId>,
156156
}
157157

158-
impl DirtyCleanVisitor<'tcx> {
158+
impl<'tcx> DirtyCleanVisitor<'tcx> {
159159
/// Possibly "deserialize" the attribute into a clean/dirty assertion
160160
fn assertion_maybe(&mut self, item_id: LocalDefId, attr: &Attribute) -> Option<Assertion> {
161161
if !attr.has_name(sym::rustc_clean) {
@@ -352,7 +352,7 @@ impl DirtyCleanVisitor<'tcx> {
352352
}
353353
}
354354

355-
impl ItemLikeVisitor<'tcx> for DirtyCleanVisitor<'tcx> {
355+
impl<'tcx> ItemLikeVisitor<'tcx> for DirtyCleanVisitor<'tcx> {
356356
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
357357
self.check_item(item.def_id, item.span);
358358
}
@@ -415,7 +415,7 @@ pub struct FindAllAttrs<'tcx> {
415415
found_attrs: Vec<&'tcx Attribute>,
416416
}
417417

418-
impl FindAllAttrs<'tcx> {
418+
impl<'tcx> FindAllAttrs<'tcx> {
419419
fn is_active_attr(&mut self, attr: &Attribute) -> bool {
420420
if attr.has_name(sym::rustc_clean) && check_config(self.tcx, attr) {
421421
return true;
@@ -434,7 +434,7 @@ impl FindAllAttrs<'tcx> {
434434
}
435435
}
436436

437-
impl intravisit::Visitor<'tcx> for FindAllAttrs<'tcx> {
437+
impl<'tcx> intravisit::Visitor<'tcx> for FindAllAttrs<'tcx> {
438438
type Map = Map<'tcx>;
439439

440440
fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<Self::Map> {

compiler/rustc_lint/src/unused.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,11 @@ trait UnusedDelimLint {
478478

479479
lhs_needs_parens
480480
|| (followed_by_block
481-
&& match inner.kind {
481+
&& match &inner.kind {
482482
ExprKind::Ret(_) | ExprKind::Break(..) | ExprKind::Yield(..) => true,
483+
ExprKind::Range(_lhs, Some(rhs), _limits) => {
484+
matches!(rhs.kind, ExprKind::Block(..))
485+
}
483486
_ => parser::contains_exterior_struct_lit(&inner),
484487
})
485488
}

compiler/rustc_middle/src/ty/layout.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,6 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
347347

348348
let mut inverse_memory_index: Vec<u32> = (0..fields.len() as u32).collect();
349349

350-
// `ReprOptions.layout_seed` is a deterministic seed that we can use to
351-
// randomize field ordering with
352-
let mut rng = Xoshiro128StarStar::seed_from_u64(repr.field_shuffle_seed);
353-
354350
let optimize = !repr.inhibit_struct_field_reordering_opt();
355351
if optimize {
356352
let end =
@@ -364,6 +360,10 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
364360
// the field ordering to try and catch some code making assumptions about layouts
365361
// we don't guarantee
366362
if repr.can_randomize_type_layout() {
363+
// `ReprOptions.layout_seed` is a deterministic seed that we can use to
364+
// randomize field ordering with
365+
let mut rng = Xoshiro128StarStar::seed_from_u64(repr.field_shuffle_seed);
366+
367367
// Shuffle the ordering of the fields
368368
optimizing.shuffle(&mut rng);
369369

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,9 +1608,9 @@ bitflags! {
16081608
// the seed stored in `ReprOptions.layout_seed`
16091609
const RANDOMIZE_LAYOUT = 1 << 5;
16101610
// Any of these flags being set prevent field reordering optimisation.
1611-
const IS_UNOPTIMISABLE = ReprFlags::IS_C.bits |
1612-
ReprFlags::IS_SIMD.bits |
1613-
ReprFlags::IS_LINEAR.bits;
1611+
const IS_UNOPTIMISABLE = ReprFlags::IS_C.bits
1612+
| ReprFlags::IS_SIMD.bits
1613+
| ReprFlags::IS_LINEAR.bits;
16141614
}
16151615
}
16161616

@@ -1640,7 +1640,14 @@ impl ReprOptions {
16401640

16411641
// Generate a deterministically-derived seed from the item's path hash
16421642
// to allow for cross-crate compilation to actually work
1643-
let field_shuffle_seed = tcx.def_path_hash(did).0.to_smaller_hash();
1643+
let mut field_shuffle_seed = tcx.def_path_hash(did).0.to_smaller_hash();
1644+
1645+
// If the user defined a custom seed for layout randomization, xor the item's
1646+
// path hash with the user defined seed, this will allowing determinism while
1647+
// still allowing users to further randomize layout generation for e.g. fuzzing
1648+
if let Some(user_seed) = tcx.sess.opts.debugging_opts.layout_seed {
1649+
field_shuffle_seed ^= user_seed;
1650+
}
16441651

16451652
for attr in tcx.get_attrs(did).iter() {
16461653
for r in attr::find_repr_attrs(&tcx.sess, attr) {

compiler/rustc_session/src/options.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,6 +1321,8 @@ options! {
13211321
"print some statistics about the query system (default: no)"),
13221322
randomize_layout: bool = (false, parse_bool, [TRACKED],
13231323
"randomize the layout of types (default: no)"),
1324+
layout_seed: Option<u64> = (None, parse_opt_number, [TRACKED],
1325+
"seed layout randomization"),
13241326
relax_elf_relocations: Option<bool> = (None, parse_opt_bool, [TRACKED],
13251327
"whether ELF relocations can be relaxed"),
13261328
relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],

library/alloc/src/borrow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ where
170170
/// clone_on_write.values.to_mut().push(3);
171171
/// println!("clone_on_write = {:?}", clone_on_write.values);
172172
///
173-
/// // The data was mutated. Let check it out.
173+
/// // The data was mutated. Let's check it out.
174174
/// match clone_on_write {
175175
/// Items { values: Cow::Owned(_) } => println!("clone_on_write contains owned data"),
176176
/// _ => panic!("expect owned data"),

library/core/src/stream/stream.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ impl<S: ?Sized + Stream + Unpin> Stream for &mut S {
9595
#[unstable(feature = "async_stream", issue = "79024")]
9696
impl<P> Stream for Pin<P>
9797
where
98-
P: DerefMut + Unpin,
98+
P: DerefMut,
9999
P::Target: Stream,
100100
{
101101
type Item = <P::Target as Stream>::Item;
102102

103103
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
104-
self.get_mut().as_mut().poll_next(cx)
104+
<P::Target as Stream>::poll_next(self.as_deref_mut(), cx)
105105
}
106106

107107
fn size_hint(&self) -> (usize, Option<usize>) {

0 commit comments

Comments
 (0)