Skip to content

Commit 2a11b3b

Browse files
committed
---
yaml --- r: 151085 b: refs/heads/try2 c: d10735e h: refs/heads/master i: 151083: 6719f7e v: v3
1 parent 0a2eb2e commit 2a11b3b

File tree

4 files changed

+11
-71
lines changed

4 files changed

+11
-71
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: e80089576ecc853996a5098df0883d649db4845d
8+
refs/heads/try2: d10735e3840b1bfcd52bf063258bc5db0c6e2a66
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/borrowck/gather_loans/lifetime.rs

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ struct GuaranteeLifetimeContext<'a> {
6565
}
6666

6767
impl<'a> GuaranteeLifetimeContext<'a> {
68-
fn tcx(&self) -> &'a ty::ctxt {
69-
self.bccx.tcx
70-
}
7168

7269
fn check(&self, cmt: &mc::cmt, discr_scope: Option<ast::NodeId>) -> R {
7370
//! Main routine. Walks down `cmt` until we find the "guarantor".
@@ -90,29 +87,10 @@ impl<'a> GuaranteeLifetimeContext<'a> {
9087
Ok(())
9188
}
9289

93-
mc::cat_deref(ref base, _, mc::GcPtr) => {
94-
let base_scope = self.scope(base);
95-
96-
// L-Deref-Managed-Imm-User-Root
97-
let omit_root =
98-
self.bccx.is_subregion_of(self.loan_region, base_scope) &&
99-
self.is_rvalue_or_immutable(base) &&
100-
!self.is_moved(base);
101-
102-
if !omit_root {
103-
// L-Deref-Managed-Imm-Compiler-Root
104-
// L-Deref-Managed-Mut-Compiler-Root
105-
Err(())
106-
} else {
107-
debug!("omitting root, base={}, base_scope={:?}",
108-
base.repr(self.tcx()), base_scope);
109-
Ok(())
110-
}
111-
}
112-
11390
mc::cat_downcast(ref base) |
11491
mc::cat_deref(ref base, _, mc::OwnedPtr) | // L-Deref-Send
115-
mc::cat_interior(ref base, _) => { // L-Field
92+
mc::cat_interior(ref base, _) | // L-Field
93+
mc::cat_deref(ref base, _, mc::GcPtr) => {
11694
self.check(base, discr_scope)
11795
}
11896

@@ -174,19 +152,6 @@ impl<'a> GuaranteeLifetimeContext<'a> {
174152
}
175153
}
176154

177-
fn is_rvalue_or_immutable(&self,
178-
cmt: &mc::cmt) -> bool {
179-
//! We can omit the root on an `@T` value if the location
180-
//! that holds the box is either (1) an rvalue, in which case
181-
//! it is in a non-user-accessible temporary, or (2) an immutable
182-
//! lvalue.
183-
184-
cmt.mutbl.is_immutable() || match cmt.guarantor().cat {
185-
mc::cat_rvalue(..) => true,
186-
_ => false
187-
}
188-
}
189-
190155
fn check_scope(&self, max_scope: ty::Region) -> R {
191156
//! Reports an error if `loan_region` is larger than `valid_scope`
192157
@@ -197,32 +162,6 @@ impl<'a> GuaranteeLifetimeContext<'a> {
197162
}
198163
}
199164

200-
fn is_moved(&self, cmt: &mc::cmt) -> bool {
201-
//! True if `cmt` is something that is potentially moved
202-
//! out of the current stack frame.
203-
204-
match cmt.guarantor().cat {
205-
mc::cat_local(id) |
206-
mc::cat_arg(id) => {
207-
self.bccx.moved_variables_set.contains(&id)
208-
}
209-
mc::cat_rvalue(..) |
210-
mc::cat_static_item |
211-
mc::cat_copied_upvar(..) |
212-
mc::cat_deref(..) |
213-
mc::cat_upvar(..) => {
214-
false
215-
}
216-
ref r @ mc::cat_downcast(..) |
217-
ref r @ mc::cat_interior(..) |
218-
ref r @ mc::cat_discr(..) => {
219-
self.tcx().sess.span_bug(
220-
cmt.span,
221-
format!("illegal guarantor category: {:?}", r));
222-
}
223-
}
224-
}
225-
226165
fn scope(&self, cmt: &mc::cmt) -> ty::Region {
227166
//! Returns the maximal region scope for the which the
228167
//! lvalue `cmt` is guaranteed to be valid without any

branches/try2/src/librustc/middle/borrowck/gather_loans/restrictions.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,18 @@ impl<'a> RestrictionsContext<'a> {
101101
self.extend(result, cmt.mutbl, LpInterior(i), restrictions)
102102
}
103103

104-
mc::cat_deref(cmt_base, _, pk @ mc::OwnedPtr) => {
104+
mc::cat_deref(cmt_base, _, pk @ mc::OwnedPtr) |
105+
mc::cat_deref(cmt_base, _, pk @ mc::GcPtr) => {
105106
// R-Deref-Send-Pointer
106107
//
107108
// When we borrow the interior of an owned pointer, we
108109
// cannot permit the base to be mutated, because that
109110
// would cause the unique pointer to be freed.
111+
//
112+
// For a managed pointer, the rules are basically the
113+
// same, because this could be the last ref.
114+
// Eventually we should make these non-special and
115+
// just rely on Deref<T> implementation.
110116
let result = self.restrict(
111117
cmt_base,
112118
restrictions | RESTR_MUTATE);
@@ -134,11 +140,6 @@ impl<'a> RestrictionsContext<'a> {
134140
Safe
135141
}
136142

137-
mc::cat_deref(_, _, mc::GcPtr) => {
138-
// R-Deref-Imm-Managed
139-
Safe
140-
}
141-
142143
mc::cat_deref(cmt_base, _, pk @ mc::BorrowedPtr(ty::MutBorrow, lt)) => {
143144
// R-Deref-Mut-Borrowed
144145
if !self.bccx.is_subregion_of(self.loan_region, lt) {

branches/try2/src/librustc/middle/typeck/check/regionck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1263,12 +1263,12 @@ fn link_region(rcx: &Rcx,
12631263
}
12641264
mc::cat_discr(cmt_base, _) |
12651265
mc::cat_downcast(cmt_base) |
1266+
mc::cat_deref(cmt_base, _, mc::GcPtr(..)) |
12661267
mc::cat_deref(cmt_base, _, mc::OwnedPtr) |
12671268
mc::cat_interior(cmt_base, _) => {
12681269
// Interior or owned data requires its base to be valid
12691270
cmt_borrowed = cmt_base;
12701271
}
1271-
mc::cat_deref(_, _, mc::GcPtr(..)) |
12721272
mc::cat_deref(_, _, mc::UnsafePtr(..)) |
12731273
mc::cat_static_item |
12741274
mc::cat_copied_upvar(..) |

0 commit comments

Comments
 (0)