Skip to content

Commit 07108f9

Browse files
committed
Derive traversable impls for BindingForm
BindingForm has been a no-op traversable ever since it was first added in cac6126, but it was modified in 0193d1f to (optionally) contain a Place without its implementations being updated to fold/visit such. By using the derive macro to implement the visitable traits, we ensure that all contained types of interest are folded/visited.
1 parent 3020cbd commit 07108f9

File tree

1 file changed

+7
-3
lines changed
  • compiler/rustc_middle/src/mir

1 file changed

+7
-3
lines changed

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ pub enum LocalKind {
759759
ReturnPointer,
760760
}
761761

762-
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable)]
762+
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
763763
pub struct VarBindingForm<'tcx> {
764764
/// Is variable bound via `x`, `mut x`, `ref x`, or `ref mut x`?
765765
pub binding_mode: ty::BindingMode,
@@ -776,12 +776,16 @@ pub struct VarBindingForm<'tcx> {
776776
/// (a) the right-hand side isn't evaluated as a place expression.
777777
/// (b) it gives a way to separate this case from the remaining cases
778778
/// for diagnostics.
779+
// FIXME: provide actual justification for `#[skip_traversal]`, or else remove
780+
#[skip_traversal(
781+
despite_potential_miscompilation_because = "potential oversight since 0193d1f"
782+
)]
779783
pub opt_match_place: Option<(Option<Place<'tcx>>, Span)>,
780784
/// The span of the pattern in which this variable was bound.
781785
pub pat_span: Span,
782786
}
783787

784-
#[derive(Clone, Debug, TyEncodable, TyDecodable)]
788+
#[derive(Clone, Debug, TyEncodable, TyDecodable, TypeFoldable, TypeVisitable)]
785789
pub enum BindingForm<'tcx> {
786790
/// This is a binding for a non-`self` binding, or a `self` that has an explicit type.
787791
Var(VarBindingForm<'tcx>),
@@ -791,7 +795,7 @@ pub enum BindingForm<'tcx> {
791795
RefForGuard,
792796
}
793797

794-
TrivialTypeTraversalImpls! { BindingForm<'tcx> }
798+
TrivialLiftImpls! { BindingForm<'tcx> }
795799

796800
mod binding_form_impl {
797801
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};

0 commit comments

Comments
 (0)