Skip to content

Commit 2b7d373

Browse files
committed
---
yaml --- r: 104137 b: refs/heads/try c: 4f72c01 h: refs/heads/master i: 104135: 74d3d2e v: v3
1 parent d0cb50c commit 2b7d373

33 files changed

+162
-174
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: 58eeb07c2a128cbba403d6204c2f291af4ddf938
5+
refs/heads/try: 4f72c018cec120d596ece1b5f2a2e7d59f1ef520
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: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,42 +36,12 @@ 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;
39+
use std::num::from_str_radix;
4040
41-
let x: Option<i64> = num::from_str_radix("deadbeef", 16);
41+
let x: Option<i64> = 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-
7545
# File operations
7646

7747
## How do I read from a file?

branches/try/src/doc/tutorial.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ braced block gives the whole block the value of that last expression.
293293

294294
Put another way, the semicolon in Rust *ignores the value of an expression*.
295295
Thus, if the branches of the `if` had looked like `{ 4; }`, the above example
296-
would simply assign `()` (nil or void) to `price`. But without the semicolon, each
296+
would simply assign `()` (unit or void) to `price`. But without the semicolon, each
297297
branch has a different value, and `price` gets the value of the branch that
298298
was taken.
299299

@@ -352,7 +352,7 @@ before the opening and after the closing quote, and can contain any sequence of
352352
characters except their closing delimiter. More on strings
353353
[later](#vectors-and-strings).
354354

355-
The nil type, written `()`, has a single value, also written `()`.
355+
The unit type, written `()`, has a single value, also written `()`.
356356

357357
## Operators
358358

@@ -852,7 +852,7 @@ fn line(a: int, b: int, x: int) -> int {
852852
It's better Rust style to write a return value this way instead of
853853
writing an explicit `return`. The utility of `return` comes in when
854854
returning early from a function. Functions that do not return a value
855-
are said to return nil, `()`, and both the return type and the return
855+
are said to return unit, `()`, and both the return type and the return
856856
value may be omitted from the definition. The following two functions
857857
are equivalent.
858858

branches/try/src/libfourcc/lib.rs

Lines changed: 6 additions & 5 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-
assert_eq!(val, 0xC0FFEE21u32);
31-
let little_val = fourcc!("foo ", little);
32-
assert_eq!(little_val, 0x21EEFFC0u32);
29+
let val = fourcc!("\xC0\xFF\xEE!")
30+
// val is 0xC0FFEE21
31+
let big_val = fourcc!("foo ", big);
32+
// big_val is 0x21EEFFC0
3333
}
3434
```
3535
@@ -60,6 +60,7 @@ use syntax::parse::token;
6060
use syntax::parse::token::InternedString;
6161

6262
#[macro_registrar]
63+
#[cfg(not(test))]
6364
pub fn macro_registrar(register: |Name, SyntaxExtension|) {
6465
register(token::intern("fourcc"),
6566
NormalTT(~BasicMacroExpander {
@@ -154,6 +155,6 @@ fn target_endian_little(cx: &ExtCtxt, sp: Span) -> bool {
154155
contains(cx.cfg(), meta)
155156
}
156157

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

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ 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),
375376
'#' => {
376377
let pos = parse_hex(st);
377378
assert_eq!(next(st), ':');

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ 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"),
331332
ty::ty_struct(def, ref substs) => {
332333
mywrite!(w, "a[{}|", (cx.ds)(def));
333334
enc_substs(w, cx, substs);

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,19 @@ 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+
_ => {
601610
// Should never get here, because t is scalar.
602-
_ => cx.sess().bug("non-scalar type passed to compare_scalar_types")
611+
cx.sess().bug("non-scalar type passed to \
612+
compare_scalar_types")
613+
}
603614
}
604615
}
605616

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

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

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>,
155+
pub fn allocate_cbox<'a>(
156+
bcx: &'a Block<'a>,
161157
sigil: ast::Sigil,
162158
cdata_ty: ty::t)
163159
-> Result<'a> {

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,19 @@ 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+
523536
// LLVM constant constructors.
524537
pub fn C_null(t: Type) -> ValueRef {
525538
unsafe {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@ 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")
371+
ty::ty_self(..) => self.leaf("self"),
372+
ty::ty_type => self.leaf("type")
372373
}
373374
}
374375

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ 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(..) => Type::i8p(),
122+
ty::ty_rptr(..) |
123+
ty::ty_type => Type::i8p(),
123124

124125
ty::ty_str(ty::vstore_slice(..)) |
125126
ty::ty_vec(_, ty::vstore_slice(..)) => {
@@ -262,6 +263,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
262263
Type::struct_([fn_ty, Type::i8p()], false)
263264
}
264265
ty::ty_trait(..) => Type::opaque_trait(),
266+
ty::ty_type => cx.tydesc_type.ptr_to(),
265267
ty::ty_tup(..) => {
266268
let repr = adt::represent_type(cx, t);
267269
adt::type_of(cx, repr)

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

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

758758
// "Fake" types, used for trans purposes
759+
ty_type, // type_desc*
759760
ty_unboxed_vec(mt),
760761
}
761762

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

1447+
pub fn mk_type(cx: ctxt) -> t { mk_t(cx, ty_type) }
1448+
14461449
pub fn walk_ty(ty: t, f: |t|) {
14471450
maybe_walk_ty(ty, |t| { f(t); true });
14481451
}
@@ -1453,7 +1456,7 @@ pub fn maybe_walk_ty(ty: t, f: |t| -> bool) {
14531456
}
14541457
match get(ty).sty {
14551458
ty_nil | ty_bot | ty_bool | ty_char | ty_int(_) | ty_uint(_) | ty_float(_) |
1456-
ty_str(_) | ty_self(_) |
1459+
ty_str(_) | ty_type | ty_self(_) |
14571460
ty_infer(_) | ty_param(_) | ty_err => {}
14581461
ty_box(ty) | ty_uniq(ty) => maybe_walk_ty(ty, f),
14591462
ty_vec(ref tm, _) | ty_unboxed_vec(ref tm) | ty_ptr(ref tm) |
@@ -1727,7 +1730,7 @@ pub fn type_is_unique(ty: t) -> bool {
17271730
pub fn type_is_scalar(ty: t) -> bool {
17281731
match get(ty).sty {
17291732
ty_nil | ty_bool | ty_char | ty_int(_) | ty_float(_) | ty_uint(_) |
1730-
ty_infer(IntVar(_)) | ty_infer(FloatVar(_)) |
1733+
ty_infer(IntVar(_)) | ty_infer(FloatVar(_)) | ty_type |
17311734
ty_bare_fn(..) | ty_ptr(_) => true,
17321735
_ => false
17331736
}
@@ -2213,6 +2216,8 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
22132216
}
22142217
ty_unboxed_vec(mt) => TC::InteriorUnsized | tc_mt(cx, mt, cache),
22152218

2219+
ty_type => TC::None,
2220+
22162221
ty_err => {
22172222
cx.sess.bug("asked to compute contents of error type");
22182223
}
@@ -2396,6 +2401,7 @@ pub fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
23962401
ty_err |
23972402
ty_param(_) |
23982403
ty_self(_) |
2404+
ty_type |
23992405
ty_vec(_, _) |
24002406
ty_unboxed_vec(_) => {
24012407
false
@@ -2622,7 +2628,7 @@ pub fn type_is_pod(cx: ctxt, ty: t) -> bool {
26222628
match get(ty).sty {
26232629
// Scalar types
26242630
ty_nil | ty_bot | ty_bool | ty_char | ty_int(_) | ty_float(_) | ty_uint(_) |
2625-
ty_ptr(_) | ty_bare_fn(_) => result = true,
2631+
ty_type | ty_ptr(_) | ty_bare_fn(_) => result = true,
26262632
// Boxed types
26272633
ty_box(_) | ty_uniq(_) | ty_closure(_) |
26282634
ty_str(vstore_uniq) |
@@ -3550,7 +3556,7 @@ pub fn occurs_check(tcx: ctxt, sp: Span, vid: TyVid, rt: t) {
35503556
pub fn ty_sort_str(cx: ctxt, t: t) -> ~str {
35513557
match get(t).sty {
35523558
ty_nil | ty_bot | ty_bool | ty_char | ty_int(_) |
3553-
ty_uint(_) | ty_float(_) | ty_str(_) => {
3559+
ty_uint(_) | ty_float(_) | ty_str(_) | ty_type => {
35543560
::util::ppaux::ty_to_str(cx, t)
35553561
}
35563562

@@ -5114,8 +5120,9 @@ pub fn hash_crate_independent(tcx: ctxt, t: t, local_hash: ~str) -> u64 {
51145120
}
51155121
ty_infer(_) => unreachable!(),
51165122
ty_err => hash.input([23]),
5123+
ty_type => hash.input([24]),
51175124
ty_unboxed_vec(m) => {
5118-
hash.input([24]);
5125+
hash.input([25]);
51195126
mt(&mut hash, m);
51205127
}
51215128
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ 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(_) | ty::ty_float(_) |
190+
ty::ty_int(_) | ty::ty_uint(_) |
191+
ty::ty_float(_) | ty::ty_type |
191192
ty::ty_err | ty::ty_infer(_) |
192193
ty::ty_param(..) | ty::ty_self(_) => {
193194
(*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_infer(TyVar(_)) => {
791+
ty_unboxed_vec(_) | ty_type | 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_uint, ty_uniq, ty_bare_fn, ty_closure};
26+
use middle::ty::{ty_type, 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(..) |
85+
ty_infer(..) | ty_param(..) | ty_self(..) | ty_type |
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,8 @@ impl<'a> ConstraintContext<'a> {
715715
self.add_constraints_from_sig(sig, variance);
716716
}
717717

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

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

Lines changed: 2 additions & 1 deletion
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};
21+
use middle::ty::{ty_nil, ty_param, ty_ptr, ty_rptr, ty_self, ty_tup, ty_type};
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,6 +454,7 @@ 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",
457458
ty_tup(ref elems) => {
458459
let strs = elems.map(|elem| ty_to_str(cx, *elem));
459460
~"(" + strs.connect(",") + ")"

0 commit comments

Comments
 (0)