Skip to content

Commit 53bf6f2

Browse files
committed
---
yaml --- r: 93027 b: refs/heads/auto c: 8828129 h: refs/heads/master i: 93025: 2757283 93023: 2b40b59 v: v3
1 parent 90f3028 commit 53bf6f2

33 files changed

+172
-464
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 9b35ae75d2e275e6dbc4b93061f7b16c4efb5b19
16+
refs/heads/auto: 88281290ffdf79d1c3700935a3116fb1a22f458f
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustc/driver/driver.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ pub fn phase_3_run_analysis_passes(sess: Session,
295295
middle::liveness::check_crate(ty_cx, method_map,
296296
capture_map, crate));
297297

298-
let (root_map, write_guard_map) =
298+
let root_map =
299299
time(time_passes, "borrow checking", (), |_|
300300
middle::borrowck::check_crate(ty_cx, method_map,
301301
moves_map, moved_variables_set,
@@ -330,7 +330,6 @@ pub fn phase_3_run_analysis_passes(sess: Session,
330330
root_map: root_map,
331331
method_map: method_map,
332332
vtable_map: vtable_map,
333-
write_guard_map: write_guard_map,
334333
capture_map: capture_map
335334
},
336335
reachable: reachable_map

branches/auto/src/librustc/metadata/tydecode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t {
342342
let did = parse_def(st, TypeParameter, |x,y| conv(x,y));
343343
return ty::mk_self(st.tcx, did);
344344
}
345-
'@' => return ty::mk_box(st.tcx, parse_mt(st, |x,y| conv(x,y))),
345+
'@' => return ty::mk_box(st.tcx, parse_ty(st, |x,y| conv(x,y))),
346346
'~' => return ty::mk_uniq(st.tcx, parse_mt(st, |x,y| conv(x,y))),
347347
'*' => return ty::mk_ptr(st.tcx, parse_mt(st, |x,y| conv(x,y))),
348348
'&' => {

branches/auto/src/librustc/metadata/tyencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ fn enc_sty(w: &mut MemWriter, cx: @ctxt, st: &ty::sty) {
292292
for t in ts.iter() { enc_ty(w, cx, *t); }
293293
mywrite!(w, "]");
294294
}
295-
ty::ty_box(mt) => { mywrite!(w, "@"); enc_mt(w, cx, mt); }
295+
ty::ty_box(typ) => { mywrite!(w, "@"); enc_ty(w, cx, typ); }
296296
ty::ty_uniq(mt) => { mywrite!(w, "~"); enc_mt(w, cx, mt); }
297297
ty::ty_ptr(mt) => { mywrite!(w, "*"); enc_mt(w, cx, mt); }
298298
ty::ty_rptr(r, mt) => {

branches/auto/src/librustc/middle/astencode.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ pub struct Maps {
5555
root_map: middle::borrowck::root_map,
5656
method_map: middle::typeck::method_map,
5757
vtable_map: middle::typeck::vtable_map,
58-
write_guard_map: middle::borrowck::write_guard_map,
5958
capture_map: middle::moves::CaptureMap,
6059
}
6160

branches/auto/src/librustc/middle/borrowck/check_loans.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,15 @@ impl<'a> CheckLoanCtxt<'a> {
368368
cmt = b;
369369
}
370370

371+
mc::cat_deref(_, _, mc::gc_ptr) => {
372+
assert_eq!(cmt.mutbl, mc::McImmutable);
373+
return;
374+
}
375+
371376
mc::cat_rvalue(..) |
372377
mc::cat_static_item |
373378
mc::cat_copied_upvar(..) |
374379
mc::cat_deref(_, _, mc::unsafe_ptr(..)) |
375-
mc::cat_deref(_, _, mc::gc_ptr(..)) |
376380
mc::cat_deref(_, _, mc::region_ptr(..)) => {
377381
assert_eq!(cmt.mutbl, mc::McDeclared);
378382
return;
@@ -411,20 +415,6 @@ impl<'a> CheckLoanCtxt<'a> {
411415
check_for_aliasability_violation(this, expr, b);
412416
}
413417

414-
mc::cat_deref(_, deref_count, mc::gc_ptr(ast::MutMutable)) => {
415-
// Dynamically check writes to `@mut`
416-
417-
let key = root_map_key {
418-
id: guarantor.id,
419-
derefs: deref_count
420-
};
421-
debug!("Inserting write guard at {:?}", key);
422-
let mut write_guard_map = this.bccx
423-
.write_guard_map
424-
.borrow_mut();
425-
write_guard_map.get().insert(key);
426-
}
427-
428418
_ => {}
429419
}
430420

@@ -455,7 +445,7 @@ impl<'a> CheckLoanCtxt<'a> {
455445
mc::cat_self(..) |
456446
mc::cat_deref(_, _, mc::unsafe_ptr(..)) |
457447
mc::cat_static_item(..) |
458-
mc::cat_deref(_, _, mc::gc_ptr(_)) |
448+
mc::cat_deref(_, _, mc::gc_ptr) |
459449
mc::cat_deref(_, _, mc::region_ptr(MutImmutable, _)) => {
460450
// Aliasability is independent of base cmt
461451
match cmt.freely_aliasable() {

branches/auto/src/librustc/middle/borrowck/gather_loans/gather_moves.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ fn check_is_legal_to_move_from(bccx: &BorrowckCtxt,
102102
cmt: mc::cmt) -> bool {
103103
match cmt.cat {
104104
mc::cat_deref(_, _, mc::region_ptr(..)) |
105-
mc::cat_deref(_, _, mc::gc_ptr(..)) |
105+
mc::cat_deref(_, _, mc::gc_ptr) |
106106
mc::cat_deref(_, _, mc::unsafe_ptr(..)) |
107107
mc::cat_stack_upvar(..) |
108108
mc::cat_copied_upvar(mc::CopiedUpvar { onceness: ast::Many, .. }) => {

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

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
use middle::borrowck::*;
1717
use mc = middle::mem_categorization;
1818
use middle::ty;
19-
use syntax::ast::{MutImmutable, MutMutable};
2019
use syntax::ast;
2120
use syntax::codemap::Span;
22-
use util::ppaux::{note_and_explain_region};
2321

2422
type R = Result<(),()>;
2523

@@ -89,12 +87,11 @@ impl<'a> GuaranteeLifetimeContext<'a> {
8987
Ok(())
9088
}
9189

92-
mc::cat_deref(base, derefs, mc::gc_ptr(ptr_mutbl)) => {
90+
mc::cat_deref(base, derefs, mc::gc_ptr) => {
9391
let base_scope = self.scope(base);
9492

9593
// L-Deref-Managed-Imm-User-Root
9694
let omit_root = (
97-
ptr_mutbl == MutImmutable &&
9895
self.bccx.is_subregion_of(self.loan_region, base_scope) &&
9996
self.is_rvalue_or_immutable(base) &&
10097
!self.is_moved(base)
@@ -103,7 +100,7 @@ impl<'a> GuaranteeLifetimeContext<'a> {
103100
if !omit_root {
104101
// L-Deref-Managed-Imm-Compiler-Root
105102
// L-Deref-Managed-Mut-Compiler-Root
106-
self.check_root(cmt, base, derefs, ptr_mutbl, discr_scope)
103+
self.check_root(cmt, base, derefs, discr_scope)
107104
} else {
108105
debug!("omitting root, base={}, base_scope={:?}",
109106
base.repr(self.tcx()), base_scope);
@@ -192,14 +189,12 @@ impl<'a> GuaranteeLifetimeContext<'a> {
192189
cmt_deref: mc::cmt,
193190
cmt_base: mc::cmt,
194191
derefs: uint,
195-
ptr_mutbl: ast::Mutability,
196192
discr_scope: Option<ast::NodeId>) -> R {
197-
debug!("check_root(cmt_deref={}, cmt_base={}, derefs={:?}, ptr_mutbl={:?}, \
193+
debug!("check_root(cmt_deref={}, cmt_base={}, derefs={:?}, \
198194
discr_scope={:?})",
199195
cmt_deref.repr(self.tcx()),
200196
cmt_base.repr(self.tcx()),
201197
derefs,
202-
ptr_mutbl,
203198
discr_scope);
204199

205200
// Make sure that the loan does not exceed the maximum time
@@ -235,19 +230,6 @@ impl<'a> GuaranteeLifetimeContext<'a> {
235230
}
236231
};
237232

238-
// If we are borrowing the inside of an `@mut` box,
239-
// we need to dynamically mark it to prevent incompatible
240-
// borrows from happening later.
241-
let opt_dyna = match ptr_mutbl {
242-
MutImmutable => None,
243-
MutMutable => {
244-
match self.loan_mutbl {
245-
MutableMutability => Some(DynaMut),
246-
ImmutableMutability | ConstMutability => Some(DynaImm)
247-
}
248-
}
249-
};
250-
251233
// FIXME(#3511) grow to the nearest cleanup scope---this can
252234
// cause observable errors if freezing!
253235
if !self.bccx.tcx.region_maps.is_cleanup_scope(root_scope) {
@@ -256,29 +238,12 @@ impl<'a> GuaranteeLifetimeContext<'a> {
256238
let cleanup_scope =
257239
self.bccx.tcx.region_maps.cleanup_scope(root_scope);
258240

259-
if opt_dyna.is_some() {
260-
self.tcx().sess.span_warn(
261-
self.span,
262-
format!("Dynamic freeze scope artifically extended \
263-
(see Issue \\#6248)"));
264-
note_and_explain_region(
265-
self.bccx.tcx,
266-
"managed value only needs to be frozen for ",
267-
ty::ReScope(root_scope),
268-
"...");
269-
note_and_explain_region(
270-
self.bccx.tcx,
271-
"...but due to Issue #6248, it will be frozen for ",
272-
ty::ReScope(cleanup_scope),
273-
"");
274-
}
275-
276241
root_scope = cleanup_scope;
277242
}
278243

279244
// Add a record of what is required
280245
let rm_key = root_map_key {id: cmt_deref.id, derefs: derefs};
281-
let root_info = RootInfo {scope: root_scope, freeze: opt_dyna};
246+
let root_info = RootInfo {scope: root_scope};
282247

283248
let mut root_map = self.bccx.root_map.borrow_mut();
284249
root_map.get().insert(rm_key, root_info);
@@ -357,7 +322,7 @@ impl<'a> GuaranteeLifetimeContext<'a> {
357322
}
358323
mc::cat_downcast(cmt) |
359324
mc::cat_deref(cmt, _, mc::uniq_ptr) |
360-
mc::cat_deref(cmt, _, mc::gc_ptr(..)) |
325+
mc::cat_deref(cmt, _, mc::gc_ptr) |
361326
mc::cat_interior(cmt, _) |
362327
mc::cat_stack_upvar(cmt) |
363328
mc::cat_discr(cmt, _) => {

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

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -132,59 +132,11 @@ impl<'a> RestrictionsContext<'a> {
132132
Safe
133133
}
134134

135-
mc::cat_deref(_, _, mc::gc_ptr(MutImmutable)) => {
135+
mc::cat_deref(_, _, mc::gc_ptr) => {
136136
// R-Deref-Imm-Managed
137137
Safe
138138
}
139139

140-
mc::cat_deref(cmt_base, _, pk @ mc::gc_ptr(MutMutable)) => {
141-
// R-Deref-Managed-Borrowed
142-
//
143-
// Technically, no restrictions are *necessary* here.
144-
// The validity of the borrow is guaranteed
145-
// dynamically. However, nonetheless we add a
146-
// restriction to make a "best effort" to report
147-
// static errors. For example, if there is code like
148-
//
149-
// let v = @mut ~[1, 2, 3];
150-
// for e in v.iter() {
151-
// v.push(e + 1);
152-
// }
153-
//
154-
// Then the code below would add restrictions on `*v`,
155-
// which means that an error would be reported
156-
// here. This of course is not perfect. For example,
157-
// a function like the following would not report an error
158-
// at compile-time but would fail dynamically:
159-
//
160-
// let v = @mut ~[1, 2, 3];
161-
// let w = v;
162-
// for e in v.iter() {
163-
// w.push(e + 1);
164-
// }
165-
//
166-
// In addition, we only add a restriction for those cases
167-
// where we can construct a sensible loan path, so an
168-
// example like the following will fail dynamically:
169-
//
170-
// impl V {
171-
// fn get_list(&self) -> @mut ~[int];
172-
// }
173-
// ...
174-
// let v: &V = ...;
175-
// for e in v.get_list().iter() {
176-
// v.get_list().push(e + 1);
177-
// }
178-
match opt_loan_path(cmt_base) {
179-
None => Safe,
180-
Some(lp_base) => {
181-
let lp = @LpExtend(lp_base, cmt.mutbl, LpDeref(pk));
182-
SafeIf(lp, ~[Restriction {loan_path: lp,
183-
set: restrictions}])
184-
}
185-
}
186-
}
187-
188140
mc::cat_deref(cmt_base, _, pk @ mc::region_ptr(MutMutable, lt)) => {
189141
// R-Deref-Mut-Borrowed
190142
if !self.bccx.is_subregion_of(self.loan_region, lt) {

branches/auto/src/librustc/middle/borrowck/mod.rs

Lines changed: 12 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use middle::dataflow::DataFlowOperator;
2020
use util::ppaux::{note_and_explain_region, Repr, UserString};
2121

2222
use std::cell::{Cell, RefCell};
23-
use std::hashmap::{HashSet, HashMap};
23+
use std::hashmap::HashMap;
2424
use std::ops::{BitOr, BitAnd};
2525
use std::result::{Result};
2626
use syntax::ast;
@@ -67,22 +67,20 @@ impl Visitor<()> for BorrowckCtxt {
6767
}
6868
}
6969

70-
pub fn check_crate(
71-
tcx: ty::ctxt,
72-
method_map: typeck::method_map,
73-
moves_map: moves::MovesMap,
74-
moved_variables_set: moves::MovedVariablesSet,
75-
capture_map: moves::CaptureMap,
76-
crate: &ast::Crate) -> (root_map, write_guard_map)
77-
{
70+
pub fn check_crate(tcx: ty::ctxt,
71+
method_map: typeck::method_map,
72+
moves_map: moves::MovesMap,
73+
moved_variables_set: moves::MovedVariablesSet,
74+
capture_map: moves::CaptureMap,
75+
crate: &ast::Crate)
76+
-> root_map {
7877
let mut bccx = BorrowckCtxt {
7978
tcx: tcx,
8079
method_map: method_map,
8180
moves_map: moves_map,
8281
moved_variables_set: moved_variables_set,
8382
capture_map: capture_map,
8483
root_map: root_map(),
85-
write_guard_map: @RefCell::new(HashSet::new()),
8684
stats: @BorrowStats {
8785
loaned_paths_same: Cell::new(0),
8886
loaned_paths_imm: Cell::new(0),
@@ -106,7 +104,7 @@ pub fn check_crate(
106104
make_stat(bccx, bccx.stats.stable_paths.get()));
107105
}
108106

109-
return (bccx.root_map, bccx.write_guard_map);
107+
return bccx.root_map;
110108

111109
fn make_stat(bccx: &mut BorrowckCtxt, stat: uint) -> ~str {
112110
let stat_f = stat as f64;
@@ -171,7 +169,6 @@ pub struct BorrowckCtxt {
171169
moved_variables_set: moves::MovedVariablesSet,
172170
capture_map: moves::CaptureMap,
173171
root_map: root_map,
174-
write_guard_map: write_guard_map,
175172

176173
// Statistics:
177174
stats: @BorrowStats
@@ -213,10 +210,6 @@ pub struct root_map_key {
213210
derefs: uint
214211
}
215212

216-
// A set containing IDs of expressions of gc'd type that need to have a write
217-
// guard.
218-
pub type write_guard_map = @RefCell<HashSet<root_map_key>>;
219-
220213
pub type BckResult<T> = Result<T, BckError>;
221214

222215
#[deriving(Eq)]
@@ -402,7 +395,6 @@ impl BitAnd<RestrictionSet,RestrictionSet> for RestrictionSet {
402395

403396
pub struct RootInfo {
404397
scope: ast::NodeId,
405-
freeze: Option<DynaFreezeKind> // Some() if we should freeze box at runtime
406398
}
407399

408400
pub type root_map = @RefCell<HashMap<root_map_key, RootInfo>>;
@@ -411,20 +403,6 @@ pub fn root_map() -> root_map {
411403
return @RefCell::new(HashMap::new());
412404
}
413405

414-
pub enum DynaFreezeKind {
415-
DynaImm,
416-
DynaMut
417-
}
418-
419-
impl ToStr for DynaFreezeKind {
420-
fn to_str(&self) -> ~str {
421-
match *self {
422-
DynaMut => ~"mutable",
423-
DynaImm => ~"immutable"
424-
}
425-
}
426-
}
427-
428406
///////////////////////////////////////////////////////////////////////////
429407
// Errors
430408

@@ -691,20 +669,9 @@ impl BorrowckCtxt {
691669
span,
692670
format!("{} in an aliasable location", prefix));
693671
}
694-
mc::AliasableManaged(ast::MutMutable) => {
695-
// FIXME(#6269) reborrow @mut to &mut
696-
self.tcx.sess.span_err(
697-
span,
698-
format!("{} in a `@mut` pointer; \
699-
try borrowing as `&mut` first", prefix));
700-
}
701-
mc::AliasableManaged(m) => {
702-
self.tcx.sess.span_err(
703-
span,
704-
format!("{} in a `@{}` pointer; \
705-
try an `@mut` instead",
706-
prefix,
707-
self.mut_to_keyword(m)));
672+
mc::AliasableManaged => {
673+
self.tcx.sess.span_err(span, format!("{} in a `@` pointer",
674+
prefix))
708675
}
709676
mc::AliasableBorrowed(m) => {
710677
self.tcx.sess.span_err(

0 commit comments

Comments
 (0)