From 17d40c6057c88f4c432b0d7bac88e1b84cb7e67f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:03:36 +0200 Subject: Adding upstream version 1.65.0+dfsg1. Signed-off-by: Daniel Baumann --- compiler/rustc_transmute/src/layout/dfa.rs | 1 - compiler/rustc_transmute/src/layout/nfa.rs | 6 ----- compiler/rustc_transmute/src/layout/tree.rs | 36 +++++++++++++++-------------- 3 files changed, 19 insertions(+), 24 deletions(-) (limited to 'compiler/rustc_transmute/src/layout') diff --git a/compiler/rustc_transmute/src/layout/dfa.rs b/compiler/rustc_transmute/src/layout/dfa.rs index b60ea6e7a..b8922696e 100644 --- a/compiler/rustc_transmute/src/layout/dfa.rs +++ b/compiler/rustc_transmute/src/layout/dfa.rs @@ -104,7 +104,6 @@ where } #[instrument(level = "debug")] - #[cfg_attr(feature = "rustc", allow(rustc::potential_query_instability))] pub(crate) fn from_nfa(nfa: Nfa) -> Self { let Nfa { transitions: nfa_transitions, start: nfa_start, accepting: nfa_accepting } = nfa; diff --git a/compiler/rustc_transmute/src/layout/nfa.rs b/compiler/rustc_transmute/src/layout/nfa.rs index f25e3c1fd..c2bc47bc0 100644 --- a/compiler/rustc_transmute/src/layout/nfa.rs +++ b/compiler/rustc_transmute/src/layout/nfa.rs @@ -119,8 +119,6 @@ where let mut transitions: Map, Set>> = self.transitions; - // the iteration order doesn't matter - #[cfg_attr(feature = "rustc", allow(rustc::potential_query_instability))] for (source, transition) in other.transitions { let fix_state = |state| if state == other.start { self.accepting } else { state }; let entry = transitions.entry(fix_state(source)).or_default(); @@ -142,8 +140,6 @@ where let mut transitions: Map, Set>> = self.transitions.clone(); - // the iteration order doesn't matter - #[cfg_attr(feature = "rustc", allow(rustc::potential_query_instability))] for (&(mut source), transition) in other.transitions.iter() { // if source is starting state of `other`, replace with starting state of `self` if source == other.start { @@ -152,8 +148,6 @@ where let entry = transitions.entry(source).or_default(); for (edge, destinations) in transition { let entry = entry.entry(edge.clone()).or_default(); - // the iteration order doesn't matter - #[cfg_attr(feature = "rustc", allow(rustc::potential_query_instability))] for &(mut destination) in destinations { // if dest is accepting state of `other`, replace with accepting state of `self` if destination == other.accepting { diff --git a/compiler/rustc_transmute/src/layout/tree.rs b/compiler/rustc_transmute/src/layout/tree.rs index 70b3ba02b..211c813b8 100644 --- a/compiler/rustc_transmute/src/layout/tree.rs +++ b/compiler/rustc_transmute/src/layout/tree.rs @@ -1,4 +1,5 @@ use super::{Byte, Def, Ref}; +use std::ops::ControlFlow; #[cfg(test)] mod tests; @@ -86,17 +87,18 @@ where F: Fn(D) -> bool, { match self { - Self::Seq(elts) => elts - .into_iter() - .map(|elt| elt.prune(f)) - .try_fold(Tree::unit(), |elts, elt| { + Self::Seq(elts) => match elts.into_iter().map(|elt| elt.prune(f)).try_fold( + Tree::unit(), + |elts, elt| { if elt == Tree::uninhabited() { - Err(Tree::uninhabited()) + ControlFlow::Break(Tree::uninhabited()) } else { - Ok(elts.then(elt)) + ControlFlow::Continue(elts.then(elt)) } - }) - .into_ok_or_err(), + }, + ) { + ControlFlow::Break(node) | ControlFlow::Continue(node) => node, + }, Self::Alt(alts) => alts .into_iter() .map(|alt| alt.prune(f)) @@ -315,7 +317,7 @@ pub(crate) mod rustc { tcx, )?, AdtKind::Enum => { - tracing::trace!(?adt_def, "treeifying enum"); + trace!(?adt_def, "treeifying enum"); let mut tree = Tree::uninhabited(); for (idx, discr) in adt_def.discriminants(tcx) { @@ -379,7 +381,7 @@ pub(crate) mod rustc { let clamp = |align: Align| align.clamp(min_align, max_align).bytes().try_into().unwrap(); - let variant_span = tracing::trace_span!( + let variant_span = trace_span!( "treeifying variant", min_align = ?min_align, max_align = ?max_align, @@ -394,27 +396,27 @@ pub(crate) mod rustc { // The layout of the variant is prefixed by the discriminant, if any. if let Some(discr) = discr { - tracing::trace!(?discr, "treeifying discriminant"); + trace!(?discr, "treeifying discriminant"); let discr_layout = alloc::Layout::from_size_align( layout_summary.discriminant_size, clamp(layout_summary.discriminant_align), ) .unwrap(); - tracing::trace!(?discr_layout, "computed discriminant layout"); + trace!(?discr_layout, "computed discriminant layout"); variant_layout = variant_layout.extend(discr_layout).unwrap().0; tree = tree.then(Self::from_disr(discr, tcx, layout_summary.discriminant_size)); } // Next come fields. - let fields_span = tracing::trace_span!("treeifying fields").entered(); + let fields_span = trace_span!("treeifying fields").entered(); for field_def in variant_def.fields.iter() { let field_ty = field_def.ty(tcx, substs_ref); - let _span = tracing::trace_span!("treeifying field", field = ?field_ty).entered(); + let _span = trace_span!("treeifying field", field = ?field_ty).entered(); // begin with the field's visibility tree = tree.then(Self::def(Def::Field(field_def))); - // compute the field's layout charactaristics + // compute the field's layout characteristics let field_layout = layout_of(tcx, field_ty)?.clamp_align(min_align, max_align); // next comes the field's padding @@ -432,7 +434,7 @@ pub(crate) mod rustc { drop(fields_span); // finally: padding - let padding_span = tracing::trace_span!("adding trailing padding").entered(); + let padding_span = trace_span!("adding trailing padding").entered(); let padding_needed = layout_summary.total_size - variant_layout.size(); if padding_needed > 0 { tree = tree.then(Self::padding(padding_needed)); @@ -465,7 +467,7 @@ pub(crate) mod rustc { layout.align().abi.bytes().try_into().unwrap(), ) .unwrap(); - tracing::trace!(?ty, ?layout, "computed layout for type"); + trace!(?ty, ?layout, "computed layout for type"); Ok(layout) } } -- cgit v1.2.3