Skip to content

Commit c5ad640

Browse files
committed
---
yaml --- r: 152629 b: refs/heads/try2 c: 34e3232 h: refs/heads/master i: 152627: 9f0e07f v: v3
1 parent 45fc0f2 commit c5ad640

Some content is hidden

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

69 files changed

+1470
-841
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: 23a7d24dd70c3614952df695a5fe78fbcd7ac20b
8+
refs/heads/try2: 34e3232705539e4506ceb4c19944f7d894413fca
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: 76 additions & 10 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 | num_lit ;
237+
literal : string_lit | char_lit | byte_string_lit | byte_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 ] ;
247+
| '\x5c' [ '\x27' | common_escape | unicode_escape ] ;
248248
249249
string_body : non_double_quote
250-
| '\x5c' [ '\x22' | common_escape ] ;
250+
| '\x5c' [ '\x22' | common_escape | unicode_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-
| 'u' hex_digit 4
257-
| 'U' hex_digit 8 ;
256+
unicode_escape : '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 zero or more of the character `U+0023` (`#`) and a
297+
`U+0072` (`r`), followed by 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,6 +319,65 @@ 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+
322381
#### Number literals
323382

324383
~~~~ {.ebnf .gram}
@@ -1829,8 +1888,6 @@ type int8_t = i8;
18291888

18301889
### Static-only attributes
18311890

1832-
- `address_insignificant` - references to this static may alias with
1833-
references to other statics, potentially of unrelated type.
18341891
- `thread_local` - on a `static mut`, this signals that the value of this
18351892
static may change depending on the current thread. The exact consequences of
18361893
this are implementation-defined.
@@ -2141,13 +2198,22 @@ These types help drive the compiler's analysis
21412198
### Inline attributes
21422199

21432200
The inline attribute is used to suggest to the compiler to perform an inline
2144-
expansion and place a copy of the function in the caller rather than generating
2145-
code to call the function where it is defined.
2201+
expansion and place a copy of the function or static in the caller rather than
2202+
generating code to call the function or access the static where it is defined.
21462203

21472204
The compiler automatically inlines functions based on internal heuristics.
21482205
Incorrectly inlining functions can actually making the program slower, so it
21492206
should be used with care.
21502207

2208+
Immutable statics are always considered inlineable
2209+
unless marked with `#[inline(never)]`.
2210+
It is undefined
2211+
whether two different inlineable statics
2212+
have the same memory address.
2213+
In other words,
2214+
the compiler is free
2215+
to collapse duplicate inlineable statics together.
2216+
21512217
`#[inline]` and `#[inline(always)]` always causes the function to be serialized
21522218
into crate metadata to allow cross-crate inlining.
21532219

branches/try2/src/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3247,7 +3247,7 @@ fn main() { println!("hello {}", world::explore()); }
32473247
Now compile and run like this (adjust to your platform if necessary):
32483248

32493249
~~~~console
3250-
$ rustc --crate-type=lib world.rs # compiles libworld-<HASH>-0.42.so
3250+
$ rustc --crate-type=lib world.rs # compiles libworld-<HASH>-0.42.rlib
32513251
$ rustc main.rs -L . # compiles main
32523252
$ ./main
32533253
"hello world"

branches/try2/src/liballoc/owned.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ use core::result::{Ok, Err, Result};
2525
///
2626
/// The following two examples are equivalent:
2727
///
28-
/// let foo = box(HEAP) Bar::new(...);
29-
/// let foo = box Bar::new(...);
28+
/// use std::owned::HEAP;
29+
///
30+
/// # struct Bar;
31+
/// # impl Bar { fn new(_a: int) { } }
32+
/// let foo = box(HEAP) Bar::new(2);
33+
/// let foo = box Bar::new(2);
3034
#[lang="exchange_heap"]
3135
pub static HEAP: () = ();
3236

branches/try2/src/libcore/failure.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
//! useful an upstream crate must define failure for libcore to use. The current
1616
//! interface for failure is:
1717
//!
18-
//! fn begin_unwind(fmt: &fmt::Arguments, file: &str, line: uint) -> !;
18+
//! ```ignore
19+
//! fn begin_unwind(fmt: &fmt::Arguments, file: &str, line: uint) -> !;
20+
//! ```
1921
//!
2022
//! This definition allows for failing with any general message, but it does not
2123
//! allow for failing with a `~Any` value. The reason for this is that libcore

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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,8 @@ 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.
563565
#[inline]
564566
fn eq_slice_(a: &str, b: &str) -> bool {
565567
#[allow(ctypes)]
@@ -572,6 +574,8 @@ fn eq_slice_(a: &str, b: &str) -> bool {
572574
}
573575

574576
/// 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.
575579
#[cfg(not(test))]
576580
#[lang="str_eq"]
577581
#[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: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,9 @@ 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));
350349
let bounds = parse_bounds(st, |x,y| conv(x,y));
351350
assert_eq!(next(st), ']');
352-
return ty::mk_trait(st.tcx, def, substs, store, bounds.builtin_bounds);
351+
return ty::mk_trait(st.tcx, def, substs, bounds.builtin_bounds);
353352
}
354353
'p' => {
355354
let did = parse_def(st, TypeParameter, |x,y| conv(x,y));

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,10 @@ 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,
236235
bounds
237236
}) => {
238237
mywrite!(w, "x[{}|", (cx.ds)(def_id));
239238
enc_substs(w, cx, substs);
240-
enc_trait_store(w, cx, store);
241239
let bounds = ty::ParamBounds {builtin_bounds: bounds,
242240
trait_bounds: Vec::new()};
243241
enc_bounds(w, cx, &bounds);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ 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),
509510
LitChar(n) => const_uint(n as u64),
510511
LitInt(n, _) => const_int(n),
511512
LitUint(n, _) => const_uint(n),
@@ -528,6 +529,7 @@ pub fn compare_const_vals(a: &const_val, b: &const_val) -> Option<int> {
528529
(&const_float(a), &const_float(b)) => compare_vals(a, b),
529530
(&const_str(ref a), &const_str(ref b)) => compare_vals(a, b),
530531
(&const_bool(a), &const_bool(b)) => compare_vals(a, b),
532+
(&const_binary(ref a), &const_binary(ref b)) => compare_vals(a, b),
531533
_ => None
532534
}
533535
}

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,12 @@ 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_trait(box ty::TyTrait { bounds, .. }) => {
365-
check_trait_cast_bounds(cx, span, source_ty, bounds);
366-
}
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+
},
367370
_ => {}
368371
}
369372
}
@@ -530,9 +533,8 @@ pub fn check_cast_for_escaping_regions(
530533
{
531534
// Determine what type we are casting to; if it is not a trait, then no
532535
// worries.
533-
match ty::get(target_ty).sty {
534-
ty::ty_trait(..) => {}
535-
_ => { return; }
536+
if !ty::type_is_trait(target_ty) {
537+
return;
536538
}
537539

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

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,7 @@ 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
808809
ast::LitInt(v, _) => v as u64,
809810
ast::LitUint(v, _) => v,
810811
ast::LitIntUnsuffixed(v) => v as u64,
@@ -980,9 +981,6 @@ fn check_heap_type(cx: &Context, span: Span, ty: ty::t) {
980981
n_box += 1;
981982
}
982983
ty::ty_uniq(_) |
983-
ty::ty_trait(box ty::TyTrait {
984-
store: ty::UniqTraitStore, ..
985-
}) |
986984
ty::ty_closure(box ty::ClosureTy {
987985
store: ty::UniqTraitStore,
988986
..
@@ -1087,7 +1085,6 @@ fn check_unused_attribute(cx: &Context, attr: &ast::Attribute) {
10871085

10881086
// FIXME: #14406 these are processed in trans, which happens after the
10891087
// lint pass
1090-
"address_insignificant",
10911088
"cold",
10921089
"inline",
10931090
"link",

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ 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, .. }) |
178177
ty::ty_closure(box ty::ClosureTy {store: ty::UniqTraitStore, ..}) => {
179178
Some(deref_ptr(OwnedPtr))
180179
}
@@ -183,13 +182,6 @@ pub fn opt_deref_kind(t: ty::t) -> Option<deref_kind> {
183182
let kind = ty::BorrowKind::from_mutbl(mt.mutbl);
184183
Some(deref_ptr(BorrowedPtr(kind, r)))
185184
}
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-
}
193185

194186
ty::ty_closure(box ty::ClosureTy {
195187
store: ty::RegionTraitStore(r, _),

0 commit comments

Comments
 (0)