File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
compiler/stable_mir/src/mir Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -465,10 +465,20 @@ impl Location {
465465 }
466466}
467467
468- impl From < Span > for Location {
469- fn from ( span : Span ) -> Self {
470- Location ( span)
471- }
468+ /// Location of the statement at the given index for a given basic block. Assumes that `stmt_idx`
469+ /// and `bb_idx` are valid for a given body.
470+ pub fn statement_location ( body : & Body , bb_idx : & BasicBlockIdx , stmt_idx : usize ) -> Location {
471+ let bb = & body. blocks [ * bb_idx] ;
472+ let stmt = & bb. statements [ stmt_idx] ;
473+ Location ( stmt. span )
474+ }
475+
476+ /// Location of the terminator for a given basic block. Assumes that `bb_idx` is valid for a given
477+ /// body.
478+ pub fn terminator_location ( body : & Body , bb_idx : & BasicBlockIdx ) -> Location {
479+ let bb = & body. blocks [ * bb_idx] ;
480+ let terminator = & bb. terminator ;
481+ Location ( terminator. span )
472482}
473483
474484/// Reference to a place used to represent a partial projection.
You can’t perform that action at this time.
0 commit comments