Skip to content

Commit 1fe2351

Browse files
---
yaml --- r: 152618 b: refs/heads/try2 c: feceb12 h: refs/heads/master v: v3
1 parent 82090d2 commit 1fe2351

Some content is hidden

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

54 files changed

+495
-935
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: d6736a1440d42f6af967a8a20ab8d73522112b72
8+
refs/heads/try2: feceb1276e3f7848fb6bee0a130065f6b1c56daf
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/doc/rust.md

Lines changed: 6 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ rule. A literal is a form of constant expression, so is evaluated (primarily)
234234
at compile time.
235235

236236
~~~~ {.ebnf .gram}
237-
literal : string_lit | char_lit | byte_string_lit | byte_lit | num_lit ;
237+
literal : string_lit | char_lit | num_lit ;
238238
~~~~
239239

240240
#### Character and string literals
@@ -244,17 +244,17 @@ char_lit : '\x27' char_body '\x27' ;
244244
string_lit : '"' string_body * '"' | 'r' raw_string ;
245245
246246
char_body : non_single_quote
247-
| '\x5c' [ '\x27' | common_escape | unicode_escape ] ;
247+
| '\x5c' [ '\x27' | common_escape ] ;
248248
249249
string_body : non_double_quote
250-
| '\x5c' [ '\x22' | common_escape | unicode_escape ] ;
250+
| '\x5c' [ '\x22' | common_escape ] ;
251251
raw_string : '"' raw_string_body '"' | '#' raw_string '#' ;
252252
253253
common_escape : '\x5c'
254254
| 'n' | 'r' | 't' | '0'
255255
| 'x' hex_digit 2
256-
unicode_escape : 'u' hex_digit 4
257-
| 'U' hex_digit 8 ;
256+
| 'u' hex_digit 4
257+
| 'U' hex_digit 8 ;
258258
259259
hex_digit : 'a' | 'b' | 'c' | 'd' | 'e' | 'f'
260260
| 'A' | 'B' | 'C' | 'D' | 'E' | 'F'
@@ -294,7 +294,7 @@ the following forms:
294294
escaped in order to denote *itself*.
295295

296296
Raw string literals do not process any escapes. They start with the character
297-
`U+0072` (`r`), followed by zero or more of the character `U+0023` (`#`) and a
297+
`U+0072` (`r`), followed zero or more of the character `U+0023` (`#`) and a
298298
`U+0022` (double-quote) character. The _raw string body_ is not defined in the
299299
EBNF grammar above: it can contain any sequence of Unicode characters and is
300300
terminated only by another `U+0022` (double-quote) character, followed by the
@@ -319,65 +319,6 @@ r##"foo #"# bar"##; // foo #"# bar
319319
"\\x52"; r"\x52"; // \x52
320320
~~~~
321321

322-
#### Byte and byte string literals
323-
324-
~~~~ {.ebnf .gram}
325-
byte_lit : 'b' '\x27' byte_body '\x27' ;
326-
byte_string_lit : 'b' '"' string_body * '"' | 'b' 'r' raw_byte_string ;
327-
328-
byte_body : ascii_non_single_quote
329-
| '\x5c' [ '\x27' | common_escape ] ;
330-
331-
byte_string_body : ascii_non_double_quote
332-
| '\x5c' [ '\x22' | common_escape ] ;
333-
raw_byte_string : '"' raw_byte_string_body '"' | '#' raw_byte_string '#' ;
334-
335-
~~~~
336-
337-
A _byte literal_ is a single ASCII character (in the `U+0000` to `U+007F` range)
338-
enclosed within two `U+0027` (single-quote) characters,
339-
with the exception of `U+0027` itself,
340-
which must be _escaped_ by a preceding U+005C character (`\`),
341-
or a single _escape_.
342-
It is equivalent to a `u8` unsigned 8-bit integer _number literal_.
343-
344-
A _byte string literal_ is a sequence of ASCII characters and _escapes_
345-
enclosed within two `U+0022` (double-quote) characters,
346-
with the exception of `U+0022` itself,
347-
which must be _escaped_ by a preceding `U+005C` character (`\`),
348-
or a _raw byte string literal_.
349-
It is equivalent to a `&'static [u8]` borrowed vectior unsigned 8-bit integers.
350-
351-
Some additional _escapes_ are available in either byte or non-raw byte string
352-
literals. An escape starts with a `U+005C` (`\`) and continues with one of
353-
the following forms:
354-
355-
* An _byte escape_ escape starts with `U+0078` (`x`) and is
356-
followed by exactly two _hex digits_. It denotes the byte
357-
equal to the provided hex value.
358-
* A _whitespace escape_ is one of the characters `U+006E` (`n`), `U+0072`
359-
(`r`), or `U+0074` (`t`), denoting the bytes values `0x0A` (ASCII LF),
360-
`0x0D` (ASCII CR) or `0x09` (ASCII HT) respectively.
361-
* The _backslash escape_ is the character `U+005C` (`\`) which must be
362-
escaped in order to denote its ASCII encoding `0x5C`.
363-
364-
Raw byte string literals do not process any escapes.
365-
They start with the character `U+0072` (`r`),
366-
followed by `U+0062` (`b`),
367-
followed by zero or more of the character `U+0023` (`#`),
368-
and a `U+0022` (double-quote) character.
369-
The _raw string body_ is not defined in the EBNF grammar above:
370-
it can contain any sequence of ASCII characters and is
371-
terminated only by another `U+0022` (double-quote) character, followed by the
372-
same number of `U+0023` (`#`) characters that preceded the opening `U+0022`
373-
(double-quote) character.
374-
A raw byte string literal can not contain any non-ASCII byte.
375-
376-
All characters contained in the raw string body represent their ASCII encoding,
377-
the characters `U+0022` (double-quote) (except when followed by at least as
378-
many `U+0023` (`#`) characters as were used to start the raw string literal) or
379-
`U+005C` (`\`) do not have any special meaning.
380-
381322
#### Number literals
382323

383324
~~~~ {.ebnf .gram}

branches/try2/src/libcore/option.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -574,13 +574,17 @@ impl<A> ExactSize<A> for Item<A> {}
574574
/// Here is an example which increments every integer in a vector,
575575
/// checking for overflow:
576576
///
577-
/// fn inc_conditionally(x: uint) -> Option<uint> {
578-
/// if x == uint::MAX { return None; }
579-
/// else { return Some(x+1u); }
580-
/// }
581-
/// let v = [1u, 2, 3];
582-
/// let res = collect(v.iter().map(|&x| inc_conditionally(x)));
583-
/// assert!(res == Some(~[2u, 3, 4]));
577+
/// ```rust
578+
/// use std::option;
579+
/// use std::uint;
580+
///
581+
/// let v = vec!(1u, 2u);
582+
/// let res: Option<Vec<uint>> = option::collect(v.iter().map(|x: &uint|
583+
/// if *x == uint::MAX { None }
584+
/// else { Some(x + 1) }
585+
/// ));
586+
/// assert!(res == Some(vec!(2u, 3u)));
587+
/// ```
584588
#[inline]
585589
pub fn collect<T, Iter: Iterator<Option<T>>, V: FromIterator<T>>(iter: Iter) -> Option<V> {
586590
// FIXME(#11084): This should be twice as fast once this bug is closed.

branches/try2/src/libcore/result.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -572,13 +572,17 @@ impl<T: Show, E> Result<T, E> {
572572
/// Here is an example which increments every integer in a vector,
573573
/// checking for overflow:
574574
///
575-
/// fn inc_conditionally(x: uint) -> Result<uint, &'static str> {
576-
/// if x == uint::MAX { return Err("overflow"); }
577-
/// else { return Ok(x+1u); }
578-
/// }
579-
/// let v = [1u, 2, 3];
580-
/// let res = collect(v.iter().map(|&x| inc_conditionally(x)));
581-
/// assert!(res == Ok(~[2u, 3, 4]));
575+
/// ```rust
576+
/// use std::result;
577+
/// use std::uint;
578+
///
579+
/// let v = vec!(1u, 2u);
580+
/// let res: Result<Vec<uint>, &'static str> = result::collect(v.iter().map(|x: &uint|
581+
/// if *x == uint::MAX { Err("Overflow!") }
582+
/// else { Ok(x + 1) }
583+
/// ));
584+
/// assert!(res == Ok(vec!(2u, 3u)));
585+
/// ```
582586
#[inline]
583587
pub fn collect<T, E, Iter: Iterator<Result<T, E>>, V: FromIterator<T>>(iter: Iter) -> Result<V, E> {
584588
// FIXME(#11084): This should be twice as fast once this bug is closed.

branches/try2/src/libcore/str.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,6 @@ Section: Comparing strings
560560

561561
// share the implementation of the lang-item vs. non-lang-item
562562
// eq_slice.
563-
/// NOTE: This function is (ab)used in rustc::middle::trans::_match
564-
/// to compare &[u8] byte slices that are not necessarily valid UTF-8.
565563
#[inline]
566564
fn eq_slice_(a: &str, b: &str) -> bool {
567565
#[allow(ctypes)]
@@ -574,8 +572,6 @@ fn eq_slice_(a: &str, b: &str) -> bool {
574572
}
575573

576574
/// Bytewise slice equality
577-
/// NOTE: This function is (ab)used in rustc::middle::trans::_match
578-
/// to compare &[u8] byte slices that are not necessarily valid UTF-8.
579575
#[cfg(not(test))]
580576
#[lang="str_eq"]
581577
#[inline]

branches/try2/src/libregex_macros/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
182182
#[allow(unused_variable)]
183183
fn run(&mut self, start: uint, end: uint) -> Vec<Option<uint>> {
184184
let mut matched = false;
185-
let prefix_bytes: &[u8] = $prefix_bytes;
185+
let prefix_bytes: &[u8] = &$prefix_bytes;
186186
let mut clist = &mut Threads::new(self.which);
187187
let mut nlist = &mut Threads::new(self.which);
188188

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,10 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t {
346346
assert_eq!(next(st), '[');
347347
let def = parse_def(st, NominalType, |x,y| conv(x,y));
348348
let substs = parse_substs(st, |x,y| conv(x,y));
349+
let store = parse_trait_store(st, |x,y| conv(x,y));
349350
let bounds = parse_bounds(st, |x,y| conv(x,y));
350351
assert_eq!(next(st), ']');
351-
return ty::mk_trait(st.tcx, def, substs, bounds.builtin_bounds);
352+
return ty::mk_trait(st.tcx, def, substs, store, bounds.builtin_bounds);
352353
}
353354
'p' => {
354355
let did = parse_def(st, TypeParameter, |x,y| conv(x,y));

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,12 @@ fn enc_sty(w: &mut MemWriter, cx: &ctxt, st: &ty::sty) {
232232
ty::ty_trait(box ty::TyTrait {
233233
def_id,
234234
ref substs,
235+
store,
235236
bounds
236237
}) => {
237238
mywrite!(w, "x[{}|", (cx.ds)(def_id));
238239
enc_substs(w, cx, substs);
240+
enc_trait_store(w, cx, store);
239241
let bounds = ty::ParamBounds {builtin_bounds: bounds,
240242
trait_bounds: Vec::new()};
241243
enc_bounds(w, cx, &bounds);

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,6 @@ pub fn lit_to_const(lit: &Lit) -> const_val {
506506
LitBinary(ref data) => {
507507
const_binary(Rc::new(data.iter().map(|x| *x).collect()))
508508
}
509-
LitByte(n) => const_uint(n as u64),
510509
LitChar(n) => const_uint(n as u64),
511510
LitInt(n, _) => const_int(n),
512511
LitUint(n, _) => const_uint(n),
@@ -529,7 +528,6 @@ pub fn compare_const_vals(a: &const_val, b: &const_val) -> Option<int> {
529528
(&const_float(a), &const_float(b)) => compare_vals(a, b),
530529
(&const_str(ref a), &const_str(ref b)) => compare_vals(a, b),
531530
(&const_bool(a), &const_bool(b)) => compare_vals(a, b),
532-
(&const_binary(ref a), &const_binary(ref b)) => compare_vals(a, b),
533531
_ => None
534532
}
535533
}

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,9 @@ fn check_bounds_on_type_parameters(cx: &mut Context, e: &Expr) {
361361
fn check_trait_cast(cx: &mut Context, source_ty: ty::t, target_ty: ty::t, span: Span) {
362362
check_cast_for_escaping_regions(cx, source_ty, target_ty, span);
363363
match ty::get(target_ty).sty {
364-
ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ ty, .. }) => match ty::get(ty).sty {
365-
ty::ty_trait(box ty::TyTrait { bounds, .. }) => {
366-
check_trait_cast_bounds(cx, span, source_ty, bounds);
367-
}
368-
_ => {}
369-
},
364+
ty::ty_trait(box ty::TyTrait { bounds, .. }) => {
365+
check_trait_cast_bounds(cx, span, source_ty, bounds);
366+
}
370367
_ => {}
371368
}
372369
}
@@ -533,8 +530,9 @@ pub fn check_cast_for_escaping_regions(
533530
{
534531
// Determine what type we are casting to; if it is not a trait, then no
535532
// worries.
536-
if !ty::type_is_trait(target_ty) {
537-
return;
533+
match ty::get(target_ty).sty {
534+
ty::ty_trait(..) => {}
535+
_ => { return; }
538536
}
539537

540538
// Collect up the regions that appear in the target type. We want to

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,6 @@ fn check_type_limits(cx: &Context, e: &ast::Expr) {
805805
} else { t };
806806
let (min, max) = uint_ty_range(uint_type);
807807
let lit_val: u64 = match lit.node {
808-
ast::LitByte(_v) => return, // _v is u8, within range by definition
809808
ast::LitInt(v, _) => v as u64,
810809
ast::LitUint(v, _) => v,
811810
ast::LitIntUnsuffixed(v) => v as u64,
@@ -981,6 +980,9 @@ fn check_heap_type(cx: &Context, span: Span, ty: ty::t) {
981980
n_box += 1;
982981
}
983982
ty::ty_uniq(_) |
983+
ty::ty_trait(box ty::TyTrait {
984+
store: ty::UniqTraitStore, ..
985+
}) |
984986
ty::ty_closure(box ty::ClosureTy {
985987
store: ty::UniqTraitStore,
986988
..

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ pub enum deref_kind {
174174
pub fn opt_deref_kind(t: ty::t) -> Option<deref_kind> {
175175
match ty::get(t).sty {
176176
ty::ty_uniq(_) |
177+
ty::ty_trait(box ty::TyTrait { store: ty::UniqTraitStore, .. }) |
177178
ty::ty_closure(box ty::ClosureTy {store: ty::UniqTraitStore, ..}) => {
178179
Some(deref_ptr(OwnedPtr))
179180
}
@@ -182,6 +183,13 @@ pub fn opt_deref_kind(t: ty::t) -> Option<deref_kind> {
182183
let kind = ty::BorrowKind::from_mutbl(mt.mutbl);
183184
Some(deref_ptr(BorrowedPtr(kind, r)))
184185
}
186+
ty::ty_trait(box ty::TyTrait {
187+
store: ty::RegionTraitStore(r, mutbl),
188+
..
189+
}) => {
190+
let kind = ty::BorrowKind::from_mutbl(mutbl);
191+
Some(deref_ptr(BorrowedPtr(kind, r)))
192+
}
185193

186194
ty::ty_closure(box ty::ClosureTy {
187195
store: ty::RegionTraitStore(r, _),

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

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,24 +1273,13 @@ fn compare_values<'a>(
12731273
val: bool_to_i1(result.bcx, result.val)
12741274
}
12751275
}
1276-
_ => cx.sess().bug("only strings supported in compare_values"),
1276+
_ => cx.sess().bug("only scalars and strings supported in compare_values"),
12771277
},
12781278
ty::ty_rptr(_, mt) => match ty::get(mt.ty).sty {
12791279
ty::ty_str => compare_str(cx, lhs, rhs, rhs_t),
1280-
ty::ty_vec(mt, _) => match ty::get(mt.ty).sty {
1281-
ty::ty_uint(ast::TyU8) => {
1282-
// NOTE: cast &[u8] to &str and abuse the str_eq lang item,
1283-
// which calls memcmp().
1284-
let t = ty::mk_str_slice(cx.tcx(), ty::ReStatic, ast::MutImmutable);
1285-
let lhs = BitCast(cx, lhs, type_of::type_of(cx.ccx(), t).ptr_to());
1286-
let rhs = BitCast(cx, rhs, type_of::type_of(cx.ccx(), t).ptr_to());
1287-
compare_str(cx, lhs, rhs, rhs_t)
1288-
},
1289-
_ => cx.sess().bug("only byte strings supported in compare_values"),
1290-
},
1291-
_ => cx.sess().bug("on string and byte strings supported in compare_values"),
1280+
_ => cx.sess().bug("only scalars and strings supported in compare_values"),
12921281
},
1293-
_ => cx.sess().bug("only scalars, byte strings, and strings supported in compare_values"),
1282+
_ => cx.sess().bug("only scalars and strings supported in compare_values"),
12941283
}
12951284
}
12961285

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,12 @@ impl Case {
292292
fn find_ptr(&self) -> Option<uint> {
293293
self.tys.iter().position(|&ty| {
294294
match ty::get(ty).sty {
295-
ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) => match ty::get(ty).sty {
296-
ty::ty_vec(_, None) | ty::ty_str| ty::ty_trait(..) => false,
295+
ty::ty_rptr(_, mt) => match ty::get(mt.ty).sty {
296+
ty::ty_vec(_, None) | ty::ty_str => false,
297297
_ => true,
298298
},
299-
ty::ty_box(..) | ty::ty_bare_fn(..) => true,
299+
ty::ty_uniq(..) | ty::ty_box(..) |
300+
ty::ty_bare_fn(..) => true,
300301
// Is that everything? Would closures or slices qualify?
301302
_ => false
302303
}

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,9 +1794,6 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t) -> Vec<(uint, u6
17941794
match ty::get(ret_ty).sty {
17951795
// `~` pointer return values never alias because ownership
17961796
// is transferred
1797-
ty::ty_uniq(it) if match ty::get(it).sty {
1798-
ty::ty_str | ty::ty_vec(..) | ty::ty_trait(..) => true, _ => false
1799-
} => {}
18001797
ty::ty_uniq(_) => {
18011798
attrs.push((lib::llvm::ReturnIndex as uint, lib::llvm::NoAliasAttribute as u64));
18021799
}
@@ -1806,9 +1803,9 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t) -> Vec<(uint, u6
18061803
// We can also mark the return value as `nonnull` in certain cases
18071804
match ty::get(ret_ty).sty {
18081805
// These are not really pointers but pairs, (pointer, len)
1809-
ty::ty_uniq(it) |
1806+
ty::ty_rptr(_, ty::mt { ty: it, .. }) |
18101807
ty::ty_rptr(_, ty::mt { ty: it, .. }) if match ty::get(it).sty {
1811-
ty::ty_str | ty::ty_vec(..) | ty::ty_trait(..) => true, _ => false
1808+
ty::ty_str | ty::ty_vec(..) => true, _ => false
18121809
} => {}
18131810
ty::ty_uniq(_) | ty::ty_rptr(_, _) => {
18141811
attrs.push((lib::llvm::ReturnIndex as uint, lib::llvm::NonNullAttribute as u64));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub fn type_is_immediate(ccx: &CrateContext, ty: ty::t) -> bool {
6767
ty::type_is_unique(ty) || ty::type_is_region_ptr(ty) ||
6868
type_is_newtype_immediate(ccx, ty) || ty::type_is_bot(ty) ||
6969
ty::type_is_simd(tcx, ty);
70-
if simple && !ty::type_is_trait(ty) {
70+
if simple {
7171
return true;
7272
}
7373
match ty::get(ty).sty {

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: ast::Lit)
4343
-> ValueRef {
4444
let _icx = push_ctxt("trans_lit");
4545
match lit.node {
46-
ast::LitByte(b) => C_integral(Type::uint_from_ty(cx, ast::TyU8), b as u64, false),
4746
ast::LitChar(i) => C_integral(Type::char(cx), i as u64, false),
4847
ast::LitInt(i, t) => C_integral(Type::int_from_ty(cx, t), i as u64, true),
4948
ast::LitUint(u, t) => C_integral(Type::uint_from_ty(cx, t), u, false),
@@ -144,9 +143,7 @@ fn const_deref(cx: &CrateContext, v: ValueRef, t: ty::t, explicit: bool)
144143
let dv = match ty::get(t).sty {
145144
ty::ty_ptr(mt) | ty::ty_rptr(_, mt) => {
146145
match ty::get(mt.ty).sty {
147-
ty::ty_vec(_, None) | ty::ty_str | ty::ty_trait(..) => {
148-
cx.sess().bug("unexpected unsized type")
149-
}
146+
ty::ty_vec(_, None) | ty::ty_str => cx.sess().bug("unexpected slice"),
150147
_ => const_deref_ptr(cx, v),
151148
}
152149
}

0 commit comments

Comments
 (0)