Skip to content

Commit d8ad0fe

Browse files
committed
---
yaml --- r: 95241 b: refs/heads/dist-snap c: 439e277 h: refs/heads/master i: 95239: 249b461 v: v3
1 parent ee28d30 commit d8ad0fe

File tree

16 files changed

+1477
-1152
lines changed

16 files changed

+1477
-1152
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 132099950fc1d157b9af0130cf3f1eb20a263541
9+
refs/heads/dist-snap: 439e2770be6aec41a3961235305787a78d47fbdd
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librustc/driver/driver.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ pub fn phase_2_configure_and_expand(sess: Session,
199199

200200
pub struct CrateAnalysis {
201201
exp_map2: middle::resolve::ExportMap2,
202-
exported_items: @middle::privacy::ExportedItems,
203202
ty_cx: ty::ctxt,
204203
maps: astencode::Maps,
205204
reachable: @mut HashSet<ast::NodeId>
@@ -229,7 +228,9 @@ pub fn phase_3_run_analysis_passes(sess: Session,
229228
let middle::resolve::CrateMap {
230229
def_map: def_map,
231230
exp_map2: exp_map2,
232-
trait_map: trait_map
231+
trait_map: trait_map,
232+
external_exports: external_exports,
233+
last_private_map: last_private_map
233234
} =
234235
time(time_passes, "resolution", (), |_|
235236
middle::resolve::resolve_crate(sess, lang_items, crate));
@@ -261,9 +262,10 @@ pub fn phase_3_run_analysis_passes(sess: Session,
261262
middle::check_const::check_crate(sess, crate, ast_map, def_map,
262263
method_map, ty_cx));
263264

264-
let exported_items =
265-
time(time_passes, "privacy checking", (), |_|
266-
middle::privacy::check_crate(ty_cx, &method_map, &exp_map2, crate));
265+
let maps = (external_exports, last_private_map);
266+
time(time_passes, "privacy checking", maps, |(a, b)|
267+
middle::privacy::check_crate(ty_cx, &method_map, &exp_map2,
268+
a, b, crate));
267269

268270
time(time_passes, "effect checking", (), |_|
269271
middle::effect::check_crate(ty_cx, method_map, crate));
@@ -305,7 +307,6 @@ pub fn phase_3_run_analysis_passes(sess: Session,
305307

306308
CrateAnalysis {
307309
exp_map2: exp_map2,
308-
exported_items: @exported_items,
309310
ty_cx: ty_cx,
310311
maps: astencode::Maps {
311312
root_map: root_map,

branches/dist-snap/src/librustc/metadata/decoder.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,8 +837,9 @@ fn each_child_of_item_or_crate(intr: @ident_interner,
837837
let def_like = item_to_def_like(child_item_doc,
838838
child_def_id,
839839
cdata.cnum);
840-
callback(def_like, token::str_to_ident(name),
841-
item_visibility(child_item_doc));
840+
// These items have a public visibility because they're part of
841+
// a public re-export.
842+
callback(def_like, token::str_to_ident(name), ast::public);
842843
}
843844
}
844845

branches/dist-snap/src/librustc/metadata/encoder.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ pub struct EncodeParams<'self> {
5858
diag: @mut span_handler,
5959
tcx: ty::ctxt,
6060
reexports2: middle::resolve::ExportMap2,
61-
exported_items: @middle::privacy::ExportedItems,
6261
item_symbols: &'self HashMap<ast::NodeId, ~str>,
6362
discrim_symbols: &'self HashMap<ast::NodeId, @str>,
6463
non_inlineable_statics: &'self HashSet<ast::NodeId>,
@@ -89,7 +88,6 @@ pub struct EncodeContext<'self> {
8988
tcx: ty::ctxt,
9089
stats: @mut Stats,
9190
reexports2: middle::resolve::ExportMap2,
92-
exported_items: @middle::privacy::ExportedItems,
9391
item_symbols: &'self HashMap<ast::NodeId, ~str>,
9492
discrim_symbols: &'self HashMap<ast::NodeId, @str>,
9593
non_inlineable_statics: &'self HashSet<ast::NodeId>,
@@ -1277,12 +1275,7 @@ fn my_visit_item(i:@item, items: ast_map::map, ebml_w:&writer::Encoder,
12771275
let mut ebml_w = ebml_w.clone();
12781276
// See above
12791277
let ecx : &EncodeContext = unsafe { cast::transmute(ecx_ptr) };
1280-
let vis = if ecx.exported_items.contains(&i.id) {
1281-
ast::public
1282-
} else {
1283-
ast::inherited
1284-
};
1285-
encode_info_for_item(ecx, &mut ebml_w, i, index, *pt, vis);
1278+
encode_info_for_item(ecx, &mut ebml_w, i, index, *pt, i.vis);
12861279
}
12871280
_ => fail2!("bad item")
12881281
}
@@ -1628,7 +1621,7 @@ impl<'self> Visitor<()> for ImplVisitor<'self> {
16281621

16291622
// Load eagerly if this is an implementation of the Drop trait
16301623
// or if the trait is not defined in this crate.
1631-
if def_id == self.ecx.tcx.lang_items.drop_trait().unwrap() ||
1624+
if Some(def_id) == self.ecx.tcx.lang_items.drop_trait() ||
16321625
def_id.crate != LOCAL_CRATE {
16331626
self.ebml_w.start_tag(tag_impls_impl);
16341627
encode_def_id(self.ebml_w, local_def(item.id));
@@ -1744,7 +1737,6 @@ pub fn encode_metadata(parms: EncodeParams, crate: &Crate) -> ~[u8] {
17441737
diag,
17451738
tcx,
17461739
reexports2,
1747-
exported_items,
17481740
discrim_symbols,
17491741
cstore,
17501742
encode_inlined_item,
@@ -1760,7 +1752,6 @@ pub fn encode_metadata(parms: EncodeParams, crate: &Crate) -> ~[u8] {
17601752
tcx: tcx,
17611753
stats: stats,
17621754
reexports2: reexports2,
1763-
exported_items: exported_items,
17641755
item_symbols: item_symbols,
17651756
discrim_symbols: discrim_symbols,
17661757
non_inlineable_statics: non_inlineable_statics,

branches/dist-snap/src/librustc/middle/check_match.rs

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use syntax::codemap::{Span, dummy_sp, Spanned};
2828
use syntax::visit;
2929
use syntax::visit::{Visitor,fn_kind};
3030

31-
struct MatchCheckCtxt {
31+
pub struct MatchCheckCtxt {
3232
tcx: ty::ctxt,
3333
method_map: method_map,
3434
moves_map: moves::MovesMap
@@ -64,7 +64,7 @@ pub fn check_crate(tcx: ty::ctxt,
6464
tcx.sess.abort_if_errors();
6565
}
6666

67-
fn check_expr(v: &mut CheckMatchVisitor,
67+
pub fn check_expr(v: &mut CheckMatchVisitor,
6868
cx: @MatchCheckCtxt,
6969
ex: @Expr,
7070
s: ()) {
@@ -115,7 +115,7 @@ fn check_expr(v: &mut CheckMatchVisitor,
115115
}
116116

117117
// Check for unreachable patterns
118-
fn check_arms(cx: &MatchCheckCtxt, arms: &[Arm]) {
118+
pub fn check_arms(cx: &MatchCheckCtxt, arms: &[Arm]) {
119119
let mut seen = ~[];
120120
for arm in arms.iter() {
121121
for pat in arm.pats.iter() {
@@ -154,14 +154,14 @@ fn check_arms(cx: &MatchCheckCtxt, arms: &[Arm]) {
154154
}
155155
}
156156

157-
fn raw_pat(p: @Pat) -> @Pat {
157+
pub fn raw_pat(p: @Pat) -> @Pat {
158158
match p.node {
159159
PatIdent(_, _, Some(s)) => { raw_pat(s) }
160160
_ => { p }
161161
}
162162
}
163163

164-
fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, pats: ~[@Pat]) {
164+
pub fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, pats: ~[@Pat]) {
165165
assert!((!pats.is_empty()));
166166
let ext = match is_useful(cx, &pats.map(|p| ~[*p]), [wild()]) {
167167
not_useful => {
@@ -209,12 +209,12 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, pats: ~[@Pat]) {
209209
cx.tcx.sess.span_err(sp, msg);
210210
}
211211

212-
type matrix = ~[~[@Pat]];
212+
pub type matrix = ~[~[@Pat]];
213213

214-
enum useful { useful(ty::t, ctor), useful_, not_useful }
214+
pub enum useful { useful(ty::t, ctor), useful_, not_useful }
215215

216216
#[deriving(Eq)]
217-
enum ctor {
217+
pub enum ctor {
218218
single,
219219
variant(DefId),
220220
val(const_val),
@@ -235,7 +235,7 @@ enum ctor {
235235

236236
// Note: is_useful doesn't work on empty types, as the paper notes.
237237
// So it assumes that v is non-empty.
238-
fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@Pat]) -> useful {
238+
pub fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@Pat]) -> useful {
239239
if m.len() == 0u { return useful_; }
240240
if m[0].len() == 0u { return not_useful; }
241241
let real_pat = match m.iter().find(|r| r[0].id != 0) {
@@ -314,7 +314,7 @@ fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@Pat]) -> useful {
314314
}
315315
}
316316

317-
fn is_useful_specialized(cx: &MatchCheckCtxt,
317+
pub fn is_useful_specialized(cx: &MatchCheckCtxt,
318318
m: &matrix,
319319
v: &[@Pat],
320320
ctor: ctor,
@@ -330,7 +330,7 @@ fn is_useful_specialized(cx: &MatchCheckCtxt,
330330
}
331331
}
332332

333-
fn pat_ctor_id(cx: &MatchCheckCtxt, p: @Pat) -> Option<ctor> {
333+
pub fn pat_ctor_id(cx: &MatchCheckCtxt, p: @Pat) -> Option<ctor> {
334334
let pat = raw_pat(p);
335335
match pat.node {
336336
PatWild => { None }
@@ -366,7 +366,7 @@ fn pat_ctor_id(cx: &MatchCheckCtxt, p: @Pat) -> Option<ctor> {
366366
}
367367
}
368368

369-
fn is_wild(cx: &MatchCheckCtxt, p: @Pat) -> bool {
369+
pub fn is_wild(cx: &MatchCheckCtxt, p: @Pat) -> bool {
370370
let pat = raw_pat(p);
371371
match pat.node {
372372
PatWild => { true }
@@ -380,7 +380,7 @@ fn is_wild(cx: &MatchCheckCtxt, p: @Pat) -> bool {
380380
}
381381
}
382382

383-
fn missing_ctor(cx: &MatchCheckCtxt,
383+
pub fn missing_ctor(cx: &MatchCheckCtxt,
384384
m: &matrix,
385385
left_ty: ty::t)
386386
-> Option<ctor> {
@@ -505,7 +505,7 @@ fn missing_ctor(cx: &MatchCheckCtxt,
505505
}
506506
}
507507

508-
fn ctor_arity(cx: &MatchCheckCtxt, ctor: &ctor, ty: ty::t) -> uint {
508+
pub fn ctor_arity(cx: &MatchCheckCtxt, ctor: &ctor, ty: ty::t) -> uint {
509509
match ty::get(ty).sty {
510510
ty::ty_tup(ref fs) => fs.len(),
511511
ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_rptr(*) => 1u,
@@ -528,11 +528,11 @@ fn ctor_arity(cx: &MatchCheckCtxt, ctor: &ctor, ty: ty::t) -> uint {
528528
}
529529
}
530530

531-
fn wild() -> @Pat {
531+
pub fn wild() -> @Pat {
532532
@Pat {id: 0, node: PatWild, span: dummy_sp()}
533533
}
534534

535-
fn specialize(cx: &MatchCheckCtxt,
535+
pub fn specialize(cx: &MatchCheckCtxt,
536536
r: &[@Pat],
537537
ctor_id: &ctor,
538538
arity: uint,
@@ -662,14 +662,15 @@ fn specialize(cx: &MatchCheckCtxt,
662662
_ => None
663663
}
664664
}
665-
PatStruct(_, ref pattern_fields, _) => {
665+
PatStruct(_, ref flds, _) => {
666666
// Is this a struct or an enum variant?
667667
match cx.tcx.def_map.get_copy(&pat_id) {
668668
DefVariant(_, variant_id, _) => {
669669
if variant(variant_id) == *ctor_id {
670-
let struct_fields = ty::lookup_struct_fields(cx.tcx, variant_id);
671-
let args = struct_fields.map(|sf| {
672-
match pattern_fields.iter().find(|f| f.ident.name == sf.name) {
670+
// FIXME #4731: Is this right? --pcw
671+
let args = flds.map(|ty_field| {
672+
match flds.iter().find(|f|
673+
f.ident == ty_field.ident) {
673674
Some(f) => f.pat,
674675
_ => wild()
675676
}
@@ -699,7 +700,7 @@ fn specialize(cx: &MatchCheckCtxt,
699700
}
700701
}
701702
let args = class_fields.iter().map(|class_field| {
702-
match pattern_fields.iter().find(|f|
703+
match flds.iter().find(|f|
703704
f.ident.name == class_field.name) {
704705
Some(f) => f.pat,
705706
_ => wild()
@@ -797,12 +798,12 @@ fn specialize(cx: &MatchCheckCtxt,
797798
}
798799
}
799800

800-
fn default(cx: &MatchCheckCtxt, r: &[@Pat]) -> Option<~[@Pat]> {
801+
pub fn default(cx: &MatchCheckCtxt, r: &[@Pat]) -> Option<~[@Pat]> {
801802
if is_wild(cx, r[0]) { Some(r.tail().to_owned()) }
802803
else { None }
803804
}
804805

805-
fn check_local(v: &mut CheckMatchVisitor,
806+
pub fn check_local(v: &mut CheckMatchVisitor,
806807
cx: &MatchCheckCtxt,
807808
loc: @Local,
808809
s: ()) {
@@ -816,7 +817,7 @@ fn check_local(v: &mut CheckMatchVisitor,
816817
check_legality_of_move_bindings(cx, false, [ loc.pat ]);
817818
}
818819

819-
fn check_fn(v: &mut CheckMatchVisitor,
820+
pub fn check_fn(v: &mut CheckMatchVisitor,
820821
cx: &MatchCheckCtxt,
821822
kind: &visit::fn_kind,
822823
decl: &fn_decl,
@@ -833,7 +834,7 @@ fn check_fn(v: &mut CheckMatchVisitor,
833834
}
834835
}
835836

836-
fn is_refutable(cx: &MatchCheckCtxt, pat: &Pat) -> bool {
837+
pub fn is_refutable(cx: &MatchCheckCtxt, pat: &Pat) -> bool {
837838
match cx.tcx.def_map.find(&pat.id) {
838839
Some(&DefVariant(enum_id, _, _)) => {
839840
if ty::enum_variants(cx.tcx, enum_id).len() != 1u {
@@ -871,7 +872,7 @@ fn is_refutable(cx: &MatchCheckCtxt, pat: &Pat) -> bool {
871872

872873
// Legality of move bindings checking
873874

874-
fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
875+
pub fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
875876
has_guard: bool,
876877
pats: &[@Pat]) {
877878
let tcx = cx.tcx;

0 commit comments

Comments
 (0)