Skip to content

Commit c47871d

Browse files
committed
---
yaml --- r: 105179 b: refs/heads/snap-stage3 c: e12fda1 h: refs/heads/master i: 105177: fad1e33 105175: 26be17b v: v3
1 parent 3d0a457 commit c47871d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+290
-1184
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 62f1d68439dcfd509eaca29887afa97f22938373
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 25e523833e16c291618c624c1c44c4705b77d6ff
4+
refs/heads/snap-stage3: e12fda1c6e3bb8ac6e2b7408afda6db3c146d790
55
refs/heads/try: db814977d07bd798feb24f6b74c00800ef458a13
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libnative/io/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,8 @@ fn translate_error(errno: i32, detail: bool) -> IoError {
9797
libc::WSAECONNREFUSED => (io::ConnectionRefused, "connection refused"),
9898
libc::WSAECONNRESET => (io::ConnectionReset, "connection reset"),
9999
libc::WSAEACCES => (io::PermissionDenied, "permission denied"),
100-
libc::WSAEWOULDBLOCK => {
101-
(io::ResourceUnavailable, "resource temporarily unavailable")
102-
}
100+
libc::WSAEWOULDBLOCK =>
101+
(io::ResourceUnavailable, "resource temporarily unavailable"),
103102
libc::WSAENOTCONN => (io::NotConnected, "not connected"),
104103
libc::WSAECONNABORTED => (io::ConnectionAborted, "connection aborted"),
105104
libc::WSAEADDRNOTAVAIL => (io::ConnectionRefused, "address not available"),

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,11 +1019,10 @@ pub fn get_struct_fields(intr: @IdentInterner, cdata: Cmd, id: ast::NodeId)
10191019
});
10201020
reader::tagged_docs(item, tag_item_unnamed_field, |an_item| {
10211021
let did = item_def_id(an_item, cdata);
1022-
let f = item_family(an_item);
10231022
result.push(ty::field_ty {
10241023
name: special_idents::unnamed_field.name,
10251024
id: did,
1026-
vis: struct_field_family_to_visibility(f),
1025+
vis: ast::Inherited,
10271026
});
10281027
true
10291028
});

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,8 @@ fn encode_struct_fields(ebml_w: &mut writer::Encoder,
310310
encode_def_id(ebml_w, local_def(f.node.id));
311311
ebml_w.end_tag();
312312
}
313-
UnnamedField(vis) => {
313+
UnnamedField => {
314314
ebml_w.start_tag(tag_item_unnamed_field);
315-
encode_struct_field_family(ebml_w, vis);
316315
encode_def_id(ebml_w, local_def(f.node.id));
317316
ebml_w.end_tag();
318317
}
@@ -514,7 +513,8 @@ fn each_auxiliary_node_id(item: @Item, callback: |NodeId| -> bool) -> bool {
514513
// If this is a newtype struct, return the constructor.
515514
match struct_def.ctor_id {
516515
Some(ctor_id) if struct_def.fields.len() > 0 &&
517-
struct_def.fields.get(0).node.kind.is_unnamed() => {
516+
struct_def.fields.get(0).node.kind ==
517+
ast::UnnamedField => {
518518
continue_ = callback(ctor_id);
519519
}
520520
_ => {}
@@ -690,7 +690,7 @@ fn encode_info_for_struct(ecx: &EncodeContext,
690690
for field in fields.iter() {
691691
let (nm, vis) = match field.node.kind {
692692
NamedField(nm, vis) => (nm, vis),
693-
UnnamedField(vis) => (special_idents::unnamed_field, vis)
693+
UnnamedField => (special_idents::unnamed_field, Inherited)
694694
};
695695

696696
let id = field.node.id;

branches/snap-stage3/src/librustc/middle/privacy.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,11 +1001,15 @@ impl<'a> SanePrivacyVisitor<'a> {
10011001
};
10021002
for f in def.fields.iter() {
10031003
match f.node.kind {
1004+
ast::NamedField(_, ast::Public) if public_def => {
1005+
tcx.sess.span_err(f.span, "unnecessary `pub` \
1006+
visibility");
1007+
}
10041008
ast::NamedField(_, ast::Private) if !public_def => {
10051009
tcx.sess.span_err(f.span, "unnecessary `priv` \
10061010
visibility");
10071011
}
1008-
ast::NamedField(..) | ast::UnnamedField(..) => {}
1012+
ast::NamedField(..) | ast::UnnamedField => {}
10091013
}
10101014
}
10111015
};
@@ -1102,7 +1106,7 @@ impl<'a> SanePrivacyVisitor<'a> {
11021106
for f in def.fields.iter() {
11031107
match f.node.kind {
11041108
ast::NamedField(_, p) => check_inherited(f.span, p),
1105-
ast::UnnamedField(..) => {}
1109+
ast::UnnamedField => {}
11061110
}
11071111
}
11081112
};

branches/snap-stage3/src/librustc/middle/trans/_match.rs

Lines changed: 41 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -256,23 +256,43 @@ enum Opt {
256256
vec_len(/* length */ uint, VecLenOpt, /*range of matches*/(uint, uint))
257257
}
258258

259-
fn lit_to_expr(tcx: &ty::ctxt, a: &Lit) -> @ast::Expr {
260-
match *a {
261-
ExprLit(existing_a_expr) => existing_a_expr,
262-
ConstLit(a_const) => const_eval::lookup_const_by_id(tcx, a_const).unwrap(),
263-
UnitLikeStructLit(_) => fail!("lit_to_expr: unexpected struct lit"),
264-
}
265-
}
266-
267259
fn opt_eq(tcx: &ty::ctxt, a: &Opt, b: &Opt) -> bool {
268260
match (a, b) {
269-
(&lit(UnitLikeStructLit(a)), &lit(UnitLikeStructLit(b))) => a == b,
270261
(&lit(a), &lit(b)) => {
271-
let a_expr = lit_to_expr(tcx, &a);
272-
let b_expr = lit_to_expr(tcx, &b);
273-
match const_eval::compare_lit_exprs(tcx, a_expr, b_expr) {
274-
Some(val1) => val1 == 0,
275-
None => fail!("compare_list_exprs: type mismatch"),
262+
match (a, b) {
263+
(UnitLikeStructLit(a), UnitLikeStructLit(b)) => a == b,
264+
_ => {
265+
let a_expr;
266+
match a {
267+
ExprLit(existing_a_expr) => a_expr = existing_a_expr,
268+
ConstLit(a_const) => {
269+
let e = const_eval::lookup_const_by_id(tcx, a_const);
270+
a_expr = e.unwrap();
271+
}
272+
UnitLikeStructLit(_) => {
273+
fail!("UnitLikeStructLit should have been handled \
274+
above")
275+
}
276+
}
277+
278+
let b_expr;
279+
match b {
280+
ExprLit(existing_b_expr) => b_expr = existing_b_expr,
281+
ConstLit(b_const) => {
282+
let e = const_eval::lookup_const_by_id(tcx, b_const);
283+
b_expr = e.unwrap();
284+
}
285+
UnitLikeStructLit(_) => {
286+
fail!("UnitLikeStructLit should have been handled \
287+
above")
288+
}
289+
}
290+
291+
match const_eval::compare_lit_exprs(tcx, a_expr, b_expr) {
292+
Some(val1) => val1 == 0,
293+
None => fail!("compare_list_exprs: type mismatch"),
294+
}
295+
}
276296
}
277297
}
278298
(&range(a1, a2), &range(b1, b2)) => {
@@ -290,42 +310,6 @@ fn opt_eq(tcx: &ty::ctxt, a: &Opt, b: &Opt) -> bool {
290310
}
291311
}
292312

293-
fn opt_overlap(tcx: &ty::ctxt, a: &Opt, b: &Opt) -> bool {
294-
match (a, b) {
295-
(&lit(a), &lit(b)) => {
296-
let a_expr = lit_to_expr(tcx, &a);
297-
let b_expr = lit_to_expr(tcx, &b);
298-
match const_eval::compare_lit_exprs(tcx, a_expr, b_expr) {
299-
Some(val1) => val1 == 0,
300-
None => fail!("opt_overlap: type mismatch"),
301-
}
302-
}
303-
304-
(&range(a1, a2), &range(b1, b2)) => {
305-
let m1 = const_eval::compare_lit_exprs(tcx, a1, b2);
306-
let m2 = const_eval::compare_lit_exprs(tcx, b1, a2);
307-
match (m1, m2) {
308-
// two ranges [a1, a2] and [b1, b2] overlap iff:
309-
// a1 <= b2 && b1 <= a2
310-
(Some(val1), Some(val2)) => (val1 <= 0 && val2 <= 0),
311-
_ => fail!("opt_overlap: type mismatch"),
312-
}
313-
}
314-
315-
(&range(a1, a2), &lit(b)) | (&lit(b), &range(a1, a2)) => {
316-
let b_expr = lit_to_expr(tcx, &b);
317-
let m1 = const_eval::compare_lit_exprs(tcx, a1, b_expr);
318-
let m2 = const_eval::compare_lit_exprs(tcx, a2, b_expr);
319-
match (m1, m2) {
320-
// b is in range [a1, a2] iff a1 <= b and b <= a2
321-
(Some(val1), Some(val2)) => (val1 <= 0 && 0 <= val2),
322-
_ => fail!("opt_overlap: type mismatch"),
323-
}
324-
}
325-
_ => fail!("opt_overlap: expect lit or range")
326-
}
327-
}
328-
329313
pub enum opt_result<'a> {
330314
single_result(Result<'a>),
331315
lower_bound(Result<'a>),
@@ -506,7 +490,7 @@ fn assert_is_binding_or_wild(bcx: &Block, p: @ast::Pat) {
506490
}
507491
}
508492

509-
type enter_pat<'a> = 'a |@ast::Pat| -> Option<Vec<@ast::Pat>>;
493+
type enter_pat<'a> = 'a |@ast::Pat| -> Option<Vec<@ast::Pat> >;
510494

511495
fn enter_match<'r,'b>(
512496
bcx: &'b Block<'b>,
@@ -648,30 +632,16 @@ fn enter_opt<'r,'b>(
648632
let tcx = bcx.tcx();
649633
let dummy = @ast::Pat {id: 0, node: ast::PatWild, span: DUMMY_SP};
650634
let mut i = 0;
651-
// By the virtue of fact that we are in `trans` already, `enter_opt` is able
652-
// to prune sub-match tree aggressively based on exact equality. But when it
653-
// comes to literal or range, that strategy may lead to wrong result if there
654-
// are guard function or multiple patterns inside tuple; in that case, pruning
655-
// based on the overlap of patterns is required.
656-
//
657-
// Ideally, when constructing the sub-match tree for certain arm, only those
658-
// arms beneath it matter. But that isn't how algorithm works right now and
659-
// all other arms are taken into consideration when computing `guarded` below.
660-
// That is ok since each round of `compile_submatch` guarantees to trim one
661-
// "column" of arm patterns and the algorithm will converge.
662-
let guarded = m.iter().any(|x| x.data.arm.guard.is_some());
663-
let multi_pats = m.len() > 0 && m[0].pats.len() > 1;
664635
enter_match(bcx, tcx.def_map, m, col, val, |p| {
665636
let answer = match p.node {
666637
ast::PatEnum(..) |
667638
ast::PatIdent(_, _, None) if pat_is_const(tcx.def_map, p) => {
668639
let const_def = tcx.def_map.borrow().get_copy(&p.id);
669640
let const_def_id = ast_util::def_id_of_def(const_def);
670-
let konst = lit(ConstLit(const_def_id));
671-
match guarded || multi_pats {
672-
false if opt_eq(tcx, &konst, opt) => Some(Vec::new()),
673-
true if opt_overlap(tcx, &konst, opt) => Some(Vec::new()),
674-
_ => None,
641+
if opt_eq(tcx, &lit(ConstLit(const_def_id)), opt) {
642+
Some(Vec::new())
643+
} else {
644+
None
675645
}
676646
}
677647
ast::PatEnum(_, ref subpats) => {
@@ -696,20 +666,10 @@ fn enter_opt<'r,'b>(
696666
}
697667
}
698668
ast::PatLit(l) => {
699-
let lit_expr = lit(ExprLit(l));
700-
match guarded || multi_pats {
701-
false if opt_eq(tcx, &lit_expr, opt) => Some(Vec::new()),
702-
true if opt_overlap(tcx, &lit_expr, opt) => Some(Vec::new()),
703-
_ => None,
704-
}
669+
if opt_eq(tcx, &lit(ExprLit(l)), opt) {Some(Vec::new())} else {None}
705670
}
706671
ast::PatRange(l1, l2) => {
707-
let rng = range(l1, l2);
708-
match guarded || multi_pats {
709-
false if opt_eq(tcx, &rng, opt) => Some(Vec::new()),
710-
true if opt_overlap(tcx, &rng, opt) => Some(Vec::new()),
711-
_ => None,
712-
}
672+
if opt_eq(tcx, &range(l1, l2), opt) {Some(Vec::new())} else {None}
713673
}
714674
ast::PatStruct(_, ref field_pats, _) => {
715675
if opt_eq(tcx, &variant_opt(bcx, p.id), opt) {

branches/snap-stage3/src/librustc/middle/trans/base.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,6 @@ fn get_extern_rust_fn(ccx: &CrateContext, inputs: &[ty::t], output: ty::t,
246246
pub fn decl_rust_fn(ccx: &CrateContext, has_env: bool,
247247
inputs: &[ty::t], output: ty::t,
248248
name: &str) -> ValueRef {
249-
use middle::ty::{BrAnon, ReLateBound};
250-
251249
let llfty = type_of_rust_fn(ccx, has_env, inputs, output);
252250
let llfn = decl_cdecl_fn(ccx.llmod, name, llfty, output);
253251

@@ -267,16 +265,7 @@ pub fn decl_rust_fn(ccx: &CrateContext, has_env: bool,
267265
unsafe {
268266
llvm::LLVMAddAttribute(llarg, lib::llvm::NoAliasAttribute as c_uint);
269267
}
270-
},
271-
// When a reference in an argument has no named lifetime, it's
272-
// impossible for that reference to escape this function(ie, be
273-
// returned).
274-
ty::ty_rptr(ReLateBound(_, BrAnon(_)), _) => {
275-
debug!("marking argument of {} as nocapture because of anonymous lifetime", name);
276-
unsafe {
277-
llvm::LLVMAddAttribute(llarg, lib::llvm::NoCaptureAttribute as c_uint);
278-
}
279-
},
268+
}
280269
_ => {
281270
// For non-immediate arguments the callee gets its own copy of
282271
// the value on the stack, so there are no aliases

branches/snap-stage3/src/librustc/middle/trans/callee.rs

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use std::slice;
2020

2121
use back::abi;
2222
use driver::session;
23-
use lib::llvm::{ValueRef, NoAliasAttribute, StructRetAttribute, NoCaptureAttribute};
23+
use lib::llvm::{ValueRef, NoAliasAttribute, StructRetAttribute};
2424
use lib::llvm::llvm;
2525
use metadata::csearch;
2626
use middle::trans::base;
@@ -661,15 +661,9 @@ pub fn trans_call_inner<'a>(
661661
llargs.push(opt_llretslot.unwrap());
662662
}
663663

664-
// start at 1, because index 0 is the return value of the llvm func
665-
let mut first_arg_offset = 1;
666-
667664
// Push the environment (or a trait object's self).
668665
match (llenv, llself) {
669-
(Some(llenv), None) => {
670-
first_arg_offset += 1;
671-
llargs.push(llenv)
672-
},
666+
(Some(llenv), None) => llargs.push(llenv),
673667
(None, Some(llself)) => llargs.push(llself),
674668
_ => {}
675669
}
@@ -688,11 +682,6 @@ pub fn trans_call_inner<'a>(
688682
let mut attrs = Vec::new();
689683
if type_of::return_uses_outptr(ccx, ret_ty) {
690684
attrs.push((1, StructRetAttribute));
691-
// The outptr can be noalias and nocapture because it's entirely
692-
// invisible to the program.
693-
attrs.push((1, NoAliasAttribute));
694-
attrs.push((1, NoCaptureAttribute));
695-
first_arg_offset += 1;
696685
}
697686

698687
// The `noalias` attribute on the return value is useful to a
@@ -706,30 +695,6 @@ pub fn trans_call_inner<'a>(
706695
_ => {}
707696
}
708697

709-
debug!("trans_callee_inner: first_arg_offset={}", first_arg_offset);
710-
711-
for (idx, &t) in ty::ty_fn_args(callee_ty).iter().enumerate()
712-
.map(|(i, v)| (i+first_arg_offset, v)) {
713-
use middle::ty::{BrAnon, ReLateBound};
714-
if !type_is_immediate(ccx, t) {
715-
// if it's not immediate, we have a program-invisible pointer,
716-
// which it can't possibly capture
717-
attrs.push((idx, NoCaptureAttribute));
718-
debug!("trans_callee_inner: argument {} nocapture because it's non-immediate", idx);
719-
continue;
720-
}
721-
722-
let t_ = ty::get(t);
723-
match t_.sty {
724-
ty::ty_rptr(ReLateBound(_, BrAnon(_)), _) => {
725-
debug!("trans_callee_inner: argument {} nocapture because \
726-
of anonymous lifetime", idx);
727-
attrs.push((idx, NoCaptureAttribute));
728-
},
729-
_ => { }
730-
}
731-
}
732-
733698
// Invoke the actual rust fn and update bcx/llresult.
734699
let (llret, b) = base::invoke(bcx,
735700
llfn,

branches/snap-stage3/src/librustc/middle/ty.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3900,7 +3900,7 @@ impl VariantInfo {
39003900
let arg_names = fields.iter().map(|field| {
39013901
match field.node.kind {
39023902
NamedField(ident, _) => ident,
3903-
UnnamedField(..) => cx.sess.bug(
3903+
UnnamedField => cx.sess.bug(
39043904
"enum_variants: all fields in struct must have a name")
39053905
}
39063906
}).collect();
@@ -4264,11 +4264,11 @@ fn struct_field_tys(fields: &[StructField]) -> Vec<field_ty> {
42644264
vis: visibility,
42654265
}
42664266
}
4267-
UnnamedField(visibility) => {
4267+
UnnamedField => {
42684268
field_ty {
42694269
name: syntax::parse::token::special_idents::unnamed_field.name,
42704270
id: ast_util::local_def(field.node.id),
4271-
vis: visibility,
4271+
vis: ast::Public,
42724272
}
42734273
}
42744274
}

branches/snap-stage3/src/librustc/middle/typeck/collect.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,8 @@ pub fn convert_struct(ccx: &CrateCtxt,
695695
write_ty_to_tcx(tcx, ctor_id, selfty);
696696

697697
tcx.tcache.borrow_mut().insert(local_def(ctor_id), tpt);
698-
} else if struct_def.fields.get(0).node.kind.is_unnamed() {
698+
} else if struct_def.fields.get(0).node.kind ==
699+
ast::UnnamedField {
699700
// Tuple-like.
700701
let inputs = struct_def.fields.map(
701702
|field| tcx.tcache.borrow().get(

0 commit comments

Comments
 (0)