Skip to content

Commit cdfe74b

Browse files
committed
Make locals field private
1 parent b62d63a commit cdfe74b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: compiler/stable_mir/src/mir/body.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ use crate::{ty::Ty, Span};
77
pub struct Body {
88
pub blocks: Vec<BasicBlock>,
99

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

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

0 commit comments

Comments
 (0)