@@ -224,8 +224,6 @@ Borrowck results in two maps.
224
224
given a memory location and not used as immediates.
225
225
*/
226
226
227
- #[ legacy_exports] ;
228
-
229
227
use core:: prelude:: * ;
230
228
231
229
use middle:: liveness;
@@ -251,20 +249,16 @@ use syntax::codemap::span;
251
249
use syntax:: print:: pprust;
252
250
use syntax:: visit;
253
251
254
- #[ legacy_exports]
255
252
pub mod check_loans;
256
- #[ legacy_exports]
257
253
pub mod gather_loans;
258
- #[ legacy_exports]
259
254
pub mod loan;
260
- #[ legacy_exports]
261
255
pub mod preserve;
262
256
263
- fn check_crate ( tcx : ty:: ctxt ,
264
- method_map : typeck:: method_map ,
265
- last_use_map : liveness:: last_use_map ,
266
- crate : @ast:: crate )
267
- -> ( root_map , mutbl_map , write_guard_map ) {
257
+ pub fn check_crate ( tcx : ty:: ctxt ,
258
+ method_map : typeck:: method_map ,
259
+ last_use_map : liveness:: last_use_map ,
260
+ crate : @ast:: crate )
261
+ -> ( root_map , mutbl_map , write_guard_map ) {
268
262
269
263
let bccx = borrowck_ctxt_ ( @{ tcx: tcx,
270
264
method_map: method_map,
@@ -308,26 +302,26 @@ fn check_crate(tcx: ty::ctxt,
308
302
// ----------------------------------------------------------------------
309
303
// Type definitions
310
304
311
- type borrowck_ctxt_ = { tcx : ty:: ctxt ,
312
- method_map : typeck:: method_map ,
313
- last_use_map : liveness:: last_use_map ,
314
- root_map : root_map ,
315
- mutbl_map : mutbl_map ,
316
- write_guard_map : write_guard_map ,
317
- stmt_map : stmt_set ,
318
-
319
- // Statistics:
320
- mut loaned_paths_same : uint ,
321
- mut loaned_paths_imm : uint ,
322
- mut stable_paths : uint ,
323
- mut req_pure_paths : uint ,
324
- mut guaranteed_paths : uint } ;
325
-
326
- enum borrowck_ctxt {
305
+ pub type borrowck_ctxt_ = { tcx : ty:: ctxt ,
306
+ method_map : typeck:: method_map ,
307
+ last_use_map : liveness:: last_use_map ,
308
+ root_map : root_map ,
309
+ mutbl_map : mutbl_map ,
310
+ write_guard_map : write_guard_map ,
311
+ stmt_map : stmt_set ,
312
+
313
+ // Statistics:
314
+ mut loaned_paths_same : uint ,
315
+ mut loaned_paths_imm : uint ,
316
+ mut stable_paths : uint ,
317
+ mut req_pure_paths : uint ,
318
+ mut guaranteed_paths : uint } ;
319
+
320
+ pub enum borrowck_ctxt {
327
321
borrowck_ctxt_( @borrowck_ctxt_ )
328
322
}
329
323
330
- struct RootInfo {
324
+ pub struct RootInfo {
331
325
scope : ast:: node_id ,
332
326
// This will be true if we need to freeze this box at runtime. This will
333
327
// result in a call to `borrow_as_imm()` and `return_to_mut()`.
@@ -337,29 +331,30 @@ struct RootInfo {
337
331
// a map mapping id's of expressions of gc'd type (@T, @[], etc) where
338
332
// the box needs to be kept live to the id of the scope for which they
339
333
// must stay live.
340
- type root_map = HashMap < root_map_key , RootInfo > ;
334
+ pub type root_map = HashMap < root_map_key , RootInfo > ;
341
335
342
336
// the keys to the root map combine the `id` of the expression with
343
337
// the number of types that it is autodereferenced. So, for example,
344
338
// if you have an expression `x.f` and x has type ~@T, we could add an
345
339
// entry {id:x, derefs:0} to refer to `x` itself, `{id:x, derefs:1}`
346
340
// to refer to the deref of the unique pointer, and so on.
347
341
#[ deriving_eq]
348
- struct root_map_key {
342
+ pub struct root_map_key {
349
343
id : ast:: node_id ,
350
344
derefs : uint
351
345
}
352
346
353
347
// set of ids of local vars / formal arguments that are modified / moved.
354
348
// this is used in trans for optimization purposes.
355
- type mutbl_map = HashMap < ast:: node_id , ( ) > ;
349
+ pub type mutbl_map = HashMap < ast:: node_id , ( ) > ;
356
350
357
351
// A set containing IDs of expressions of gc'd type that need to have a write
358
352
// guard.
359
- type write_guard_map = HashMap < root_map_key , ( ) > ;
353
+ pub type write_guard_map = HashMap < root_map_key , ( ) > ;
360
354
361
- // Errors that can occur"]
362
- enum bckerr_code {
355
+ // Errors that can occur
356
+ #[ deriving_eq]
357
+ pub enum bckerr_code {
363
358
err_mut_uniq,
364
359
err_mut_variant,
365
360
err_root_not_permitted,
@@ -368,61 +363,16 @@ enum bckerr_code {
368
363
err_out_of_scope( ty:: Region , ty:: Region ) // superscope, subscope
369
364
}
370
365
371
- impl bckerr_code : cmp:: Eq {
372
- pure fn eq ( & self , other : & bckerr_code ) -> bool {
373
- match ( * self ) {
374
- err_mut_uniq => {
375
- match ( * other) {
376
- err_mut_uniq => true ,
377
- _ => false
378
- }
379
- }
380
- err_mut_variant => {
381
- match ( * other) {
382
- err_mut_variant => true ,
383
- _ => false
384
- }
385
- }
386
- err_root_not_permitted => {
387
- match ( * other) {
388
- err_root_not_permitted => true ,
389
- _ => false
390
- }
391
- }
392
- err_mutbl( e0a) => {
393
- match ( * other) {
394
- err_mutbl( e0b) => e0a == e0b,
395
- _ => false
396
- }
397
- }
398
- err_out_of_root_scope( e0a, e1a) => {
399
- match ( * other) {
400
- err_out_of_root_scope( e0b, e1b) =>
401
- e0a == e0b && e1a == e1b,
402
- _ => false
403
- }
404
- }
405
- err_out_of_scope( e0a, e1a) => {
406
- match ( * other) {
407
- err_out_of_scope( e0b, e1b) => e0a == e0b && e1a == e1b,
408
- _ => false
409
- }
410
- }
411
- }
412
- }
413
- pure fn ne ( & self , other : & bckerr_code ) -> bool { !( * self ) . eq ( other) }
414
- }
415
-
416
366
// Combination of an error code and the categorization of the expression
417
367
// that caused it
418
368
#[ deriving_eq]
419
- struct bckerr {
369
+ pub struct bckerr {
420
370
cmt : cmt ,
421
371
code : bckerr_code
422
372
}
423
373
424
374
// shorthand for something that fails with `bckerr` or succeeds with `T`
425
- type bckres < T > = Result < T , bckerr > ;
375
+ pub type bckres < T > = Result < T , bckerr > ;
426
376
427
377
/// a complete record of a loan that was granted
428
378
pub struct Loan { lp : @loan_path , cmt : cmt , mutbl : ast:: mutability }
@@ -438,7 +388,8 @@ pub type req_maps = {
438
388
pure_map : HashMap < ast:: node_id , bckerr >
439
389
} ;
440
390
441
- fn save_and_restore < T : Copy , U > ( save_and_restore_t : & mut T , f : fn ( ) -> U ) -> U {
391
+ pub fn save_and_restore < T : Copy , U > ( save_and_restore_t : & mut T ,
392
+ f : fn ( ) -> U ) -> U {
442
393
let old_save_and_restore_t = * save_and_restore_t;
443
394
let u = f ( ) ;
444
395
* save_and_restore_t = old_save_and_restore_t;
@@ -447,20 +398,20 @@ fn save_and_restore<T:Copy,U>(save_and_restore_t: &mut T, f: fn() -> U) -> U {
447
398
448
399
/// Creates and returns a new root_map
449
400
450
- impl root_map_key : to_bytes:: IterBytes {
401
+ pub impl root_map_key : to_bytes:: IterBytes {
451
402
pure fn iter_bytes ( & self , +lsb0 : bool , f : to_bytes:: Cb ) {
452
403
to_bytes:: iter_bytes_2 ( & self . id , & self . derefs , lsb0, f) ;
453
404
}
454
405
}
455
406
456
- fn root_map ( ) -> root_map {
407
+ pub fn root_map ( ) -> root_map {
457
408
return HashMap ( ) ;
458
409
}
459
410
460
411
// ___________________________________________________________________________
461
412
// Misc
462
413
463
- impl borrowck_ctxt {
414
+ pub impl borrowck_ctxt {
464
415
fn is_subregion_of ( r_sub : ty:: Region , r_sup : ty:: Region ) -> bool {
465
416
region:: is_subregion_of ( self . tcx . region_map , r_sub, r_sup)
466
417
}
@@ -632,7 +583,7 @@ impl borrowck_ctxt {
632
583
// assuming it is embedded in an immutable context. In general, the
633
584
// mutability can be "overridden" if the component is embedded in a
634
585
// mutable structure.
635
- fn inherent_mutability( ck: comp_kind) -> mutability {
586
+ pub fn inherent_mutability( ck: comp_kind) -> mutability {
636
587
match ck {
637
588
comp_tuple | comp_anon_field | comp_variant ( _) => m_imm,
638
589
comp_field ( _, m) | comp_index ( _, m) => m
0 commit comments