Skip to content

Commit 6840e6c

Browse files
committed
---
yaml --- r: 47191 b: refs/heads/try c: ad414de h: refs/heads/master i: 47189: 2e60772 47187: 6998aa0 47183: c8816fe v: v3
1 parent a42f88e commit 6840e6c

File tree

10 files changed

+21
-64
lines changed

10 files changed

+21
-64
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: 3bbcac322669cff3abde5be937cc4ec3860f3985
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
5-
refs/heads/try: 4ffff6697b144b346cc3853a82f1056b593ef58d
5+
refs/heads/try: ad414dec67f3f9583938a2a1212e104443fca798
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/librustc/lib/llvm.rs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,12 +1379,7 @@ pub fn type_to_str_inner(names: @TypeNames, +outer0: &[TypeRef], ty: TypeRef)
13791379
type_to_str_inner(names, outer, out_ty)).to_managed();
13801380
}
13811381
Struct => {
1382-
let n_elts = llvm::LLVMCountStructElementTypes(ty) as uint;
1383-
let mut elts = vec::from_elem(n_elts, 0 as TypeRef);
1384-
if !elts.is_empty() {
1385-
llvm::LLVMGetStructElementTypes(
1386-
ty, ptr::to_mut_unsafe_ptr(&mut elts[0]));
1387-
}
1382+
let elts = struct_tys(ty);
13881383
// See [Note at-str]
13891384
return fmt!("{%s}", tys_str(names, outer, elts)).to_managed();
13901385
}
@@ -1445,17 +1440,16 @@ pub fn fn_ty_param_tys(fn_ty: TypeRef) -> ~[TypeRef] {
14451440
}
14461441
}
14471442

1448-
pub fn struct_element_types(struct_ty: TypeRef) -> ~[TypeRef] {
1443+
pub fn struct_tys(struct_ty: TypeRef) -> ~[TypeRef] {
14491444
unsafe {
1450-
let count = llvm::LLVMCountStructElementTypes(struct_ty);
1451-
let mut buf: ~[TypeRef] =
1452-
vec::from_elem(count as uint,
1453-
cast::transmute::<uint,TypeRef>(0));
1454-
if buf.len() > 0 {
1455-
llvm::LLVMGetStructElementTypes(
1456-
struct_ty, ptr::to_mut_unsafe_ptr(&mut buf[0]));
1445+
let n_elts = llvm::LLVMCountStructElementTypes(struct_ty) as uint;
1446+
if n_elts == 0 {
1447+
return ~[];
14571448
}
1458-
return buf;
1449+
let mut elts = vec::from_elem(n_elts, ptr::null());
1450+
llvm::LLVMGetStructElementTypes(
1451+
struct_ty, ptr::to_mut_unsafe_ptr(&mut elts[0]));
1452+
return elts;
14591453
}
14601454
}
14611455

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,11 +2150,6 @@ pub fn trans_mod(ccx: @CrateContext, m: ast::_mod) {
21502150
}
21512151
}
21522152
2153-
pub fn get_pair_fn_ty(llpairty: TypeRef) -> TypeRef {
2154-
// Bit of a kludge: pick the fn typeref out of the pair.
2155-
return struct_elt(llpairty, 0u);
2156-
}
2157-
21582153
pub fn register_fn(ccx: @CrateContext,
21592154
sp: span,
21602155
+path: path,

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

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use lib::llvm::{llvm, TypeRef, ValueRef, Integer, Pointer, Float, Double};
1515
use lib::llvm::{Struct, Array, Attribute};
1616
use lib::llvm::{StructRetAttribute, ByValAttribute};
17+
use lib::llvm::struct_tys;
1718
use middle::trans::common::*;
1819
use middle::trans::cabi::*;
1920

@@ -65,19 +66,6 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
6566
return (off + a - 1u) / a * a;
6667
}
6768

68-
fn struct_tys(ty: TypeRef) -> ~[TypeRef] {
69-
unsafe {
70-
let n = llvm::LLVMCountStructElementTypes(ty);
71-
if (n == 0) {
72-
return ~[];
73-
}
74-
let mut elts = vec::from_elem(n as uint, ptr::null());
75-
llvm::LLVMGetStructElementTypes(ty,
76-
ptr::to_mut_unsafe_ptr(&mut elts[0]));
77-
return elts;
78-
}
79-
}
80-
8169
fn ty_align(ty: TypeRef) -> uint {
8270
unsafe {
8371
return match llvm::LLVMGetTypeKind(ty) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ pub fn trans_rtcall_or_lang_call_with_type_params(bcx: block,
380380
fty);
381381
let mut llfnty = type_of::type_of(callee.bcx.ccx(),
382382
substituted);
383-
llfnty = T_ptr(struct_elt(llfnty, 0));
383+
llfnty = lib::llvm::struct_tys(llfnty)[0];
384384
new_llval = PointerCast(callee.bcx, fn_data.llfn, llfnty);
385385
}
386386
_ => fail!()

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -645,19 +645,6 @@ pub fn val_str(tn: @TypeNames, v: ValueRef) -> @str {
645645
return ty_str(tn, val_ty(v));
646646
}
647647

648-
// Returns the nth element of the given LLVM structure type.
649-
pub fn struct_elt(llstructty: TypeRef, n: uint) -> TypeRef {
650-
unsafe {
651-
let elt_count = llvm::LLVMCountStructElementTypes(llstructty) as uint;
652-
assert (n < elt_count);
653-
let mut elt_tys = vec::from_elem(elt_count, T_nil());
654-
llvm::LLVMGetStructElementTypes(
655-
llstructty,
656-
ptr::to_mut_unsafe_ptr(&mut elt_tys[0]));
657-
return llvm::LLVMGetElementType(elt_tys[n]);
658-
}
659-
}
660-
661648
pub fn in_scope_cx(cx: block, f: &fn(&mut scope_info)) {
662649
let mut cur = cx;
663650
loop {

branches/try/src/librustc/middle/typeck/infer/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,10 +733,10 @@ impl @mut InferCtxt {
733733

734734
fn report_mismatched_types(sp: span, e: ty::t, a: ty::t,
735735
err: &ty::type_err) {
736+
// Don't report an error if expected is ty_err
736737
let resolved_expected =
737738
self.resolve_type_vars_if_possible(e);
738739
let mk_msg = match ty::get(resolved_expected).sty {
739-
// Don't report an error if expected is ty_err
740740
ty::ty_err => return,
741741
_ => {
742742
// if I leave out : ~str, it infers &str and complains
@@ -779,3 +779,4 @@ impl @mut InferCtxt {
779779
}
780780

781781
}
782+

branches/try/src/librustc/util/ppaux.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -238,21 +238,19 @@ pub fn vstore_to_str(cx: ctxt, vs: ty::vstore) -> ~str {
238238
ty::vstore_fixed(n) => fmt!("%u", n),
239239
ty::vstore_uniq => ~"~",
240240
ty::vstore_box => ~"@",
241-
/* FIXME(#4517) slice fmt */
242241
ty::vstore_slice(r) => region_to_str(cx, r)
243242
}
244243
}
245244

246245
pub fn vstore_ty_to_str(cx: ctxt, ty: ~str, vs: ty::vstore) -> ~str {
247246
match vs {
248247
ty::vstore_fixed(_) => {
249-
fmt!("[%s * %s]", ty, vstore_to_str(cx, vs))
248+
fmt!("%s/%s", ty, vstore_to_str(cx, vs))
250249
}
251-
/* FIXME(#4517) slice fmt */
252250
ty::vstore_slice(_) => {
253251
fmt!("%s/%s", vstore_to_str(cx, vs), ty)
254252
}
255-
_ => fmt!("%s[%s]", vstore_to_str(cx, vs), ty)
253+
_ => fmt!("%s%s", vstore_to_str(cx, vs), ty)
256254
}
257255
}
258256

@@ -455,13 +453,13 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str {
455453
ty_trait(did, ref substs, vs) => {
456454
let path = ty::item_path(cx, did);
457455
let base = ast_map::path_to_str(path, cx.sess.intr());
458-
let ty = parameterized(cx, base, substs.self_r, substs.tps);
459-
fmt!("%s%s", vstore_to_str(cx, vs), ty)
456+
let result = parameterized(cx, base, substs.self_r, substs.tps);
457+
vstore_ty_to_str(cx, result, vs)
460458
}
461459
ty_evec(mt, vs) => {
462-
vstore_ty_to_str(cx, fmt!("%s", mt_to_str(cx, mt)), vs)
460+
vstore_ty_to_str(cx, fmt!("[%s]", mt_to_str(cx, mt)), vs)
463461
}
464-
ty_estr(vs) => fmt!("%s%s", vstore_to_str(cx, vs), ~"str"),
462+
ty_estr(vs) => vstore_ty_to_str(cx, ~"str", vs),
465463
ty_opaque_box => ~"@?",
466464
ty_opaque_closure_ptr(ast::BorrowedSigil) => ~"closure&",
467465
ty_opaque_closure_ptr(ast::ManagedSigil) => ~"closure@",

branches/try/src/test/compile-fail/issue-2149.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ impl<A> vec_monad<A> for ~[A] {
2222
}
2323
fn main() {
2424
["hi"].bind(|x| [x] );
25-
//~^ ERROR type `[&staticstr * 1]` does not implement any method in scope named `bind`
25+
//~^ ERROR type `[&static/str]/1` does not implement any method in scope named `bind`
2626
//~^^ ERROR Unconstrained region variable
2727
}

branches/try/src/test/compile-fail/issue-4517.rs

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

0 commit comments

Comments
 (0)