Skip to content

Commit c25703c

Browse files
committed
librustc: De-export front, borrowck, and typeck/check. rs=deexporting
1 parent 2ea2628 commit c25703c

File tree

15 files changed

+202
-304
lines changed

15 files changed

+202
-304
lines changed

src/librustc/front/intrinsic.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
// and injected into each crate the compiler builds. Keep it small.
1313

1414
mod intrinsic {
15-
#[legacy_exports];
16-
1715
pub use intrinsic::rusti::visit_tydesc;
1816

1917
// FIXME (#3727): remove this when the interface has settled and the
@@ -30,7 +28,7 @@ mod intrinsic {
3028
// Remaining fields not listed
3129
};
3230

33-
trait TyVisitor {
31+
pub trait TyVisitor {
3432
fn visit_bot(&self) -> bool;
3533
fn visit_nil(&self) -> bool;
3634
fn visit_bool(&self) -> bool;
@@ -125,9 +123,8 @@ mod intrinsic {
125123
}
126124

127125
#[abi = "rust-intrinsic"]
128-
extern mod rusti {
129-
#[legacy_exports];
130-
fn get_tydesc<T>() -> *();
131-
fn visit_tydesc(++td: *TyDesc, &&tv: TyVisitor);
126+
pub extern mod rusti {
127+
pub fn get_tydesc<T>() -> *();
128+
pub fn visit_tydesc(++td: *TyDesc, &&tv: TyVisitor);
132129
}
133130
}

src/librustc/front/test.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,6 @@ fn add_test_module(cx: test_ctxt, +m: ast::_mod) -> ast::_mod {
193193
We're going to be building a module that looks more or less like:
194194
195195
mod __test {
196-
#[legacy_exports];
197-
198196
fn main(args: ~[str]) -> int {
199197
std::test::test_main(args, tests())
200198
}

src/librustc/middle/borrowck/check_loans.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
use core::prelude::*;
2121

22-
use middle::borrowck::{Loan, bckerr, borrowck_ctxt, cmt, inherent_mutability};
22+
use middle::borrowck::{Loan, bckerr, borrowck_ctxt, inherent_mutability};
2323
use middle::borrowck::{req_maps, root_map_key, save_and_restore};
2424
use middle::mem_categorization::{cat_arg, cat_binding, cat_comp, cat_deref};
2525
use middle::mem_categorization::{cat_local, cat_rvalue, cat_self};
26-
use middle::mem_categorization::{cat_special, gc_ptr, loan_path, lp_arg};
26+
use middle::mem_categorization::{cat_special, cmt, gc_ptr, loan_path, lp_arg};
2727
use middle::mem_categorization::{lp_comp, lp_deref, lp_local};
2828
use middle::ty::{CopyValue, MoveValue, ReadValue};
2929
use middle::ty;
@@ -41,8 +41,6 @@ use syntax::codemap::span;
4141
use syntax::print::pprust;
4242
use syntax::visit;
4343

44-
export check_loans;
45-
4644
enum check_loan_ctxt = @{
4745
bccx: borrowck_ctxt,
4846
req_maps: req_maps,
@@ -65,9 +63,9 @@ enum purity_cause {
6563
pc_cmt(bckerr)
6664
}
6765

68-
fn check_loans(bccx: borrowck_ctxt,
69-
req_maps: req_maps,
70-
crate: @ast::crate) {
66+
pub fn check_loans(bccx: borrowck_ctxt,
67+
req_maps: req_maps,
68+
crate: @ast::crate) {
7169
let clcx = check_loan_ctxt(@{bccx: bccx,
7270
req_maps: req_maps,
7371
reported: HashMap(),

src/librustc/middle/borrowck/gather_loans.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ use syntax::codemap::span;
4040
use syntax::print::pprust;
4141
use syntax::visit;
4242

43-
export gather_loans;
44-
4543
/// Context used while gathering loans:
4644
///
4745
/// - `bccx`: the the borrow check context
@@ -76,7 +74,7 @@ enum gather_loan_ctxt = @{bccx: borrowck_ctxt,
7674
mut root_ub: ast::node_id,
7775
mut ignore_adjustments: LinearSet<ast::node_id>};
7876

79-
fn gather_loans(bccx: borrowck_ctxt, crate: @ast::crate) -> req_maps {
77+
pub fn gather_loans(bccx: borrowck_ctxt, crate: @ast::crate) -> req_maps {
8078
let glcx = gather_loan_ctxt(@{bccx: bccx,
8179
req_maps: {req_loan_map: HashMap(),
8280
pure_map: HashMap()},

src/librustc/middle/borrowck/loan.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,20 @@ XXX --- much more needed, don't have time to write this all up now
4343

4444
use core::prelude::*;
4545

46-
use middle::borrowck::{Loan, bckerr, bckres, borrowck_ctxt, cmt, err_mutbl};
46+
use middle::borrowck::{Loan, bckerr, bckres, borrowck_ctxt, err_mutbl};
4747
use middle::borrowck::{err_out_of_scope};
4848
use middle::mem_categorization::{cat_arg, cat_binding, cat_discr, cat_comp};
4949
use middle::mem_categorization::{cat_deref, cat_discr, cat_local, cat_self};
50-
use middle::mem_categorization::{cat_special, cat_stack_upvar, comp_field};
51-
use middle::mem_categorization::{comp_index, comp_variant, gc_ptr};
52-
use middle::mem_categorization::{region_ptr};
50+
use middle::mem_categorization::{cat_special, cat_stack_upvar, cmt};
51+
use middle::mem_categorization::{comp_field, comp_index, comp_variant};
52+
use middle::mem_categorization::{gc_ptr, region_ptr};
5353
use middle::ty;
5454
use util::common::indenter;
5555

5656
use core::result::{Err, Ok, Result};
5757
use syntax::ast::{m_const, m_imm, m_mutbl};
5858
use syntax::ast;
5959

60-
export public_methods;
61-
6260
impl borrowck_ctxt {
6361
fn loan(cmt: cmt,
6462
scope_region: ty::Region,

src/librustc/middle/borrowck/mod.rs

Lines changed: 37 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
229227
use core::prelude::*;
230228

231229
use middle::liveness;
@@ -251,20 +249,16 @@ use syntax::codemap::span;
251249
use syntax::print::pprust;
252250
use syntax::visit;
253251

254-
#[legacy_exports]
255252
pub mod check_loans;
256-
#[legacy_exports]
257253
pub mod gather_loans;
258-
#[legacy_exports]
259254
pub mod loan;
260-
#[legacy_exports]
261255
pub 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
428378
pub 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

src/librustc/middle/borrowck/preserve.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,21 @@
1616
use core::prelude::*;
1717

1818
use middle::borrowck::{RootInfo, bckerr, bckerr_code, bckres, borrowck_ctxt};
19-
use middle::borrowck::{cmt, err_mut_uniq, err_mut_variant};
19+
use middle::borrowck::{err_mut_uniq, err_mut_variant};
2020
use middle::borrowck::{err_out_of_root_scope, err_out_of_scope};
2121
use middle::borrowck::{err_root_not_permitted, root_map_key};
2222
use middle::mem_categorization::{cat_arg, cat_binding, cat_comp, cat_deref};
2323
use middle::mem_categorization::{cat_discr, cat_local, cat_self, cat_special};
24-
use middle::mem_categorization::{cat_stack_upvar, comp_field, comp_index};
25-
use middle::mem_categorization::{comp_variant, gc_ptr, region_ptr};
24+
use middle::mem_categorization::{cat_stack_upvar, cmt, comp_field};
25+
use middle::mem_categorization::{comp_index, comp_variant, gc_ptr};
26+
use middle::mem_categorization::{region_ptr};
2627
use middle::ty;
2728
use util::common::indenter;
2829

2930
use syntax::ast::{m_const, m_imm, m_mutbl};
3031
use syntax::ast;
3132

32-
export public_methods, preserve_condition, pc_ok, pc_if_pure;
33-
34-
enum preserve_condition {
33+
pub enum preserve_condition {
3534
pc_ok,
3635
pc_if_pure(bckerr)
3736
}

0 commit comments

Comments
 (0)