Skip to content

Commit 2f77212

Browse files
author
Cameron Zwarich
committed
Remove comments that no longer apply after the removal of const
1 parent 8a5c5b6 commit 2f77212

File tree

1 file changed

+4
-38
lines changed

1 file changed

+4
-38
lines changed

src/librustc/middle/borrowck/check_loans.rs

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -829,28 +829,8 @@ impl<'a> CheckLoanCtxt<'a> {
829829
// let p = &v;
830830
// v = ~[4];
831831
//
832-
// In this case, creating `p` triggers a RESTR_MUTATE
833-
// restriction on the path `v`.
834-
//
835-
// Here is a second, more subtle example:
836-
//
837-
// let mut v = ~[1, 2, 3];
838-
// let p = &const v[0];
839-
// v[0] = 4; // OK
840-
// v[1] = 5; // OK
841-
// v = ~[4, 5, 3]; // Error
842-
//
843-
// In this case, `p` is pointing to `v[0]`, and it is a
844-
// `const` pointer in any case. So the first two
845-
// assignments are legal (and would be permitted by this
846-
// check). However, the final assignment (which is
847-
// logically equivalent) is forbidden, because it would
848-
// cause the existing `v` array to be freed, thus
849-
// invalidating `p`. In the code, this error results
850-
// because `gather_loans::restrictions` adds a
851-
// `RESTR_MUTATE` restriction whenever the contents of an
852-
// owned pointer are borrowed, and hence while `v[*]` is not
853-
// restricted from being written, `v` is.
832+
// In this case, creating `p` restricts the mutation of `v`.
833+
854834
let cont = this.each_in_scope_restriction(assignment_id,
855835
&*loan_path,
856836
|loan, restr| {
@@ -882,28 +862,14 @@ impl<'a> CheckLoanCtxt<'a> {
882862
//
883863
// So in this loop, we walk back up the loan path so long
884864
// as the mutability of the path is dependent on a super
885-
// path, and check that the super path was not lent out as
886-
// mutable or immutable (a const loan is ok).
865+
// path, and check that the super path was not borrowed.
887866
//
888867
// Mutability of a path can be dependent on the super path
889868
// in two ways. First, it might be inherited mutability.
890869
// Second, the pointee of an `&mut` pointer can only be
891870
// mutated if it is found in an unaliased location, so we
892871
// have to check that the owner location is not borrowed.
893-
//
894-
// Note that we are *not* checking for any and all
895-
// restrictions. We are only interested in the pointers
896-
// that the user created, whereas we add restrictions for
897-
// all kinds of paths that are not directly aliased. If we checked
898-
// for all restrictions, and not just loans, then the following
899-
// valid program would be considered illegal:
900-
//
901-
// let mut v = ~[1, 2, 3];
902-
// let p = &const v[0];
903-
// v[1] = 5; // ok
904-
//
905-
// Here the restriction that `v` not be mutated would be misapplied
906-
// to block the subpath `v[1]`.
872+
907873
let full_loan_path = loan_path.clone();
908874
let mut loan_path = loan_path;
909875
loop {

0 commit comments

Comments
 (0)