Skip to content

Commit 173705b

Browse files
committed
---
yaml --- r: 128863 b: refs/heads/try c: d3c71a5 h: refs/heads/master i: 128861: 7149dad 128859: 62b88fa 128855: 05b6d93 128847: ffbeaf4 128831: ebf7a8f v: v3
1 parent 4f45cfe commit 173705b

File tree

13 files changed

+95
-221
lines changed

13 files changed

+95
-221
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 07d86b46a949a94223da714e35b343243e4ecce4
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a86d9ad15e339ab343a12513f9c90556f677b9ca
5-
refs/heads/try: 78ec3904b443c818d9f83e837ca13e5f197db740
5+
refs/heads/try: d3c71a5890b8f8a9e03cac11b769e07bb3f2a450
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/etc/vim/ftplugin/rust.vim

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,6 @@ if exists("g:loaded_delimitMate")
5656
let b:delimitMate_excluded_regions = delimitMate#Get("excluded_regions") . ',rustLifetimeCandidate,rustGenericLifetimeCandidate'
5757
endif
5858

59-
if has("folding") && exists('g:rust_fold') && g:rust_fold != 0
60-
let b:rust_set_foldmethod=1
61-
setlocal foldmethod=syntax
62-
if g:rust_fold == 2
63-
setlocal foldlevel<
64-
else
65-
setlocal foldlevel=99
66-
endif
67-
endif
68-
6959
if has('conceal') && exists('g:rust_conceal')
7060
let b:rust_set_conceallevel=1
7161
setlocal conceallevel=2
@@ -118,10 +108,6 @@ let b:undo_ftplugin = "
118108
\|else
119109
\|unlet! b:delimitMate_excluded_regions
120110
\|endif
121-
\|if exists('b:rust_set_foldmethod')
122-
\|setlocal foldmethod< foldlevel<
123-
\|unlet b:rust_set_foldmethod
124-
\|endif
125111
\|if exists('b:rust_set_conceallevel')
126112
\|setlocal conceallevel<
127113
\|unlet b:rust_set_conceallevel

branches/try/src/etc/vim/syntax/rust.vim

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ elseif exists("b:current_syntax")
1111
finish
1212
endif
1313

14+
" Fold settings {{{1
15+
16+
if has("folding") && exists('g:rust_fold') && g:rust_fold != 0
17+
setlocal foldmethod=syntax
18+
if g:rust_fold == 2
19+
setlocal foldlevel<
20+
else
21+
setlocal foldlevel=99
22+
endif
23+
endif
24+
1425
" Syntax definitions {{{1
1526
" Basic keywords {{{2
1627
syn keyword rustConditional match if else

branches/try/src/libnum/complex.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,6 @@ mod test {
257257
assert_eq!(_1_0i.inv(), _1_0i.inv());
258258
}
259259

260-
#[test]
261-
#[should_fail]
262-
fn test_divide_by_zero_natural() {
263-
let n = Complex::new(2i, 3i);
264-
let d = Complex::new(0, 0);
265-
let _x = n / d;
266-
}
267-
268260
#[test]
269261
#[should_fail]
270262
#[ignore]

branches/try/src/librustc/back/link.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,6 +1472,9 @@ fn link_args(cmd: &mut Command,
14721472
// [1] - https://sourceware.org/bugzilla/show_bug.cgi?id=13130
14731473
// [2] - https://code.google.com/p/go/issues/detail?id=2139
14741474
cmd.arg("-Wl,--enable-long-section-names");
1475+
1476+
// Always enable DEP (NX bit) when it is available
1477+
cmd.arg("-Wl,--nxcompat");
14751478
}
14761479

14771480
if sess.targ_cfg.os == abi::OsAndroid {

branches/try/src/librustc/middle/trans/base.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1947,10 +1947,12 @@ pub fn trans_named_tuple_constructor<'a>(mut bcx: &'a Block<'a>,
19471947
};
19481948

19491949
if !type_is_zero_size(ccx, result_ty) {
1950+
let repr = adt::represent_type(ccx, result_ty);
1951+
19501952
match args {
19511953
callee::ArgExprs(exprs) => {
19521954
let fields = exprs.iter().map(|x| *x).enumerate().collect::<Vec<_>>();
1953-
bcx = expr::trans_adt(bcx, result_ty, disr, fields.as_slice(),
1955+
bcx = expr::trans_adt(bcx, &*repr, disr, fields.as_slice(),
19541956
None, expr::SaveIn(llresult));
19551957
}
19561958
_ => ccx.sess().bug("expected expr as arguments for variant/struct tuple constructor")
@@ -2278,7 +2280,7 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t)
22782280
match ty::get(ret_ty).sty {
22792281
// `~` pointer return values never alias because ownership
22802282
// is transferred
2281-
ty::ty_uniq(it) if match ty::get(it).sty {
2283+
ty::ty_uniq(it) if match ty::get(it).sty {
22822284
ty::ty_str | ty::ty_vec(..) | ty::ty_trait(..) => true, _ => false
22832285
} => {}
22842286
ty::ty_uniq(_) => {
@@ -2354,21 +2356,15 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t)
23542356
}
23552357

23562358
// `&mut` pointer parameters never alias other parameters, or mutable global data
2357-
//
2358-
// `&T` where `T` contains no `UnsafeCell<U>` is immutable, and can be marked as both
2359-
// `readonly` and `noalias`, as LLVM's definition of `noalias` is based solely on
2360-
// memory dependencies rather than pointer equality
2359+
// `&` pointer parameters never alias either (for LLVM's purposes) as long as the
2360+
// interior is safe
23612361
ty::ty_rptr(b, mt) if mt.mutbl == ast::MutMutable ||
23622362
!ty::type_contents(ccx.tcx(), mt.ty).interior_unsafe() => {
23632363

23642364
let llsz = llsize_of_real(ccx, type_of::type_of(ccx, mt.ty));
23652365
attrs.arg(idx, llvm::NoAliasAttribute)
23662366
.arg(idx, llvm::DereferenceableAttribute(llsz));
23672367

2368-
if mt.mutbl == ast::MutImmutable {
2369-
attrs.arg(idx, llvm::ReadOnlyAttribute);
2370-
}
2371-
23722368
match b {
23732369
ReLateBound(_, BrAnon(_)) => {
23742370
attrs.arg(idx, llvm::NoCaptureAttribute);

branches/try/src/librustc/middle/trans/controlflow.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,13 @@ pub fn trans_for<'a>(
330330
// Check the discriminant; if the `None` case, exit the loop.
331331
let option_representation = adt::represent_type(loopback_bcx_out.ccx(),
332332
method_result_type);
333+
let i8_type = Type::i8(loopback_bcx_out.ccx());
333334
let lldiscriminant = adt::trans_get_discr(loopback_bcx_out,
334335
&*option_representation,
335336
option_datum.val,
336-
None);
337-
let i1_type = Type::i1(loopback_bcx_out.ccx());
338-
let llcondition = Trunc(loopback_bcx_out, lldiscriminant, i1_type);
337+
Some(i8_type));
338+
let llzero = C_u8(loopback_bcx_out.ccx(), 0);
339+
let llcondition = ICmp(loopback_bcx_out, IntNE, lldiscriminant, llzero);
339340
CondBr(loopback_bcx_out, llcondition, body_bcx_in.llbb, cleanup_llbb);
340341

341342
// Now we're in the body. Unpack the `Option` value into the programmer-

branches/try/src/librustc/middle/trans/expr.rs

Lines changed: 49 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -746,17 +746,18 @@ fn trans_rvalue_dps_unadjusted<'a>(bcx: &'a Block<'a>,
746746
controlflow::trans_block(bcx, &**blk, dest)
747747
}
748748
ast::ExprStruct(_, ref fields, base) => {
749-
trans_struct(bcx,
750-
fields.as_slice(),
751-
base,
752-
expr.span,
753-
expr.id,
754-
dest)
749+
trans_rec_or_struct(bcx,
750+
fields.as_slice(),
751+
base,
752+
expr.span,
753+
expr.id,
754+
dest)
755755
}
756756
ast::ExprTup(ref args) => {
757+
let repr = adt::represent_type(bcx.ccx(), expr_ty(bcx, expr));
757758
let numbered_fields: Vec<(uint, Gc<ast::Expr>)> =
758759
args.iter().enumerate().map(|(i, arg)| (i, *arg)).collect();
759-
trans_adt(bcx, expr_ty(bcx, expr), 0, numbered_fields.as_slice(), None, dest)
760+
trans_adt(bcx, &*repr, 0, numbered_fields.as_slice(), None, dest)
760761
}
761762
ast::ExprLit(lit) => {
762763
match lit.node {
@@ -1041,13 +1042,16 @@ pub fn with_field_tys<R>(tcx: &ty::ctxt,
10411042
}
10421043
}
10431044

1044-
fn trans_struct<'a>(bcx: &'a Block<'a>,
1045-
fields: &[ast::Field],
1046-
base: Option<Gc<ast::Expr>>,
1047-
expr_span: codemap::Span,
1048-
id: ast::NodeId,
1049-
dest: Dest) -> &'a Block<'a> {
1045+
fn trans_rec_or_struct<'a>(
1046+
bcx: &'a Block<'a>,
1047+
fields: &[ast::Field],
1048+
base: Option<Gc<ast::Expr>>,
1049+
expr_span: codemap::Span,
1050+
id: ast::NodeId,
1051+
dest: Dest)
1052+
-> &'a Block<'a> {
10501053
let _icx = push_ctxt("trans_rec");
1054+
let bcx = bcx;
10511055

10521056
let ty = node_id_type(bcx, id);
10531057
let tcx = bcx.tcx();
@@ -1088,7 +1092,8 @@ fn trans_struct<'a>(bcx: &'a Block<'a>,
10881092
}
10891093
};
10901094

1091-
trans_adt(bcx, ty, discr, numbered_fields.as_slice(), optbase, dest)
1095+
let repr = adt::represent_type(bcx.ccx(), ty);
1096+
trans_adt(bcx, &*repr, discr, numbered_fields.as_slice(), optbase, dest)
10921097
})
10931098
}
10941099

@@ -1116,71 +1121,60 @@ pub struct StructBaseInfo {
11161121
* - `optbase` contains information on the base struct (if any) from
11171122
* which remaining fields are copied; see comments on `StructBaseInfo`.
11181123
*/
1119-
pub fn trans_adt<'a>(mut bcx: &'a Block<'a>,
1120-
ty: ty::t,
1124+
pub fn trans_adt<'a>(bcx: &'a Block<'a>,
1125+
repr: &adt::Repr,
11211126
discr: ty::Disr,
11221127
fields: &[(uint, Gc<ast::Expr>)],
11231128
optbase: Option<StructBaseInfo>,
11241129
dest: Dest) -> &'a Block<'a> {
11251130
let _icx = push_ctxt("trans_adt");
11261131
let fcx = bcx.fcx;
1127-
let repr = adt::represent_type(bcx.ccx(), ty);
1128-
1129-
// If we don't care about the result, just make a
1130-
// temporary stack slot
1132+
let mut bcx = bcx;
11311133
let addr = match dest {
1132-
SaveIn(pos) => pos,
1133-
Ignore => alloc_ty(bcx, ty, "temp"),
1134+
Ignore => {
1135+
for &(_i, ref e) in fields.iter() {
1136+
bcx = trans_into(bcx, &**e, Ignore);
1137+
}
1138+
for sbi in optbase.iter() {
1139+
// FIXME #7261: this moves entire base, not just certain fields
1140+
bcx = trans_into(bcx, &*sbi.expr, Ignore);
1141+
}
1142+
return bcx;
1143+
}
1144+
SaveIn(pos) => pos
11341145
};
11351146

11361147
// This scope holds intermediates that must be cleaned should
11371148
// failure occur before the ADT as a whole is ready.
11381149
let custom_cleanup_scope = fcx.push_custom_cleanup_scope();
11391150

1140-
// First we trans the base, if we have one, to the dest
1141-
for base in optbase.iter() {
1142-
assert_eq!(discr, 0);
1143-
1144-
match ty::expr_kind(bcx.tcx(), &*base.expr) {
1145-
ty::LvalueExpr => {
1146-
let base_datum = unpack_datum!(bcx, trans_to_lvalue(bcx, &*base.expr, "base"));
1147-
for &(i, t) in base.fields.iter() {
1148-
let datum = base_datum.get_element(
1149-
t, |srcval| adt::trans_field_ptr(bcx, &*repr, srcval, discr, i));
1150-
let dest = adt::trans_field_ptr(bcx, &*repr, addr, discr, i);
1151-
bcx = datum.store_to(bcx, dest);
1152-
}
1153-
},
1154-
ty::RvalueDpsExpr | ty::RvalueDatumExpr => {
1155-
bcx = trans_into(bcx, &*base.expr, SaveIn(addr));
1156-
},
1157-
ty::RvalueStmtExpr => bcx.tcx().sess.bug("unexpected expr kind for struct base expr")
1158-
}
1159-
}
1160-
1161-
// Now, we just overwrite the fields we've explicity specified
11621151
for &(i, ref e) in fields.iter() {
1163-
let dest = adt::trans_field_ptr(bcx, &*repr, addr, discr, i);
1152+
let dest = adt::trans_field_ptr(bcx, repr, addr, discr, i);
11641153
let e_ty = expr_ty_adjusted(bcx, &**e);
11651154
bcx = trans_into(bcx, &**e, SaveIn(dest));
11661155
let scope = cleanup::CustomScope(custom_cleanup_scope);
11671156
fcx.schedule_lifetime_end(scope, dest);
11681157
fcx.schedule_drop_mem(scope, dest, e_ty);
11691158
}
11701159

1171-
adt::trans_set_discr(bcx, &*repr, addr, discr);
1160+
for base in optbase.iter() {
1161+
// FIXME #6573: is it sound to use the destination's repr on the base?
1162+
// And, would it ever be reasonable to be here with discr != 0?
1163+
let base_datum = unpack_datum!(bcx, trans_to_lvalue(bcx, &*base.expr, "base"));
1164+
for &(i, t) in base.fields.iter() {
1165+
let datum = base_datum.get_element(
1166+
t,
1167+
|srcval| adt::trans_field_ptr(bcx, repr, srcval, discr, i));
1168+
let dest = adt::trans_field_ptr(bcx, repr, addr, discr, i);
1169+
bcx = datum.store_to(bcx, dest);
1170+
}
1171+
}
1172+
1173+
adt::trans_set_discr(bcx, repr, addr, discr);
11721174

11731175
fcx.pop_custom_cleanup_scope(custom_cleanup_scope);
11741176

1175-
// If we don't care about the result drop the temporary we made
1176-
match dest {
1177-
SaveIn(_) => bcx,
1178-
Ignore => {
1179-
bcx = glue::drop_ty(bcx, addr, ty);
1180-
base::call_lifetime_end(bcx, addr);
1181-
bcx
1182-
}
1183-
}
1177+
return bcx;
11841178
}
11851179

11861180

branches/try/src/librustc/middle/trans/glue.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,8 @@ fn trans_struct_drop<'a>(bcx: &'a Block<'a>,
250250
let args = vec!(self_arg);
251251

252252
// Add all the fields as a value which needs to be cleaned at the end of
253-
// this scope. Iterate in reverse order so a Drop impl doesn't reverse
254-
// the order in which fields get dropped.
255-
for (i, ty) in st.fields.iter().enumerate().rev() {
253+
// this scope.
254+
for (i, ty) in st.fields.iter().enumerate() {
256255
let llfld_a = adt::struct_field_ptr(variant_cx, &*st, value, i, false);
257256
variant_cx.fcx.schedule_drop_mem(cleanup::CustomScope(field_scope),
258257
llfld_a, *ty);

0 commit comments

Comments
 (0)