Skip to content

Commit

Permalink
Make locals field private
Browse files Browse the repository at this point in the history
  • Loading branch information
klinvill committed Oct 25, 2023
1 parent b62d63a commit cdfe74b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions compiler/stable_mir/src/mir/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use crate::{ty::Ty, Span};
pub struct Body {
pub blocks: Vec<BasicBlock>,

/// Declarations of locals.
// Declarations of locals within the function.
//
// The first local is the return value pointer, followed by `arg_count`
// locals for the function arguments, followed by any user-declared
// variables and temporaries.
pub locals: LocalDecls,
locals: LocalDecls,

// The number of arguments this function takes.
arg_count: usize,
Expand All @@ -22,12 +22,12 @@ impl Body {
/// Constructs a `Body`.
///
/// A constructor is required to build a `Body` from outside the crate
/// because the `arg_count` field is private.
/// because the `arg_count` and `locals` fields are private.
pub fn new(blocks: Vec<BasicBlock>, locals: LocalDecls, arg_count: usize) -> Self {
// If locals doesn't contain enough entries, it can lead to panics in
// `ret_local` and `arg_locals`.
// `ret_local`, `arg_locals`, and `internal_locals`.
assert!(
locals.len() >= arg_count + 1,
locals.len() > arg_count,
"A Body must contain at least a local for the return value and each of the function's arguments"
);
Self { blocks, locals, arg_count }
Expand Down

0 comments on commit cdfe74b

Please sign in to comment.