Skip to content

Commit 4e7b16c

Browse files
committed
---
yaml --- r: 148718 b: refs/heads/try2 c: 535e806 h: refs/heads/master v: v3
1 parent 394df29 commit 4e7b16c

Some content is hidden

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

63 files changed

+685
-201
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 0d0205a577594b1be55230e07ab93ee3063e008c
8+
refs/heads/try2: 535e806841e1eca7adb9f41796001848f6859637
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libextra/arc.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -47,7 +47,6 @@ use sync::{Mutex, RWLock};
4747
use std::cast;
4848
use std::sync::arc::UnsafeArc;
4949
use std::task;
50-
use std::borrow;
5150

5251
/// As sync::condvar, a mechanism for unlock-and-descheduling and signaling.
5352
pub struct Condvar<'a> {
@@ -465,7 +464,7 @@ impl<T:Freeze + Send> RWArc<T> {
465464
// of this cast is removing the mutability.)
466465
let new_data = data;
467466
// Downgrade ensured the token belonged to us. Just a sanity check.
468-
assert!(borrow::ref_eq(&(*state).data, new_data));
467+
assert!((&(*state).data as *T as uint) == (new_data as *mut T as uint));
469468
// Produce new token
470469
RWReadMode {
471470
data: new_data,

branches/try2/src/libextra/sync.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -18,7 +18,6 @@
1818
*/
1919

2020

21-
use std::borrow;
2221
use std::comm;
2322
use std::unstable::sync::Exclusive;
2423
use std::sync::arc::UnsafeArc;
@@ -634,7 +633,7 @@ impl RWLock {
634633
/// To be called inside of the write_downgrade block.
635634
pub fn downgrade<'a>(&self, token: RWLockWriteMode<'a>)
636635
-> RWLockReadMode<'a> {
637-
if !borrow::ref_eq(self, token.lock) {
636+
if !((self as *RWLock) == (token.lock as *RWLock)) {
638637
fail!("Can't downgrade() with a different rwlock's write_mode!");
639638
}
640639
unsafe {

branches/try2/src/librustc/front/feature_gate.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
4848
("log_syntax", Active),
4949
("trace_macros", Active),
5050
("simd", Active),
51+
("default_type_params", Active),
5152

5253
// These are used to test this portion of the compiler, they don't actually
5354
// mean anything
@@ -234,6 +235,20 @@ impl Visitor<()> for Context {
234235
}
235236
visit::walk_expr(self, e, ());
236237
}
238+
239+
fn visit_generics(&mut self, generics: &ast::Generics, _: ()) {
240+
for type_parameter in generics.ty_params.iter() {
241+
match type_parameter.default {
242+
Some(ty) => {
243+
self.gate_feature("default_type_params", ty.span,
244+
"default type parameters are \
245+
experimental and possibly buggy");
246+
}
247+
None => {}
248+
}
249+
}
250+
visit::walk_generics(self, generics, ());
251+
}
237252
}
238253

239254
pub fn check_crate(sess: Session, crate: &ast::Crate) {

branches/try2/src/librustc/metadata/tydecode.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,9 +573,12 @@ pub fn parse_type_param_def_data(data: &[u8], start: uint,
573573
}
574574

575575
fn parse_type_param_def(st: &mut PState, conv: conv_did) -> ty::TypeParameterDef {
576-
ty::TypeParameterDef {ident: parse_ident(st, ':'),
577-
def_id: parse_def(st, NominalType, |x,y| conv(x,y)),
578-
bounds: @parse_bounds(st, |x,y| conv(x,y))}
576+
ty::TypeParameterDef {
577+
ident: parse_ident(st, ':'),
578+
def_id: parse_def(st, NominalType, |x,y| conv(x,y)),
579+
bounds: @parse_bounds(st, |x,y| conv(x,y)),
580+
default: parse_opt(st, |st| parse_ty(st, |x,y| conv(x,y)))
581+
}
579582
}
580583

581584
fn parse_bounds(st: &mut PState, conv: conv_did) -> ty::ParamBounds {

branches/try2/src/librustc/metadata/tyencode.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,4 +421,5 @@ fn enc_bounds(w: &mut MemWriter, cx: @ctxt, bs: &ty::ParamBounds) {
421421
pub fn enc_type_param_def(w: &mut MemWriter, cx: @ctxt, v: &ty::TypeParameterDef) {
422422
mywrite!(w, "{}:{}|", cx.tcx.sess.str_of(v.ident), (cx.ds)(v.def_id));
423423
enc_bounds(w, cx, v.bounds);
424+
enc_opt(w, v.default, |w, t| enc_ty(w, cx, t));
424425
}

branches/try2/src/librustc/middle/lint.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ pub enum Lint {
8686
AttributeUsage,
8787
UnknownFeatures,
8888
UnknownCrateType,
89+
DefaultTypeParamUsage,
8990

9091
ManagedHeapMemory,
9192
OwnedHeapMemory,
@@ -359,6 +360,7 @@ static lint_table: &'static [(&'static str, LintSpec)] = &[
359360
desc: "unknown features found in crate-level #[feature] directives",
360361
default: deny,
361362
}),
363+
362364
("unknown_crate_type",
363365
LintSpec {
364366
lint: UnknownCrateType,
@@ -379,6 +381,13 @@ static lint_table: &'static [(&'static str, LintSpec)] = &[
379381
desc: "unused result of an expression in a statement",
380382
default: allow,
381383
}),
384+
385+
("default_type_param_usage",
386+
LintSpec {
387+
lint: DefaultTypeParamUsage,
388+
desc: "prevents explicitly setting a type parameter with a default",
389+
default: deny,
390+
}),
382391
];
383392

384393
/*

branches/try2/src/librustc/middle/resolve.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3931,6 +3931,10 @@ impl Resolver {
39313931
for bound in type_parameter.bounds.iter() {
39323932
self.resolve_type_parameter_bound(type_parameter.id, bound);
39333933
}
3934+
match type_parameter.default {
3935+
Some(ty) => self.resolve_type(ty),
3936+
None => {}
3937+
}
39343938
}
39353939
}
39363940

branches/try2/src/librustc/middle/subst.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ impl Subst for ty::TypeParameterDef {
164164
ty::TypeParameterDef {
165165
ident: self.ident,
166166
def_id: self.def_id,
167-
bounds: self.bounds.subst(tcx, substs)
167+
bounds: self.bounds.subst(tcx, substs),
168+
default: self.default.map(|x| x.subst(tcx, substs))
168169
}
169170
}
170171
}

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use driver::session;
3030
use driver::session::Session;
3131
use driver::driver::{CrateAnalysis, CrateTranslation};
3232
use lib::llvm::{ModuleRef, ValueRef, BasicBlockRef};
33-
use lib::llvm::{llvm, True};
33+
use lib::llvm::{llvm, True, Vector};
3434
use lib;
3535
use metadata::common::LinkMeta;
3636
use metadata::{csearch, encoder};
@@ -376,7 +376,7 @@ pub fn malloc_raw_dyn<'a>(
376376

377377
// Get the tydesc for the body:
378378
let static_ti = get_tydesc(ccx, t);
379-
glue::lazily_emit_all_tydesc_glue(ccx, static_ti);
379+
glue::lazily_emit_tydesc_glue(ccx, abi::tydesc_field_drop_glue, static_ti);
380380

381381
// Allocate space:
382382
let tydesc = PointerCast(bcx, static_ti.tydesc, Type::i8p());
@@ -827,8 +827,10 @@ pub fn cast_shift_rhs(op: ast::BinOp,
827827
// Shifts may have any size int on the rhs
828828
unsafe {
829829
if ast_util::is_shift_binop(op) {
830-
let rhs_llty = val_ty(rhs);
831-
let lhs_llty = val_ty(lhs);
830+
let mut rhs_llty = val_ty(rhs);
831+
let mut lhs_llty = val_ty(lhs);
832+
if rhs_llty.kind() == Vector { rhs_llty = rhs_llty.element_type() }
833+
if lhs_llty.kind() == Vector { lhs_llty = lhs_llty.element_type() }
832834
let rhs_sz = llvm::LLVMGetIntTypeWidth(rhs_llty.to_ref());
833835
let lhs_sz = llvm::LLVMGetIntTypeWidth(lhs_llty.to_ref());
834836
if lhs_sz < rhs_sz {

branches/try2/src/librustc/middle/trans/debuginfo.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,7 @@ fn set_members_of_composite_type(cx: &CrateContext,
16461646
.map(|(i, member_description)| {
16471647
let (member_size, member_align) = size_and_align_of(cx, member_description.llvm_type);
16481648
let member_offset = match member_description.offset {
1649-
FixedMemberOffset { bytes } => bytes,
1649+
FixedMemberOffset { bytes } => bytes as u64,
16501650
ComputedMemberOffset => machine::llelement_offset(cx, composite_llvm_type, i)
16511651
};
16521652

@@ -1815,7 +1815,7 @@ fn fixed_vec_metadata(cx: &CrateContext,
18151815
return unsafe {
18161816
llvm::LLVMDIBuilderCreateArrayType(
18171817
DIB(cx),
1818-
bytes_to_bits(element_type_size * len),
1818+
bytes_to_bits(element_type_size * (len as u64)),
18191819
bytes_to_bits(element_type_align),
18201820
element_type_metadata,
18211821
subscripts)
@@ -2000,7 +2000,8 @@ fn trait_metadata(cx: &CrateContext,
20002000
ppaux::mutability_to_str(mutability) +
20012001
token::ident_to_str(&ident);
20022002
// Add type and region parameters
2003-
let name = ppaux::parameterized(cx.tcx, name, &substs.regions, substs.tps);
2003+
let name = ppaux::parameterized(cx.tcx, name, &substs.regions,
2004+
substs.tps, def_id, true);
20042005

20052006
let (containing_scope, definition_span) =
20062007
get_namespace_and_span_for_item(cx, def_id, usage_site_span);
@@ -2210,11 +2211,11 @@ fn span_start(cx: &CrateContext, span: Span) -> codemap::Loc {
22102211
cx.sess.codemap.lookup_char_pos(span.lo)
22112212
}
22122213

2213-
fn size_and_align_of(cx: &CrateContext, llvm_type: Type) -> (uint, uint) {
2214+
fn size_and_align_of(cx: &CrateContext, llvm_type: Type) -> (u64, u64) {
22142215
(machine::llsize_of_alloc(cx, llvm_type), machine::llalign_of_min(cx, llvm_type))
22152216
}
22162217

2217-
fn bytes_to_bits(bytes: uint) -> c_ulonglong {
2218+
fn bytes_to_bits(bytes: u64) -> c_ulonglong {
22182219
(bytes * 8) as c_ulonglong
22192220
}
22202221

branches/try2/src/librustc/middle/trans/foreign.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ pub fn trans_native_call<'a>(
341341
let llalign = cmp::min(llforeign_align, llrust_align);
342342
debug!("llrust_size={:?}", llrust_size);
343343
base::call_memcpy(bcx, llretptr_i8, llscratch_i8,
344-
C_uint(ccx, llrust_size), llalign as u32);
344+
C_uint(ccx, llrust_size as uint), llalign as u32);
345345
}
346346
}
347347

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ fn simplified_glue_type(tcx: ty::ctxt, field: uint, t: ty::t) -> ty::t {
131131
t
132132
}
133133

134-
fn lazily_emit_tydesc_glue(ccx: @CrateContext, field: uint, ti: @tydesc_info) {
134+
pub fn lazily_emit_tydesc_glue(ccx: @CrateContext, field: uint, ti: @tydesc_info) {
135135
let _icx = push_ctxt("lazily_emit_tydesc_glue");
136136

137137
let simpl = simplified_glue_type(ccx.tcx, field, ti.ty);
@@ -367,17 +367,9 @@ fn make_drop_glue<'a>(bcx: &'a Block<'a>, v0: ValueRef, t: ty::t) -> &'a Block<'
367367
let lluniquevalue = GEPi(bcx, v0, [0, abi::trt_field_box]);
368368
// Only drop the value when it is non-null
369369
with_cond(bcx, IsNotNull(bcx, Load(bcx, lluniquevalue)), |bcx| {
370-
let llvtable = Load(bcx, GEPi(bcx, v0, [0, abi::trt_field_vtable]));
371-
372-
// Cast the vtable to a pointer to a pointer to a tydesc.
373-
let llvtable = PointerCast(bcx, llvtable,
374-
ccx.tydesc_type.ptr_to().ptr_to());
375-
let lltydesc = Load(bcx, llvtable);
376-
call_tydesc_glue_full(bcx,
377-
lluniquevalue,
378-
lltydesc,
379-
abi::tydesc_field_drop_glue,
380-
None);
370+
let lldtor_ptr = Load(bcx, GEPi(bcx, v0, [0, abi::trt_field_vtable]));
371+
let lldtor = Load(bcx, lldtor_ptr);
372+
Call(bcx, lldtor, [PointerCast(bcx, lluniquevalue, Type::i8p())], []);
381373
bcx
382374
})
383375
}

branches/try2/src/librustc/middle/trans/intrinsic.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ pub fn trans_intrinsic(ccx: @CrateContext,
247247
"size_of" => {
248248
let tp_ty = substs.tys[0];
249249
let lltp_ty = type_of::type_of(ccx, tp_ty);
250-
Ret(bcx, C_uint(ccx, machine::llsize_of_real(ccx, lltp_ty)));
250+
Ret(bcx, C_uint(ccx, machine::llsize_of_real(ccx, lltp_ty) as uint));
251251
}
252252
"move_val_init" => {
253253
// Create a datum reflecting the value being moved.
@@ -266,12 +266,12 @@ pub fn trans_intrinsic(ccx: @CrateContext,
266266
"min_align_of" => {
267267
let tp_ty = substs.tys[0];
268268
let lltp_ty = type_of::type_of(ccx, tp_ty);
269-
Ret(bcx, C_uint(ccx, machine::llalign_of_min(ccx, lltp_ty)));
269+
Ret(bcx, C_uint(ccx, machine::llalign_of_min(ccx, lltp_ty) as uint));
270270
}
271271
"pref_align_of"=> {
272272
let tp_ty = substs.tys[0];
273273
let lltp_ty = type_of::type_of(ccx, tp_ty);
274-
Ret(bcx, C_uint(ccx, machine::llalign_of_pref(ccx, lltp_ty)));
274+
Ret(bcx, C_uint(ccx, machine::llalign_of_pref(ccx, lltp_ty) as uint));
275275
}
276276
"get_tydesc" => {
277277
let tp_ty = substs.tys[0];
@@ -337,7 +337,7 @@ pub fn trans_intrinsic(ccx: @CrateContext,
337337
_ => fail!("transmute has non-expr arg"),
338338
}
339339
};
340-
let pluralize = |n| if 1u == n { "" } else { "s" };
340+
let pluralize = |n| if 1 == n { "" } else { "s" };
341341
ccx.sess.span_fatal(sp,
342342
format!("transmute called on types with \
343343
different sizes: {} ({} bit{}) to \

branches/try2/src/librustc/middle/trans/machine.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ use middle::trans::type_::Type;
2121
// compute sizeof / alignof
2222

2323
// Returns the number of bytes clobbered by a Store to this type.
24-
pub fn llsize_of_store(cx: &CrateContext, ty: Type) -> uint {
24+
pub fn llsize_of_store(cx: &CrateContext, ty: Type) -> u64 {
2525
unsafe {
26-
return llvm::LLVMStoreSizeOfType(cx.td.lltd, ty.to_ref()) as uint;
26+
return llvm::LLVMStoreSizeOfType(cx.td.lltd, ty.to_ref()) as u64;
2727
}
2828
}
2929

3030
// Returns the number of bytes between successive elements of type T in an
3131
// array of T. This is the "ABI" size. It includes any ABI-mandated padding.
32-
pub fn llsize_of_alloc(cx: &CrateContext, ty: Type) -> uint {
32+
pub fn llsize_of_alloc(cx: &CrateContext, ty: Type) -> u64 {
3333
unsafe {
34-
return llvm::LLVMABISizeOfType(cx.td.lltd, ty.to_ref()) as uint;
34+
return llvm::LLVMABISizeOfType(cx.td.lltd, ty.to_ref()) as u64;
3535
}
3636
}
3737

@@ -43,22 +43,22 @@ pub fn llsize_of_alloc(cx: &CrateContext, ty: Type) -> uint {
4343
// that LLVM *does* distinguish between e.g. a 1-bit value and an 8-bit value
4444
// at the codegen level! In general you should prefer `llbitsize_of_real`
4545
// below.
46-
pub fn llsize_of_real(cx: &CrateContext, ty: Type) -> uint {
46+
pub fn llsize_of_real(cx: &CrateContext, ty: Type) -> u64 {
4747
unsafe {
48-
let nbits = llvm::LLVMSizeOfTypeInBits(cx.td.lltd, ty.to_ref()) as uint;
49-
if nbits & 7u != 0u {
48+
let nbits = llvm::LLVMSizeOfTypeInBits(cx.td.lltd, ty.to_ref()) as u64;
49+
if nbits & 7 != 0 {
5050
// Not an even number of bytes, spills into "next" byte.
51-
1u + (nbits >> 3)
51+
1 + (nbits >> 3)
5252
} else {
5353
nbits >> 3
5454
}
5555
}
5656
}
5757

5858
/// Returns the "real" size of the type in bits.
59-
pub fn llbitsize_of_real(cx: &CrateContext, ty: Type) -> uint {
59+
pub fn llbitsize_of_real(cx: &CrateContext, ty: Type) -> u64 {
6060
unsafe {
61-
llvm::LLVMSizeOfTypeInBits(cx.td.lltd, ty.to_ref()) as uint
61+
llvm::LLVMSizeOfTypeInBits(cx.td.lltd, ty.to_ref()) as u64
6262
}
6363
}
6464

@@ -71,7 +71,7 @@ pub fn llsize_of(cx: &CrateContext, ty: Type) -> ValueRef {
7171
// there's no need for that contrivance. The instruction
7272
// selection DAG generator would flatten that GEP(1) node into a
7373
// constant of the type's alloc size, so let's save it some work.
74-
return C_uint(cx, llsize_of_alloc(cx, ty));
74+
return C_uint(cx, llsize_of_alloc(cx, ty) as uint);
7575
}
7676

7777
// Returns the "default" size of t (see above), or 1 if the size would
@@ -89,18 +89,18 @@ pub fn nonzero_llsize_of(cx: &CrateContext, ty: Type) -> ValueRef {
8989
// The preferred alignment may be larger than the alignment used when
9090
// packing the type into structs. This will be used for things like
9191
// allocations inside a stack frame, which LLVM has a free hand in.
92-
pub fn llalign_of_pref(cx: &CrateContext, ty: Type) -> uint {
92+
pub fn llalign_of_pref(cx: &CrateContext, ty: Type) -> u64 {
9393
unsafe {
94-
return llvm::LLVMPreferredAlignmentOfType(cx.td.lltd, ty.to_ref()) as uint;
94+
return llvm::LLVMPreferredAlignmentOfType(cx.td.lltd, ty.to_ref()) as u64;
9595
}
9696
}
9797

9898
// Returns the minimum alignment of a type required by the platform.
9999
// This is the alignment that will be used for struct fields, arrays,
100100
// and similar ABI-mandated things.
101-
pub fn llalign_of_min(cx: &CrateContext, ty: Type) -> uint {
101+
pub fn llalign_of_min(cx: &CrateContext, ty: Type) -> u64 {
102102
unsafe {
103-
return llvm::LLVMABIAlignmentOfType(cx.td.lltd, ty.to_ref()) as uint;
103+
return llvm::LLVMABIAlignmentOfType(cx.td.lltd, ty.to_ref()) as u64;
104104
}
105105
}
106106

@@ -114,8 +114,8 @@ pub fn llalign_of(cx: &CrateContext, ty: Type) -> ValueRef {
114114
}
115115
}
116116

117-
pub fn llelement_offset(cx: &CrateContext, struct_ty: Type, element: uint) -> uint {
117+
pub fn llelement_offset(cx: &CrateContext, struct_ty: Type, element: uint) -> u64 {
118118
unsafe {
119-
return llvm::LLVMOffsetOfElement(cx.td.lltd, struct_ty.to_ref(), element as u32) as uint;
119+
return llvm::LLVMOffsetOfElement(cx.td.lltd, struct_ty.to_ref(), element as u32) as u64;
120120
}
121121
}

0 commit comments

Comments
 (0)