Skip to content

Commit d0ac7a2

Browse files
committed
---
yaml --- r: 104138 b: refs/heads/try c: cfb87f1 h: refs/heads/master v: v3
1 parent 2b7d373 commit d0ac7a2

32 files changed

+171
-159
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: 62f1d68439dcfd509eaca29887afa97f22938373
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6e7f170fedd3c526a643c0b2d13863acd982be02
5-
refs/heads/try: 4f72c018cec120d596ece1b5f2a2e7d59f1ef520
5+
refs/heads/try: cfb87f10ec7d41d0e7f8c68fbb908fc195517d41
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/doc/complement-cheatsheet.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,42 @@ let y: ~str = x.to_str_radix(16);
3636
Use [`FromStrRadix`](http://static.rust-lang.org/doc/master/std/num/trait.FromStrRadix.html), and its helper function, [`from_str_radix`](http://static.rust-lang.org/doc/master/std/num/fn.from_str_radix.html).
3737

3838
~~~
39-
use std::num::from_str_radix;
39+
use std::num;
4040
41-
let x: Option<i64> = from_str_radix("deadbeef", 16);
41+
let x: Option<i64> = num::from_str_radix("deadbeef", 16);
4242
let y: i64 = x.unwrap();
4343
~~~
4444

45+
**Vector of Bytes to String**
46+
47+
To return a Borrowed String Slice (&str) use the str helper function [`from_utf8`](http://static.rust-lang.org/doc/master/std/str/fn.from_utf8.html).
48+
49+
~~~
50+
use std::str;
51+
52+
let bytes = ~[104u8,105u8];
53+
let x: Option<&str> = str::from_utf8(bytes);
54+
let y: &str = x.unwrap();
55+
~~~
56+
57+
To return an Owned String (~str) use the str helper function [`from_utf8_owned`](http://static.rust-lang.org/doc/master/std/str/fn.from_utf8_owned.html).
58+
59+
~~~
60+
use std::str;
61+
62+
let x: Option<~str> = str::from_utf8_owned(~[104u8,105u8]);
63+
let y: ~str = x.unwrap();
64+
~~~~
65+
66+
To return a [`MaybeOwned`](http://static.rust-lang.org/doc/master/std/str/enum.MaybeOwned.html) use the str helper function [`from_utf8_lossy`](http://static.rust-lang.org/doc/master/std/str/fn.from_utf8_owned.html). This function also replaces non-valid utf-8 sequences with U+FFFD replacement character.
67+
68+
~~~
69+
use std::str;
70+
71+
let x = bytes!(72u8,"ello ",0xF0,0x90,0x80,"World!");
72+
let y = str::from_utf8_lossy(x);
73+
~~~~
74+
4575
# File operations
4676
4777
## How do I read from a file?

branches/try/src/libfourcc/lib.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ To load the extension and use it:
2626
extern mod fourcc;
2727
2828
fn main() {
29-
let val = fourcc!("\xC0\xFF\xEE!")
30-
// val is 0xC0FFEE21
31-
let big_val = fourcc!("foo ", big);
32-
// big_val is 0x21EEFFC0
29+
let val = fourcc!("\xC0\xFF\xEE!");
30+
assert_eq!(val, 0xC0FFEE21u32);
31+
let little_val = fourcc!("foo ", little);
32+
assert_eq!(little_val, 0x21EEFFC0u32);
3333
}
3434
```
3535
@@ -60,7 +60,6 @@ use syntax::parse::token;
6060
use syntax::parse::token::InternedString;
6161

6262
#[macro_registrar]
63-
#[cfg(not(test))]
6463
pub fn macro_registrar(register: |Name, SyntaxExtension|) {
6564
register(token::intern("fourcc"),
6665
NormalTT(~BasicMacroExpander {
@@ -155,6 +154,6 @@ fn target_endian_little(cx: &ExtCtxt, sp: Span) -> bool {
155154
contains(cx.cfg(), meta)
156155
}
157156

158-
// Fixes LLVM assert on Windows
157+
// FIXME (10872): This is required to prevent an LLVM assert on Windows
159158
#[test]
160159
fn dummy_test() { }

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,6 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t {
372372
'F' => {
373373
return ty::mk_bare_fn(st.tcx, parse_bare_fn_ty(st, |x,y| conv(x,y)));
374374
}
375-
'Y' => return ty::mk_type(st.tcx),
376375
'#' => {
377376
let pos = parse_hex(st);
378377
assert_eq!(next(st), ':');

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ fn enc_sty(w: &mut MemWriter, cx: @ctxt, st: &ty::sty) {
328328
ty::ty_self(did) => {
329329
mywrite!(w, "s{}|", (cx.ds)(did));
330330
}
331-
ty::ty_type => mywrite!(w, "Y"),
332331
ty::ty_struct(def, ref substs) => {
333332
mywrite!(w, "a[{}|", (cx.ds)(def));
334333
enc_substs(w, cx, substs);

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -598,19 +598,8 @@ pub fn compare_scalar_types<'a>(
598598
ty::ty_int(_) => rslt(cx, f(signed_int)),
599599
ty::ty_uint(_) => rslt(cx, f(unsigned_int)),
600600
ty::ty_float(_) => rslt(cx, f(floating_point)),
601-
ty::ty_type => {
602-
rslt(
603-
controlflow::trans_fail(
604-
cx, None,
605-
InternedString::new("attempt to compare values of type \
606-
type")),
607-
C_nil())
608-
}
609-
_ => {
610601
// Should never get here, because t is scalar.
611-
cx.sess().bug("non-scalar type passed to \
612-
compare_scalar_types")
613-
}
602+
_ => cx.sess().bug("non-scalar type passed to compare_scalar_types")
614603
}
615604
}
616605

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,12 @@ pub fn mk_closure_tys(tcx: ty::ctxt,
152152
return cdata_ty;
153153
}
154154

155-
pub fn allocate_cbox<'a>(
156-
bcx: &'a Block<'a>,
155+
fn tuplify_box_ty(tcx: ty::ctxt, t: ty::t) -> ty::t {
156+
let ptr = ty::mk_imm_ptr(tcx, ty::mk_i8());
157+
ty::mk_tup(tcx, ~[ty::mk_uint(), ty::mk_nil_ptr(tcx), ptr, ptr, t])
158+
}
159+
160+
fn allocate_cbox<'a>(bcx: &'a Block<'a>,
157161
sigil: ast::Sigil,
158162
cdata_ty: ty::t)
159163
-> Result<'a> {

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -520,19 +520,6 @@ pub fn val_ty(v: ValueRef) -> Type {
520520
}
521521
}
522522

523-
// Let T be the content of a box @T. tuplify_box_ty(t) returns the
524-
// representation of @T as a tuple (i.e., the ty::t version of what T_box()
525-
// returns).
526-
pub fn tuplify_box_ty(tcx: ty::ctxt, t: ty::t) -> ty::t {
527-
let ptr = ty::mk_ptr(
528-
tcx,
529-
ty::mt {ty: ty::mk_i8(), mutbl: ast::MutImmutable}
530-
);
531-
return ty::mk_tup(tcx, ~[ty::mk_uint(), ty::mk_type(tcx),
532-
ptr, ptr,
533-
t]);
534-
}
535-
536523
// LLVM constant constructors.
537524
pub fn C_null(t: Type) -> ValueRef {
538525
unsafe {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,7 @@ impl<'a> Reflector<'a> {
368368
let extra = ~[self.c_uint(p.idx)];
369369
self.visit("param", extra)
370370
}
371-
ty::ty_self(..) => self.leaf("self"),
372-
ty::ty_type => self.leaf("type")
371+
ty::ty_self(..) => self.leaf("self")
373372
}
374373
}
375374

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type {
119119
ty::ty_box(..) |
120120
ty::ty_uniq(..) |
121121
ty::ty_ptr(..) |
122-
ty::ty_rptr(..) |
123-
ty::ty_type => Type::i8p(),
122+
ty::ty_rptr(..) => Type::i8p(),
124123

125124
ty::ty_str(ty::vstore_slice(..)) |
126125
ty::ty_vec(_, ty::vstore_slice(..)) => {
@@ -263,7 +262,6 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
263262
Type::struct_([fn_ty, Type::i8p()], false)
264263
}
265264
ty::ty_trait(..) => Type::opaque_trait(),
266-
ty::ty_type => cx.tydesc_type.ptr_to(),
267265
ty::ty_tup(..) => {
268266
let repr = adt::represent_type(cx, t);
269267
adt::type_of(cx, repr)

branches/try/src/librustc/middle/ty.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,6 @@ pub enum sty {
756756
// on non-useful type error messages)
757757

758758
// "Fake" types, used for trans purposes
759-
ty_type, // type_desc*
760759
ty_unboxed_vec(mt),
761760
}
762761

@@ -1181,7 +1180,7 @@ pub fn mk_t(cx: ctxt, st: sty) -> t {
11811180
flags |= get(mt.ty).flags;
11821181
}
11831182
&ty_nil | &ty_bool | &ty_char | &ty_int(_) | &ty_float(_) | &ty_uint(_) |
1184-
&ty_str(_) | &ty_type => {}
1183+
&ty_str(_) => {}
11851184
// You might think that we could just return ty_err for
11861185
// any type containing ty_err as a component, and get
11871186
// rid of the has_ty_err flag -- likewise for ty_bot (with
@@ -1444,8 +1443,6 @@ pub fn mk_param(cx: ctxt, n: uint, k: DefId) -> t {
14441443
mk_t(cx, ty_param(param_ty { idx: n, def_id: k }))
14451444
}
14461445

1447-
pub fn mk_type(cx: ctxt) -> t { mk_t(cx, ty_type) }
1448-
14491446
pub fn walk_ty(ty: t, f: |t|) {
14501447
maybe_walk_ty(ty, |t| { f(t); true });
14511448
}
@@ -1456,7 +1453,7 @@ pub fn maybe_walk_ty(ty: t, f: |t| -> bool) {
14561453
}
14571454
match get(ty).sty {
14581455
ty_nil | ty_bot | ty_bool | ty_char | ty_int(_) | ty_uint(_) | ty_float(_) |
1459-
ty_str(_) | ty_type | ty_self(_) |
1456+
ty_str(_) | ty_self(_) |
14601457
ty_infer(_) | ty_param(_) | ty_err => {}
14611458
ty_box(ty) | ty_uniq(ty) => maybe_walk_ty(ty, f),
14621459
ty_vec(ref tm, _) | ty_unboxed_vec(ref tm) | ty_ptr(ref tm) |
@@ -1730,7 +1727,7 @@ pub fn type_is_unique(ty: t) -> bool {
17301727
pub fn type_is_scalar(ty: t) -> bool {
17311728
match get(ty).sty {
17321729
ty_nil | ty_bool | ty_char | ty_int(_) | ty_float(_) | ty_uint(_) |
1733-
ty_infer(IntVar(_)) | ty_infer(FloatVar(_)) | ty_type |
1730+
ty_infer(IntVar(_)) | ty_infer(FloatVar(_)) |
17341731
ty_bare_fn(..) | ty_ptr(_) => true,
17351732
_ => false
17361733
}
@@ -2216,8 +2213,6 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
22162213
}
22172214
ty_unboxed_vec(mt) => TC::InteriorUnsized | tc_mt(cx, mt, cache),
22182215

2219-
ty_type => TC::None,
2220-
22212216
ty_err => {
22222217
cx.sess.bug("asked to compute contents of error type");
22232218
}
@@ -2401,7 +2396,6 @@ pub fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
24012396
ty_err |
24022397
ty_param(_) |
24032398
ty_self(_) |
2404-
ty_type |
24052399
ty_vec(_, _) |
24062400
ty_unboxed_vec(_) => {
24072401
false
@@ -2628,7 +2622,7 @@ pub fn type_is_pod(cx: ctxt, ty: t) -> bool {
26282622
match get(ty).sty {
26292623
// Scalar types
26302624
ty_nil | ty_bot | ty_bool | ty_char | ty_int(_) | ty_float(_) | ty_uint(_) |
2631-
ty_type | ty_ptr(_) | ty_bare_fn(_) => result = true,
2625+
ty_ptr(_) | ty_bare_fn(_) => result = true,
26322626
// Boxed types
26332627
ty_box(_) | ty_uniq(_) | ty_closure(_) |
26342628
ty_str(vstore_uniq) |
@@ -3556,7 +3550,7 @@ pub fn occurs_check(tcx: ctxt, sp: Span, vid: TyVid, rt: t) {
35563550
pub fn ty_sort_str(cx: ctxt, t: t) -> ~str {
35573551
match get(t).sty {
35583552
ty_nil | ty_bot | ty_bool | ty_char | ty_int(_) |
3559-
ty_uint(_) | ty_float(_) | ty_str(_) | ty_type => {
3553+
ty_uint(_) | ty_float(_) | ty_str(_) => {
35603554
::util::ppaux::ty_to_str(cx, t)
35613555
}
35623556

@@ -5120,9 +5114,8 @@ pub fn hash_crate_independent(tcx: ctxt, t: t, local_hash: ~str) -> u64 {
51205114
}
51215115
ty_infer(_) => unreachable!(),
51225116
ty_err => hash.input([23]),
5123-
ty_type => hash.input([24]),
51245117
ty_unboxed_vec(m) => {
5125-
hash.input([25]);
5118+
hash.input([24]);
51265119
mt(&mut hash, m);
51275120
}
51285121
}

branches/try/src/librustc/middle/ty_fold.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,7 @@ pub fn super_fold_sty<T:TypeFolder>(this: &mut T,
187187
ty::ty_str(this.fold_vstore(vst))
188188
}
189189
ty::ty_nil | ty::ty_bot | ty::ty_bool | ty::ty_char |
190-
ty::ty_int(_) | ty::ty_uint(_) |
191-
ty::ty_float(_) | ty::ty_type |
190+
ty::ty_int(_) | ty::ty_uint(_) | ty::ty_float(_) |
192191
ty::ty_err | ty::ty_infer(_) |
193192
ty::ty_param(..) | ty::ty_self(_) => {
194193
(*sty).clone()

branches/try/src/librustc/middle/typeck/check/method.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ impl<'a> LookupContext<'a> {
788788

789789
ty_err => None,
790790

791-
ty_unboxed_vec(_) | ty_type | ty_infer(TyVar(_)) => {
791+
ty_unboxed_vec(_) | ty_infer(TyVar(_)) => {
792792
self.bug(format!("unexpected type: {}",
793793
self.ty_to_str(self_ty)));
794794
}

branches/try/src/librustc/middle/typeck/coherence.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use middle::ty::{substs, t, ty_bool, ty_char, ty_bot, ty_box, ty_enum, ty_err};
2323
use middle::ty::{ty_str, ty_vec, ty_float, ty_infer, ty_int, ty_nil};
2424
use middle::ty::{ty_param, ty_param_bounds_and_ty, ty_ptr};
2525
use middle::ty::{ty_rptr, ty_self, ty_struct, ty_trait, ty_tup};
26-
use middle::ty::{ty_type, ty_uint, ty_uniq, ty_bare_fn, ty_closure};
26+
use middle::ty::{ty_uint, ty_uniq, ty_bare_fn, ty_closure};
2727
use middle::ty::{ty_unboxed_vec, type_is_ty_var};
2828
use middle::subst::Subst;
2929
use middle::ty;
@@ -82,7 +82,7 @@ fn get_base_type(inference_context: &InferCtxt,
8282

8383
ty_nil | ty_bot | ty_bool | ty_char | ty_int(..) | ty_uint(..) | ty_float(..) |
8484
ty_str(..) | ty_vec(..) | ty_bare_fn(..) | ty_closure(..) | ty_tup(..) |
85-
ty_infer(..) | ty_param(..) | ty_self(..) | ty_type |
85+
ty_infer(..) | ty_param(..) | ty_self(..) |
8686
ty_unboxed_vec(..) | ty_err | ty_box(_) |
8787
ty_uniq(_) | ty_ptr(_) | ty_rptr(_, _) => {
8888
debug!("(getting base type) no base type; found {:?}",

branches/try/src/librustc/middle/typeck/variance.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,8 +715,7 @@ impl<'a> ConstraintContext<'a> {
715715
self.add_constraints_from_sig(sig, variance);
716716
}
717717

718-
ty::ty_infer(..) | ty::ty_err |
719-
ty::ty_type | ty::ty_unboxed_vec(..) => {
718+
ty::ty_infer(..) | ty::ty_err | ty::ty_unboxed_vec(..) => {
720719
self.tcx().sess.bug(
721720
format!("unexpected type encountered in \
722721
variance inference: {}",

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use middle::ty::{ReFree, ReScope, ReInfer, ReStatic, Region,
1818
ReEmpty};
1919
use middle::ty::{ty_bool, ty_char, ty_bot, ty_box, ty_struct, ty_enum};
2020
use middle::ty::{ty_err, ty_str, ty_vec, ty_float, ty_bare_fn, ty_closure};
21-
use middle::ty::{ty_nil, ty_param, ty_ptr, ty_rptr, ty_self, ty_tup, ty_type};
21+
use middle::ty::{ty_nil, ty_param, ty_ptr, ty_rptr, ty_self, ty_tup};
2222
use middle::ty::{ty_uniq, ty_trait, ty_int, ty_uint, ty_unboxed_vec, ty_infer};
2323
use middle::ty;
2424
use middle::typeck;
@@ -454,7 +454,6 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str {
454454
region_ptr_to_str(cx, r) + mt_to_str(cx, tm)
455455
}
456456
ty_unboxed_vec(ref tm) => { format!("unboxed_vec<{}>", mt_to_str(cx, tm)) }
457-
ty_type => ~"type",
458457
ty_tup(ref elems) => {
459458
let strs = elems.map(|elem| ty_to_str(cx, *elem));
460459
~"(" + strs.connect(",") + ")"

0 commit comments

Comments
 (0)