1
Fork 0

Remove MirVisitable.

The `MirVisitable` trait is just a complicated way to visit either a
statement or a terminator. (And its impl for `Terminator` is unused.) It
has a single use.

This commit removes it, replacing it with an if/else, which is shorter
and simpler.
This commit is contained in:
Nicholas Nethercote 2025-02-19 15:52:05 +11:00
parent cee430b2ce
commit 311e8d3e5d
3 changed files with 18 additions and 43 deletions

View file

@ -32,7 +32,6 @@ use tracing::{debug, trace};
pub use self::query::*;
use self::visit::TyContext;
use crate::mir::interpret::{AllocRange, Scalar};
use crate::mir::visit::MirVisitable;
use crate::ty::codec::{TyDecoder, TyEncoder};
use crate::ty::print::{FmtPrinter, Printer, pretty_print_const, with_no_trimmed_paths};
use crate::ty::visit::TypeVisitableExt;
@ -1364,10 +1363,6 @@ impl<'tcx> BasicBlockData<'tcx> {
self.terminator.as_mut().expect("invalid terminator state")
}
pub fn visitable(&self, index: usize) -> &dyn MirVisitable<'tcx> {
if index < self.statements.len() { &self.statements[index] } else { &self.terminator }
}
/// Does the block have no statements and an unreachable terminator?
#[inline]
pub fn is_empty_unreachable(&self) -> bool {