Skip to content

Commit 820261f

Browse files
committed
---
yaml --- r: 115455 b: refs/heads/try c: 81bc32d h: refs/heads/master i: 115453: 4e4b4f6 115451: c94f493 115447: 31f561b 115439: 1ca2770 115423: eba69c9 115391: d2dcacd 115327: 4bd0a7a 115199: 2219769 v: v3
1 parent a69d176 commit 820261f

File tree

5 files changed

+34
-129
lines changed

5 files changed

+34
-129
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: bee4e6adac17f87b1cdc26ab69f8c0f5d82575a3
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ec0258a381b88b5574e3f8ce72ae553ac3a574b7
5-
refs/heads/try: fd625dda9a25c054d622e20822f2889f17b15aa6
5+
refs/heads/try: 81bc32d9750f34a2218e6ba8f2d2c1a101f8a8a1
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/doc/tutorial.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -468,19 +468,16 @@ Unlike in C, there is no "falling through" between arms: only one arm
468468
executes, and it doesn't have to explicitly `break` out of the
469469
construct when it is finished.
470470

471-
A `match` arm consists of a *pattern*, then an arrow `=>`, followed by
472-
an *action* (expression). Literals are valid patterns and match only
473-
their own value. A single arm may match multiple different patterns by
474-
combining them with the pipe operator (`|`), so long as every pattern
475-
binds the same set of variables. Ranges of numeric literal patterns
476-
can be expressed with two dots, as in `M..N`. The underscore (`_`) is
477-
a wildcard pattern that matches any single value. (`..`) is a different
478-
wildcard that can match one or more fields in an `enum` variant.
479-
480-
The patterns in a match arm are followed by a fat arrow, `=>`, then an
481-
expression to evaluate. Each case is separated by commas. It's often
482-
convenient to use a block expression for each case, in which case the
483-
commas are optional.
471+
A `match` arm consists of a *pattern*, then a fat arrow `=>`, followed
472+
by an *action* (expression). Each case is separated by commas. It is
473+
often convenient to use a block expression for each case, in which case
474+
the commas are optional as shown below. Literals are valid patterns and
475+
match only their own value. A single arm may match multiple different
476+
patterns by combining them with the pipe operator (`|`), so long as every
477+
pattern binds the same set of variables. Ranges of numeric literal
478+
patterns can be expressed with two dots, as in `M..N`. The underscore
479+
(`_`) is a wildcard pattern that matches any single value. (`..`) is a
480+
different wildcard that can match one or more fields in an `enum` variant.
484481

485482
~~~
486483
# let my_number = 1;

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

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -779,26 +779,6 @@ pub fn trans_const(ccx: &CrateContext, r: &Repr, discr: Disr,
779779
}
780780
}
781781

782-
/**
783-
* Compute struct field offsets relative to struct begin.
784-
*/
785-
fn compute_struct_field_offsets(ccx: &CrateContext, st: &Struct) -> Vec<u64> {
786-
let mut offsets = vec!();
787-
788-
let mut offset = 0;
789-
for &ty in st.fields.iter() {
790-
let llty = type_of::sizing_type_of(ccx, ty);
791-
if !st.packed {
792-
let type_align = machine::llalign_of_min(ccx, llty) as u64;
793-
offset = roundup(offset, type_align);
794-
}
795-
offsets.push(offset);
796-
offset += machine::llsize_of_alloc(ccx, llty) as u64;
797-
}
798-
assert_eq!(st.fields.len(), offsets.len());
799-
offsets
800-
}
801-
802782
/**
803783
* Building structs is a little complicated, because we might need to
804784
* insert padding if a field's value is less aligned than its type.
@@ -813,32 +793,26 @@ fn build_const_struct(ccx: &CrateContext, st: &Struct, vals: &[ValueRef])
813793
-> Vec<ValueRef> {
814794
assert_eq!(vals.len(), st.fields.len());
815795

816-
let target_offsets = compute_struct_field_offsets(ccx, st);
817-
818-
// offset of current value
819796
let mut offset = 0;
820797
let mut cfields = Vec::new();
821-
for (&val, &target_offset) in vals.iter().zip(target_offsets.iter()) {
822-
if !st.packed {
823-
let val_align = machine::llalign_of_min(ccx, val_ty(val))
824-
/*bad*/as u64;
825-
offset = roundup(offset, val_align);
826-
}
798+
for (i, &ty) in st.fields.iter().enumerate() {
799+
let llty = type_of::sizing_type_of(ccx, ty);
800+
let type_align = machine::llalign_of_min(ccx, llty)
801+
/*bad*/as u64;
802+
let val_align = machine::llalign_of_min(ccx, val_ty(vals[i]))
803+
/*bad*/as u64;
804+
let target_offset = roundup(offset, type_align);
805+
offset = roundup(offset, val_align);
827806
if offset != target_offset {
828807
cfields.push(padding(ccx, target_offset - offset));
829808
offset = target_offset;
830809
}
831-
assert!(!is_undef(val));
832-
cfields.push(val);
833-
offset += machine::llsize_of_alloc(ccx, val_ty(val)) as u64;
834-
}
835-
836-
assert!(offset <= st.size);
837-
if offset != st.size {
838-
cfields.push(padding(ccx, st.size - offset));
810+
assert!(!is_undef(vals[i]));
811+
cfields.push(vals[i]);
812+
offset += machine::llsize_of_alloc(ccx, llty) as u64
839813
}
840814

841-
cfields
815+
return cfields;
842816
}
843817

844818
fn padding(ccx: &CrateContext, size: u64) -> ValueRef {

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ fn decl_fn(llmod: ModuleRef, name: &str, cc: lib::llvm::CallConv,
186186
}
187187
}
188188
// `~` pointer return values never alias because ownership is transferred
189+
// FIXME #6750 ~Trait cannot be directly marked as
190+
// noalias because the actual object pointer is nested.
189191
ty::ty_uniq(..) // | ty::ty_trait(_, _, ty::UniqTraitStore, _, _)
190192
=> {
191193
unsafe {
@@ -256,25 +258,23 @@ pub fn decl_rust_fn(ccx: &CrateContext, has_env: bool,
256258
let llarg = unsafe { llvm::LLVMGetParam(llfn, (offset + i) as c_uint) };
257259
match ty::get(arg_ty).sty {
258260
// `~` pointer parameters never alias because ownership is transferred
259-
ty::ty_uniq(..) => {
261+
// FIXME #6750 ~Trait cannot be directly marked as
262+
// noalias because the actual object pointer is nested.
263+
ty::ty_uniq(..) | // ty::ty_trait(_, _, ty::UniqTraitStore, _, _) |
264+
ty::ty_closure(~ty::ClosureTy {store: ty::UniqTraitStore, ..}) => {
260265
unsafe {
261266
llvm::LLVMAddAttribute(llarg, lib::llvm::NoAliasAttribute as c_uint);
262267
}
263-
}
264-
// `&mut` pointer parameters never alias other parameters, or mutable global data
265-
ty::ty_rptr(_, mt) if mt.mutbl == ast::MutMutable => {
266-
unsafe {
267-
llvm::LLVMAddAttribute(llarg, lib::llvm::NoAliasAttribute as c_uint);
268-
}
269-
}
270-
// When a reference in an argument has no named lifetime, it's impossible for that
271-
// reference to escape this function (returned or stored beyond the call by a closure).
268+
},
269+
// When a reference in an argument has no named lifetime, it's
270+
// impossible for that reference to escape this function(ie, be
271+
// returned).
272272
ty::ty_rptr(ReLateBound(_, BrAnon(_)), _) => {
273273
debug!("marking argument of {} as nocapture because of anonymous lifetime", name);
274274
unsafe {
275275
llvm::LLVMAddAttribute(llarg, lib::llvm::NoCaptureAttribute as c_uint);
276276
}
277-
}
277+
},
278278
_ => {
279279
// For non-immediate arguments the callee gets its own copy of
280280
// the value on the stack, so there are no aliases

branches/try/src/test/run-pass/trans-tag-static-padding.rs

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)