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
This commit is contained in:
commit
df2f45c1d3
27 changed files with 374 additions and 99 deletions
|
@ -103,7 +103,7 @@ struct IfThisChanged<'tcx> {
|
|||
then_this_would_need: Targets,
|
||||
}
|
||||
|
||||
impl IfThisChanged<'tcx> {
|
||||
impl<'tcx> IfThisChanged<'tcx> {
|
||||
fn argument(&self, attr: &ast::Attribute) -> Option<Symbol> {
|
||||
let mut value = None;
|
||||
for list_item in attr.meta_item_list().unwrap_or_default() {
|
||||
|
@ -172,7 +172,7 @@ impl IfThisChanged<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl Visitor<'tcx> for IfThisChanged<'tcx> {
|
||||
impl<'tcx> Visitor<'tcx> for IfThisChanged<'tcx> {
|
||||
type Map = Map<'tcx>;
|
||||
|
||||
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
|
||||
|
|
|
@ -56,7 +56,7 @@ struct AssertModuleSource<'tcx> {
|
|||
available_cgus: BTreeSet<String>,
|
||||
}
|
||||
|
||||
impl AssertModuleSource<'tcx> {
|
||||
impl<'tcx> AssertModuleSource<'tcx> {
|
||||
fn check_attr(&self, attr: &ast::Attribute) {
|
||||
let (expected_reuse, comp_kind) = if attr.has_name(sym::rustc_partition_reused) {
|
||||
(CguReuse::PreLto, ComparisonKind::AtLeast)
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#![deny(missing_docs)]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![feature(let_else)]
|
||||
#![feature(nll)]
|
||||
#![recursion_limit = "256"]
|
||||
|
|
|
@ -155,7 +155,7 @@ pub struct DirtyCleanVisitor<'tcx> {
|
|||
checked_attrs: FxHashSet<ast::AttrId>,
|
||||
}
|
||||
|
||||
impl DirtyCleanVisitor<'tcx> {
|
||||
impl<'tcx> DirtyCleanVisitor<'tcx> {
|
||||
/// Possibly "deserialize" the attribute into a clean/dirty assertion
|
||||
fn assertion_maybe(&mut self, item_id: LocalDefId, attr: &Attribute) -> Option<Assertion> {
|
||||
if !attr.has_name(sym::rustc_clean) {
|
||||
|
@ -352,7 +352,7 @@ impl DirtyCleanVisitor<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl ItemLikeVisitor<'tcx> for DirtyCleanVisitor<'tcx> {
|
||||
impl<'tcx> ItemLikeVisitor<'tcx> for DirtyCleanVisitor<'tcx> {
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
|
||||
self.check_item(item.def_id, item.span);
|
||||
}
|
||||
|
@ -415,7 +415,7 @@ pub struct FindAllAttrs<'tcx> {
|
|||
found_attrs: Vec<&'tcx Attribute>,
|
||||
}
|
||||
|
||||
impl FindAllAttrs<'tcx> {
|
||||
impl<'tcx> FindAllAttrs<'tcx> {
|
||||
fn is_active_attr(&mut self, attr: &Attribute) -> bool {
|
||||
if attr.has_name(sym::rustc_clean) && check_config(self.tcx, attr) {
|
||||
return true;
|
||||
|
@ -434,7 +434,7 @@ impl FindAllAttrs<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl intravisit::Visitor<'tcx> for FindAllAttrs<'tcx> {
|
||||
impl<'tcx> intravisit::Visitor<'tcx> for FindAllAttrs<'tcx> {
|
||||
type Map = Map<'tcx>;
|
||||
|
||||
fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<Self::Map> {
|
||||
|
|
|
@ -478,8 +478,11 @@ trait UnusedDelimLint {
|
|||
|
||||
lhs_needs_parens
|
||||
|| (followed_by_block
|
||||
&& match inner.kind {
|
||||
&& match &inner.kind {
|
||||
ExprKind::Ret(_) | ExprKind::Break(..) | ExprKind::Yield(..) => true,
|
||||
ExprKind::Range(_lhs, Some(rhs), _limits) => {
|
||||
matches!(rhs.kind, ExprKind::Block(..))
|
||||
}
|
||||
_ => parser::contains_exterior_struct_lit(&inner),
|
||||
})
|
||||
}
|
||||
|
|
|
@ -347,10 +347,6 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
|
|||
|
||||
let mut inverse_memory_index: Vec<u32> = (0..fields.len() as u32).collect();
|
||||
|
||||
// `ReprOptions.layout_seed` is a deterministic seed that we can use to
|
||||
// randomize field ordering with
|
||||
let mut rng = Xoshiro128StarStar::seed_from_u64(repr.field_shuffle_seed);
|
||||
|
||||
let optimize = !repr.inhibit_struct_field_reordering_opt();
|
||||
if optimize {
|
||||
let end =
|
||||
|
@ -364,6 +360,10 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
|
|||
// the field ordering to try and catch some code making assumptions about layouts
|
||||
// we don't guarantee
|
||||
if repr.can_randomize_type_layout() {
|
||||
// `ReprOptions.layout_seed` is a deterministic seed that we can use to
|
||||
// randomize field ordering with
|
||||
let mut rng = Xoshiro128StarStar::seed_from_u64(repr.field_shuffle_seed);
|
||||
|
||||
// Shuffle the ordering of the fields
|
||||
optimizing.shuffle(&mut rng);
|
||||
|
||||
|
|
|
@ -1608,9 +1608,9 @@ bitflags! {
|
|||
// the seed stored in `ReprOptions.layout_seed`
|
||||
const RANDOMIZE_LAYOUT = 1 << 5;
|
||||
// Any of these flags being set prevent field reordering optimisation.
|
||||
const IS_UNOPTIMISABLE = ReprFlags::IS_C.bits |
|
||||
ReprFlags::IS_SIMD.bits |
|
||||
ReprFlags::IS_LINEAR.bits;
|
||||
const IS_UNOPTIMISABLE = ReprFlags::IS_C.bits
|
||||
| ReprFlags::IS_SIMD.bits
|
||||
| ReprFlags::IS_LINEAR.bits;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1640,7 +1640,14 @@ impl ReprOptions {
|
|||
|
||||
// Generate a deterministically-derived seed from the item's path hash
|
||||
// to allow for cross-crate compilation to actually work
|
||||
let field_shuffle_seed = tcx.def_path_hash(did).0.to_smaller_hash();
|
||||
let mut field_shuffle_seed = tcx.def_path_hash(did).0.to_smaller_hash();
|
||||
|
||||
// If the user defined a custom seed for layout randomization, xor the item's
|
||||
// path hash with the user defined seed, this will allowing determinism while
|
||||
// still allowing users to further randomize layout generation for e.g. fuzzing
|
||||
if let Some(user_seed) = tcx.sess.opts.debugging_opts.layout_seed {
|
||||
field_shuffle_seed ^= user_seed;
|
||||
}
|
||||
|
||||
for attr in tcx.get_attrs(did).iter() {
|
||||
for r in attr::find_repr_attrs(&tcx.sess, attr) {
|
||||
|
|
|
@ -1321,6 +1321,8 @@ options! {
|
|||
"print some statistics about the query system (default: no)"),
|
||||
randomize_layout: bool = (false, parse_bool, [TRACKED],
|
||||
"randomize the layout of types (default: no)"),
|
||||
layout_seed: Option<u64> = (None, parse_opt_number, [TRACKED],
|
||||
"seed layout randomization"),
|
||||
relax_elf_relocations: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
||||
"whether ELF relocations can be relaxed"),
|
||||
relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue