safe transmute: tweak tracing
ref: https://github.com/rust-lang/rust/pull/92268#discussion_r925246903 ref: https://github.com/rust-lang/rust/pull/92268#discussion_r925250811 ref: https://github.com/rust-lang/rust/pull/92268#discussion_r925255782
This commit is contained in:
parent
0fa70c3b12
commit
c0d0ce95eb
5 changed files with 16 additions and 21 deletions
|
@ -103,7 +103,7 @@ where
|
||||||
Self { transitions, start, accepting }
|
Self { transitions, start, accepting }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument]
|
#[instrument(level = "DEBUG")]
|
||||||
#[cfg_attr(feature = "rustc", allow(rustc::potential_query_instability))]
|
#[cfg_attr(feature = "rustc", allow(rustc::potential_query_instability))]
|
||||||
pub(crate) fn from_nfa(nfa: Nfa<R>) -> Self {
|
pub(crate) fn from_nfa(nfa: Nfa<R>) -> Self {
|
||||||
let Nfa { transitions: nfa_transitions, start: nfa_start, accepting: nfa_accepting } = nfa;
|
let Nfa { transitions: nfa_transitions, start: nfa_start, accepting: nfa_accepting } = nfa;
|
||||||
|
|
|
@ -76,7 +76,6 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A `Tree` whose layout is entirely padding of the given width.
|
/// A `Tree` whose layout is entirely padding of the given width.
|
||||||
#[tracing::instrument]
|
|
||||||
pub(crate) fn padding(width_in_bytes: usize) -> Self {
|
pub(crate) fn padding(width_in_bytes: usize) -> Self {
|
||||||
Self::Seq(vec![Self::uninit(); width_in_bytes])
|
Self::Seq(vec![Self::uninit(); width_in_bytes])
|
||||||
}
|
}
|
||||||
|
@ -316,10 +315,7 @@ pub(crate) mod rustc {
|
||||||
tcx,
|
tcx,
|
||||||
)?,
|
)?,
|
||||||
AdtKind::Enum => {
|
AdtKind::Enum => {
|
||||||
tracing::trace!(
|
tracing::trace!(?adt_def, "treeifying enum");
|
||||||
adt_def = ?adt_def,
|
|
||||||
"treeifying enum"
|
|
||||||
);
|
|
||||||
let mut tree = Tree::uninhabited();
|
let mut tree = Tree::uninhabited();
|
||||||
|
|
||||||
for (idx, discr) in adt_def.discriminants(tcx) {
|
for (idx, discr) in adt_def.discriminants(tcx) {
|
||||||
|
@ -398,13 +394,13 @@ pub(crate) mod rustc {
|
||||||
|
|
||||||
// The layout of the variant is prefixed by the discriminant, if any.
|
// The layout of the variant is prefixed by the discriminant, if any.
|
||||||
if let Some(discr) = discr {
|
if let Some(discr) = discr {
|
||||||
tracing::trace!(discr = ?discr, "treeifying discriminant");
|
tracing::trace!(?discr, "treeifying discriminant");
|
||||||
let discr_layout = alloc::Layout::from_size_align(
|
let discr_layout = alloc::Layout::from_size_align(
|
||||||
layout_summary.discriminant_size,
|
layout_summary.discriminant_size,
|
||||||
clamp(layout_summary.discriminant_align),
|
clamp(layout_summary.discriminant_align),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
tracing::trace!(discr_layout = ?discr_layout, "computed discriminant layout");
|
tracing::trace!(?discr_layout, "computed discriminant layout");
|
||||||
variant_layout = variant_layout.extend(discr_layout).unwrap().0;
|
variant_layout = variant_layout.extend(discr_layout).unwrap().0;
|
||||||
tree = tree.then(Self::from_disr(discr, tcx, layout_summary.discriminant_size));
|
tree = tree.then(Self::from_disr(discr, tcx, layout_summary.discriminant_size));
|
||||||
}
|
}
|
||||||
|
@ -469,11 +465,7 @@ pub(crate) mod rustc {
|
||||||
layout.align().abi.bytes().try_into().unwrap(),
|
layout.align().abi.bytes().try_into().unwrap(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
tracing::trace!(
|
tracing::trace!(?ty, ?layout, "computed layout for type");
|
||||||
ty = ?ty,
|
|
||||||
layout = ?layout,
|
|
||||||
"computed layout for type"
|
|
||||||
);
|
|
||||||
Ok(layout)
|
Ok(layout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,9 @@
|
||||||
)]
|
)]
|
||||||
#![allow(dead_code, unused_variables)]
|
#![allow(dead_code, unused_variables)]
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
extern crate tracing;
|
||||||
|
|
||||||
#[cfg(feature = "rustc")]
|
#[cfg(feature = "rustc")]
|
||||||
pub(crate) use rustc_data_structures::fx::{FxHashMap as Map, FxHashSet as Set};
|
pub(crate) use rustc_data_structures::fx::{FxHashMap as Map, FxHashSet as Set};
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ mod rustc {
|
||||||
impl<'tcx> MaybeTransmutableQuery<Ty<'tcx>, TyCtxt<'tcx>> {
|
impl<'tcx> MaybeTransmutableQuery<Ty<'tcx>, TyCtxt<'tcx>> {
|
||||||
/// This method begins by converting `src` and `dst` from `Ty`s to `Tree`s,
|
/// This method begins by converting `src` and `dst` from `Ty`s to `Tree`s,
|
||||||
/// then computes an answer using those trees.
|
/// then computes an answer using those trees.
|
||||||
#[tracing::instrument(skip(self), fields(src = ?self.src, dst = ?self.dst))]
|
#[instrument(level = "DEBUG", skip(self), fields(src = ?self.src, dst = ?self.dst))]
|
||||||
pub fn answer(self) -> Answer<<TyCtxt<'tcx> as QueryContext>::Ref> {
|
pub fn answer(self) -> Answer<<TyCtxt<'tcx> as QueryContext>::Ref> {
|
||||||
let query_or_answer = self.map_layouts(|src, dst, scope, &context| {
|
let query_or_answer = self.map_layouts(|src, dst, scope, &context| {
|
||||||
// Convert `src` and `dst` from their rustc representations, to `Tree`-based
|
// Convert `src` and `dst` from their rustc representations, to `Tree`-based
|
||||||
|
@ -103,14 +103,14 @@ where
|
||||||
/// This method begins by de-def'ing `src` and `dst`, and prunes private paths from `dst`,
|
/// This method begins by de-def'ing `src` and `dst`, and prunes private paths from `dst`,
|
||||||
/// then converts `src` and `dst` to `Nfa`s, and computes an answer using those NFAs.
|
/// then converts `src` and `dst` to `Nfa`s, and computes an answer using those NFAs.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[tracing::instrument(skip(self), fields(src = ?self.src, dst = ?self.dst))]
|
#[instrument(level = "DEBUG", skip(self), fields(src = ?self.src, dst = ?self.dst))]
|
||||||
pub(crate) fn answer(self) -> Answer<<C as QueryContext>::Ref> {
|
pub(crate) fn answer(self) -> Answer<<C as QueryContext>::Ref> {
|
||||||
let assume_visibility = self.assume.visibility;
|
let assume_visibility = self.assume.visibility;
|
||||||
let query_or_answer = self.map_layouts(|src, dst, scope, context| {
|
let query_or_answer = self.map_layouts(|src, dst, scope, context| {
|
||||||
// Remove all `Def` nodes from `src`, without checking their visibility.
|
// Remove all `Def` nodes from `src`, without checking their visibility.
|
||||||
let src = src.prune(&|def| true);
|
let src = src.prune(&|def| true);
|
||||||
|
|
||||||
tracing::trace!(src = ?src, "pruned src");
|
tracing::trace!(?src, "pruned src");
|
||||||
|
|
||||||
// Remove all `Def` nodes from `dst`, additionally...
|
// Remove all `Def` nodes from `dst`, additionally...
|
||||||
let dst = if assume_visibility {
|
let dst = if assume_visibility {
|
||||||
|
@ -121,7 +121,7 @@ where
|
||||||
dst.prune(&|def| context.is_accessible_from(def, scope))
|
dst.prune(&|def| context.is_accessible_from(def, scope))
|
||||||
};
|
};
|
||||||
|
|
||||||
tracing::trace!(dst = ?dst, "pruned dst");
|
tracing::trace!(?dst, "pruned dst");
|
||||||
|
|
||||||
// Convert `src` from a tree-based representation to an NFA-based representation.
|
// Convert `src` from a tree-based representation to an NFA-based representation.
|
||||||
// If the conversion fails because `src` is uninhabited, conclude that the transmutation
|
// If the conversion fails because `src` is uninhabited, conclude that the transmutation
|
||||||
|
@ -152,7 +152,7 @@ where
|
||||||
///
|
///
|
||||||
/// This method converts `src` and `dst` to DFAs, then computes an answer using those DFAs.
|
/// This method converts `src` and `dst` to DFAs, then computes an answer using those DFAs.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[tracing::instrument(skip(self), fields(src = ?self.src, dst = ?self.dst))]
|
#[instrument(level = "DEBUG", skip(self), fields(src = ?self.src, dst = ?self.dst))]
|
||||||
pub(crate) fn answer(self) -> Answer<<C as QueryContext>::Ref> {
|
pub(crate) fn answer(self) -> Answer<<C as QueryContext>::Ref> {
|
||||||
let query_or_answer = self
|
let query_or_answer = self
|
||||||
.map_layouts(|src, dst, scope, context| Ok((Dfa::from_nfa(src), Dfa::from_nfa(dst))));
|
.map_layouts(|src, dst, scope, context| Ok((Dfa::from_nfa(src), Dfa::from_nfa(dst))));
|
||||||
|
@ -192,7 +192,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[tracing::instrument(skip(self))]
|
#[instrument(level = "DEBUG", skip(self))]
|
||||||
fn answer_memo(
|
fn answer_memo(
|
||||||
&self,
|
&self,
|
||||||
cache: &mut Map<(dfa::State, dfa::State), Answer<<C as QueryContext>::Ref>>,
|
cache: &mut Map<(dfa::State, dfa::State), Answer<<C as QueryContext>::Ref>>,
|
||||||
|
|
|
@ -52,7 +52,7 @@ mod rustc {
|
||||||
|
|
||||||
type Scope = Ty<'tcx>;
|
type Scope = Ty<'tcx>;
|
||||||
|
|
||||||
#[tracing::instrument(skip(self))]
|
#[instrument(level = "DEBUG", skip(self))]
|
||||||
fn is_accessible_from(&self, def: Self::Def, scope: Self::Scope) -> bool {
|
fn is_accessible_from(&self, def: Self::Def, scope: Self::Scope) -> bool {
|
||||||
use layout::rustc::Def;
|
use layout::rustc::Def;
|
||||||
use rustc_middle::ty;
|
use rustc_middle::ty;
|
||||||
|
@ -82,7 +82,7 @@ mod rustc {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
|
|
||||||
tracing::trace!(ret = ?ret, "ret");
|
tracing::trace!(?ret, "ret");
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue