@@ -224,8 +224,6 @@ Borrowck results in two maps.
224224 given a memory location and not used as immediates.
225225 */
226226
227- #[ legacy_exports] ;
228-
229227use core:: prelude:: * ;
230228
231229use middle:: liveness;
@@ -251,20 +249,16 @@ use syntax::codemap::span;
251249use syntax:: print:: pprust;
252250use syntax:: visit;
253251
254- #[ legacy_exports]
255252pub mod check_loans;
256- #[ legacy_exports]
257253pub mod gather_loans;
258- #[ legacy_exports]
259254pub mod loan;
260- #[ legacy_exports]
261255pub mod preserve;
262256
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 ) {
268262
269263 let bccx = borrowck_ctxt_ ( @{ tcx: tcx,
270264 method_map: method_map,
@@ -308,26 +302,26 @@ fn check_crate(tcx: ty::ctxt,
308302// ----------------------------------------------------------------------
309303// Type definitions
310304
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 {
327321 borrowck_ctxt_( @borrowck_ctxt_ )
328322}
329323
330- struct RootInfo {
324+ pub struct RootInfo {
331325 scope : ast:: node_id ,
332326 // This will be true if we need to freeze this box at runtime. This will
333327 // result in a call to `borrow_as_imm()` and `return_to_mut()`.
@@ -337,29 +331,30 @@ struct RootInfo {
337331// a map mapping id's of expressions of gc'd type (@T, @[], etc) where
338332// the box needs to be kept live to the id of the scope for which they
339333// must stay live.
340- type root_map = HashMap < root_map_key , RootInfo > ;
334+ pub type root_map = HashMap < root_map_key , RootInfo > ;
341335
342336// the keys to the root map combine the `id` of the expression with
343337// the number of types that it is autodereferenced. So, for example,
344338// if you have an expression `x.f` and x has type ~@T, we could add an
345339// entry {id:x, derefs:0} to refer to `x` itself, `{id:x, derefs:1}`
346340// to refer to the deref of the unique pointer, and so on.
347341#[ deriving_eq]
348- struct root_map_key {
342+ pub struct root_map_key {
349343 id : ast:: node_id ,
350344 derefs : uint
351345}
352346
353347// set of ids of local vars / formal arguments that are modified / moved.
354348// 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 , ( ) > ;
356350
357351// A set containing IDs of expressions of gc'd type that need to have a write
358352// guard.
359- type write_guard_map = HashMap < root_map_key , ( ) > ;
353+ pub type write_guard_map = HashMap < root_map_key , ( ) > ;
360354
361- // Errors that can occur"]
362- enum bckerr_code {
355+ // Errors that can occur
356+ #[ deriving_eq]
357+ pub enum bckerr_code {
363358 err_mut_uniq,
364359 err_mut_variant,
365360 err_root_not_permitted,
@@ -368,61 +363,16 @@ enum bckerr_code {
368363 err_out_of_scope( ty:: Region , ty:: Region ) // superscope, subscope
369364}
370365
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-
416366// Combination of an error code and the categorization of the expression
417367// that caused it
418368#[ deriving_eq]
419- struct bckerr {
369+ pub struct bckerr {
420370 cmt : cmt ,
421371 code : bckerr_code
422372}
423373
424374// 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 > ;
426376
427377/// a complete record of a loan that was granted
428378pub struct Loan { lp : @loan_path , cmt : cmt , mutbl : ast:: mutability }
@@ -438,7 +388,8 @@ pub type req_maps = {
438388 pure_map : HashMap < ast:: node_id , bckerr >
439389} ;
440390
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 {
442393 let old_save_and_restore_t = * save_and_restore_t;
443394 let u = f ( ) ;
444395 * 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 {
447398
448399/// Creates and returns a new root_map
449400
450- impl root_map_key : to_bytes:: IterBytes {
401+ pub impl root_map_key : to_bytes:: IterBytes {
451402 pure fn iter_bytes ( & self , +lsb0 : bool , f : to_bytes:: Cb ) {
452403 to_bytes:: iter_bytes_2 ( & self . id , & self . derefs , lsb0, f) ;
453404 }
454405}
455406
456- fn root_map ( ) -> root_map {
407+ pub fn root_map ( ) -> root_map {
457408 return HashMap ( ) ;
458409}
459410
460411// ___________________________________________________________________________
461412// Misc
462413
463- impl borrowck_ctxt {
414+ pub impl borrowck_ctxt {
464415 fn is_subregion_of ( r_sub : ty:: Region , r_sup : ty:: Region ) -> bool {
465416 region:: is_subregion_of ( self . tcx . region_map , r_sub, r_sup)
466417 }
@@ -632,7 +583,7 @@ impl borrowck_ctxt {
632583// assuming it is embedded in an immutable context. In general, the
633584// mutability can be "overridden" if the component is embedded in a
634585// mutable structure.
635- fn inherent_mutability( ck: comp_kind) -> mutability {
586+ pub fn inherent_mutability( ck: comp_kind) -> mutability {
636587 match ck {
637588 comp_tuple | comp_anon_field | comp_variant ( _) => m_imm,
638589 comp_field ( _, m) | comp_index ( _, m) => m
0 commit comments