Skip to content

Commit 04e7ae3

Browse files
committed
---
yaml --- r: 83764 b: refs/heads/try c: 6dfc5d5 h: refs/heads/master v: v3
1 parent a794711 commit 04e7ae3

File tree

37 files changed

+129
-278
lines changed

37 files changed

+129
-278
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: 0e4d1fc8cae42e15e00f71d9f439b01bb25a86ae
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6c08cc2db4f98e9f07ae7d50338396c4123c2f0a
5-
refs/heads/try: d7dfe0ae34eb9a818dcbdb5646e21e721ffb3c33
5+
refs/heads/try: 6dfc5d5de1c933a030618e6dcf20a1c3027fe846
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/doc/rust.md

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,13 @@ literal : string_lit | char_lit | num_lit ;
239239

240240
~~~~~~~~ {.ebnf .gram}
241241
char_lit : '\x27' char_body '\x27' ;
242-
string_lit : '"' string_body * '"' | 'r' raw_string ;
242+
string_lit : '"' string_body * '"' ;
243243
244244
char_body : non_single_quote
245245
| '\x5c' [ '\x27' | common_escape ] ;
246246
247247
string_body : non_double_quote
248248
| '\x5c' [ '\x22' | common_escape ] ;
249-
raw_string : '"' raw_string_body '"' | '#' raw_string '#' ;
250249
251250
common_escape : '\x5c'
252251
| 'n' | 'r' | 't' | '0'
@@ -268,10 +267,9 @@ which must be _escaped_ by a preceding U+005C character (`\`).
268267

269268
A _string literal_ is a sequence of any Unicode characters enclosed within
270269
two `U+0022` (double-quote) characters, with the exception of `U+0022`
271-
itself, which must be _escaped_ by a preceding `U+005C` character (`\`),
272-
or a _raw string literal_.
270+
itself, which must be _escaped_ by a preceding `U+005C` character (`\`).
273271

274-
Some additional _escapes_ are available in either character or non-raw string
272+
Some additional _escapes_ are available in either character or string
275273
literals. An escape starts with a `U+005C` (`\`) and continues with one of
276274
the following forms:
277275

@@ -287,35 +285,9 @@ the following forms:
287285
* A _whitespace escape_ is one of the characters `U+006E` (`n`), `U+0072`
288286
(`r`), or `U+0074` (`t`), denoting the unicode values `U+000A` (LF),
289287
`U+000D` (CR) or `U+0009` (HT) respectively.
290-
* The _backslash escape_ is the character `U+005C` (`\`) which must be
288+
* The _backslash escape_ is the character U+005C (`\`) which must be
291289
escaped in order to denote *itself*.
292290

293-
Raw string literals do not process any escapes. They start with the character
294-
`U+0072` (`r`), followed zero or more of the character `U+0023` (`#`) and a
295-
`U+0022` (double-quote) character. The _raw string body_ is not defined in the
296-
EBNF grammar above: it can contain any sequence of Unicode characters and is
297-
terminated only by another `U+0022` (double-quote) character, followed by the
298-
same number of `U+0023` (`#`) characters that preceeded the opening `U+0022`
299-
(double-quote) character.
300-
301-
All Unicode characters contained in the raw string body represent themselves,
302-
the characters `U+0022` (double-quote) (except when followed by at least as
303-
many `U+0023` (`#`) characters as were used to start the raw string literal) or
304-
`U+005C` (`\`) do not have any special meaning.
305-
306-
Examples for string literals:
307-
308-
~~~
309-
"foo"; r"foo"; // foo
310-
"\"foo\""; r#""foo""#; // "foo"
311-
312-
"foo #\"# bar";
313-
r##"foo #"# bar"##; // foo #"# bar
314-
315-
"\x52"; "R"; r"R"; // R
316-
"\\x52"; r"\x52"; // \x52
317-
~~~
318-
319291
#### Number literals
320292

321293
~~~~~~~~ {.ebnf .gram}

branches/try/doc/tutorial.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,7 @@ whose literals are written between single quotes, as in `'x'`.
353353
Just like C, Rust understands a number of character escapes, using the backslash
354354
character, such as `\n`, `\r`, and `\t`. String literals,
355355
written between double quotes, allow the same escape sequences.
356-
357-
On the other hand, raw string literals do not process any escape sequences.
358-
They are written as `r##"blah"##`, with a matching number of zero or more `#`
359-
before the opening and after the closing quote, and can contain any sequence of
360-
characters except their closing delimiter. More on strings
361-
[later](#vectors-and-strings).
356+
More on strings [later](#vectors-and-strings).
362357

363358
The nil type, written `()`, has a single value, also written `()`.
364359

branches/try/src/etc/vim/syntax/rust.vim

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ syn match rustFormat display "%%" contained
148148
syn match rustSpecial display contained /\\\([nrt\\'"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)/
149149
syn match rustStringContinuation display contained /\\\n\s*/
150150
syn region rustString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=rustTodo,rustFormat,rustSpecial,rustStringContinuation
151-
syn region rustString start='r\z(#*\)"' end='"\z1'
152151

153152
syn region rustAttribute start="#\[" end="\]" contains=rustString,rustDeriving
154153
syn region rustDeriving start="deriving(" end=")" contained contains=rustTrait

branches/try/src/librustc/front/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> @ast::Expr {
407407
debug2!("encoding {}", ast_util::path_name_i(path));
408408

409409
let name_lit: ast::lit =
410-
nospan(ast::lit_str(ast_util::path_name_i(path).to_managed(), ast::CookedStr));
410+
nospan(ast::lit_str(ast_util::path_name_i(path).to_managed()));
411411

412412
let name_expr = @ast::Expr {
413413
id: ast::DUMMY_NODE_ID,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ fn visit_view_item(e: @mut Env, i: &ast::view_item) {
142142
let ident = token::ident_to_str(&ident);
143143
let meta_items = match path_opt {
144144
None => meta_items.clone(),
145-
Some((p, _path_str_style)) => {
145+
Some(p) => {
146146
let p_path = Path(p);
147147
match p_path.filestem() {
148148
Some(s) =>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,7 @@ fn encode_meta_item(ebml_w: &mut writer::Encoder, mi: @MetaItem) {
14461446
}
14471447
MetaNameValue(name, value) => {
14481448
match value.node {
1449-
lit_str(value, _) => {
1449+
lit_str(value) => {
14501450
ebml_w.start_tag(tag_meta_item_name_value);
14511451
ebml_w.start_tag(tag_meta_item_name);
14521452
ebml_w.writer.write(name.as_bytes());

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub fn check_pat(v: &mut CheckCrateVisitor, p: @Pat, _is_const: bool) {
8686
match e.node {
8787
ExprVstore(
8888
@Expr { node: ExprLit(@codemap::Spanned {
89-
node: lit_str(*),
89+
node: lit_str(_),
9090
_}),
9191
_ },
9292
ExprVstoreUniq
@@ -120,7 +120,7 @@ pub fn check_expr(v: &mut CheckCrateVisitor,
120120
"disallowed operator in constant expression");
121121
return;
122122
}
123-
ExprLit(@codemap::Spanned {node: lit_str(*), _}) => { }
123+
ExprLit(@codemap::Spanned {node: lit_str(_), _}) => { }
124124
ExprBinary(*) | ExprUnary(*) => {
125125
if method_map.contains_key(&e.id) {
126126
sess.span_err(e.span, "user-defined operators are not \

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ pub fn eval_const_expr_partial<T: ty::ExprTyProvider>(tcx: &T, e: &Expr)
475475

476476
pub fn lit_to_const(lit: &lit) -> const_val {
477477
match lit.node {
478-
lit_str(s, _) => const_str(s),
478+
lit_str(s) => const_str(s),
479479
lit_char(n) => const_uint(n as u64),
480480
lit_int(n, _) => const_int(n),
481481
lit_uint(n, _) => const_uint(n),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub fn const_lit(cx: &mut CrateContext, e: &ast::Expr, lit: ast::lit)
7171
}
7272
ast::lit_bool(b) => C_bool(b),
7373
ast::lit_nil => C_nil(),
74-
ast::lit_str(s, _) => C_estr_slice(cx, s)
74+
ast::lit_str(s) => C_estr_slice(cx, s)
7575
}
7676
}
7777

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ fn trans_rvalue_dps_unadjusted(bcx: @mut Block, expr: &ast::Expr,
705705
args.iter().enumerate().map(|(i, arg)| (i, *arg)).collect();
706706
return trans_adt(bcx, repr, 0, numbered_fields, None, dest);
707707
}
708-
ast::ExprLit(@codemap::Spanned {node: ast::lit_str(s, _), _}) => {
708+
ast::ExprLit(@codemap::Spanned {node: ast::lit_str(s), _}) => {
709709
return tvec::trans_lit_str(bcx, expr, s, dest);
710710
}
711711
ast::ExprVstore(contents, ast::ExprVstoreSlice) |

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ pub fn trans_slice_vstore(bcx: @mut Block,
205205

206206
// Handle the &"..." case:
207207
match content_expr.node {
208-
ast::ExprLit(@codemap::Spanned {node: ast::lit_str(s, _), span: _}) => {
208+
ast::ExprLit(@codemap::Spanned {node: ast::lit_str(s), span: _}) => {
209209
return trans_lit_str(bcx, content_expr, s, dest);
210210
}
211211
_ => {}
@@ -296,7 +296,7 @@ pub fn trans_uniq_or_managed_vstore(bcx: @mut Block, heap: heap, vstore_expr: &a
296296
heap_exchange => {
297297
match content_expr.node {
298298
ast::ExprLit(@codemap::Spanned {
299-
node: ast::lit_str(s, _), span
299+
node: ast::lit_str(s), span
300300
}) => {
301301
let llptrval = C_cstr(bcx.ccx(), s);
302302
let llptrval = PointerCast(bcx, llptrval, Type::i8p());
@@ -357,7 +357,7 @@ pub fn write_content(bcx: @mut Block,
357357
let _indenter = indenter();
358358

359359
match content_expr.node {
360-
ast::ExprLit(@codemap::Spanned { node: ast::lit_str(s, _), _ }) => {
360+
ast::ExprLit(@codemap::Spanned { node: ast::lit_str(s), _ }) => {
361361
match dest {
362362
Ignore => {
363363
return bcx;
@@ -490,7 +490,7 @@ pub fn elements_required(bcx: @mut Block, content_expr: &ast::Expr) -> uint {
490490
//! Figure out the number of elements we need to store this content
491491
492492
match content_expr.node {
493-
ast::ExprLit(@codemap::Spanned { node: ast::lit_str(s, _), _ }) => {
493+
ast::ExprLit(@codemap::Spanned { node: ast::lit_str(s), _ }) => {
494494
s.len()
495495
},
496496
ast::ExprVec(ref es, _) => es.len(),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3266,7 +3266,7 @@ pub fn expr_kind(tcx: ctxt,
32663266
ast::ExprDoBody(*) |
32673267
ast::ExprBlock(*) |
32683268
ast::ExprRepeat(*) |
3269-
ast::ExprLit(@codemap::Spanned {node: lit_str(*), _}) |
3269+
ast::ExprLit(@codemap::Spanned {node: lit_str(_), _}) |
32703270
ast::ExprVstore(_, ast::ExprVstoreSlice) |
32713271
ast::ExprVstore(_, ast::ExprVstoreMutSlice) |
32723272
ast::ExprVec(*) => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2259,7 +2259,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
22592259
match expr.node {
22602260
ast::ExprVstore(ev, vst) => {
22612261
let typ = match ev.node {
2262-
ast::ExprLit(@codemap::Spanned { node: ast::lit_str(*), _ }) => {
2262+
ast::ExprLit(@codemap::Spanned { node: ast::lit_str(_), _ }) => {
22632263
let tt = ast_expr_vstore_to_vstore(fcx, ev, vst);
22642264
ty::mk_estr(tcx, tt)
22652265
}

branches/try/src/librustdoc/clean.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ impl Clean<ViewItemInner> for ast::view_item_ {
10081008
fn clean(&self) -> ViewItemInner {
10091009
match self {
10101010
&ast::view_item_extern_mod(ref i, ref p, ref mi, ref id) =>
1011-
ExternMod(i.clean(), p.map(|&(ref x, _)| x.to_owned()), mi.clean(), *id),
1011+
ExternMod(i.clean(), p.map(|x| x.to_owned()), mi.clean(), *id),
10121012
&ast::view_item_use(ref vp) => Import(vp.clean())
10131013
}
10141014
}
@@ -1114,7 +1114,7 @@ impl ToSource for syntax::codemap::Span {
11141114

11151115
fn lit_to_str(lit: &ast::lit) -> ~str {
11161116
match lit.node {
1117-
ast::lit_str(st, _) => st.to_owned(),
1117+
ast::lit_str(st) => st.to_owned(),
11181118
ast::lit_char(c) => ~"'" + std::char::from_u32(c).unwrap().to_str() + "'",
11191119
ast::lit_int(i, _t) => i.to_str(),
11201120
ast::lit_uint(u, _t) => u.to_str(),

branches/try/src/librustpkg/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ impl<'self> Visitor<()> for ViewItemVisitor<'self> {
406406
// ignore metadata, I guess
407407
ast::view_item_extern_mod(lib_ident, path_opt, _, _) => {
408408
let lib_name = match path_opt {
409-
Some((p, _)) => p,
409+
Some(p) => p,
410410
None => self.sess.str_of(lib_ident)
411411
};
412412
debug2!("Finding and installing... {}", lib_name);
@@ -513,7 +513,7 @@ pub fn find_and_install_dependencies(context: &BuildContext,
513513

514514
pub fn mk_string_lit(s: @str) -> ast::lit {
515515
Spanned {
516-
node: ast::lit_str(s, ast::CookedStr),
516+
node: ast::lit_str(s),
517517
span: dummy_sp()
518518
}
519519
}

branches/try/src/libstd/num/num.rs

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,7 @@ pub trait ToPrimitive {
404404

405405
/// Converts the value of `self` to an `u64`.
406406
#[inline]
407-
fn to_u64(&self) -> Option<u64> {
408-
self.to_u64().and_then(|x| x.to_u64())
409-
}
407+
fn to_u64(&self) -> Option<u64>;
410408

411409
/// Converts the value of `self` to an `f32`.
412410
#[inline]
@@ -1481,4 +1479,51 @@ mod tests {
14811479
assert_eq!(third.checked_mul(&3), Some(third * 3));
14821480
assert_eq!(third.checked_mul(&4), None);
14831481
}
1482+
1483+
1484+
#[deriving(Eq)]
1485+
struct Value { x: int }
1486+
1487+
impl ToPrimitive for Value {
1488+
fn to_i64(&self) -> Option<i64> { self.x.to_i64() }
1489+
fn to_u64(&self) -> Option<u64> { self.x.to_u64() }
1490+
}
1491+
1492+
impl FromPrimitive for Value {
1493+
fn from_i64(n: i64) -> Option<Value> { Some(Value { x: n as int }) }
1494+
fn from_u64(n: u64) -> Option<Value> { Some(Value { x: n as int }) }
1495+
}
1496+
1497+
#[test]
1498+
fn test_to_primitive() {
1499+
let value = Value { x: 5 };
1500+
assert_eq!(value.to_int(), Some(5));
1501+
assert_eq!(value.to_i8(), Some(5));
1502+
assert_eq!(value.to_i16(), Some(5));
1503+
assert_eq!(value.to_i32(), Some(5));
1504+
assert_eq!(value.to_i64(), Some(5));
1505+
assert_eq!(value.to_uint(), Some(5));
1506+
assert_eq!(value.to_u8(), Some(5));
1507+
assert_eq!(value.to_u16(), Some(5));
1508+
assert_eq!(value.to_u32(), Some(5));
1509+
assert_eq!(value.to_u64(), Some(5));
1510+
assert_eq!(value.to_f32(), Some(5f32));
1511+
assert_eq!(value.to_f64(), Some(5f64));
1512+
}
1513+
1514+
#[test]
1515+
fn test_from_primitive() {
1516+
assert_eq!(from_int(5), Some(Value { x: 5 }));
1517+
assert_eq!(from_i8(5), Some(Value { x: 5 }));
1518+
assert_eq!(from_i16(5), Some(Value { x: 5 }));
1519+
assert_eq!(from_i32(5), Some(Value { x: 5 }));
1520+
assert_eq!(from_i64(5), Some(Value { x: 5 }));
1521+
assert_eq!(from_uint(5), Some(Value { x: 5 }));
1522+
assert_eq!(from_u8(5), Some(Value { x: 5 }));
1523+
assert_eq!(from_u16(5), Some(Value { x: 5 }));
1524+
assert_eq!(from_u32(5), Some(Value { x: 5 }));
1525+
assert_eq!(from_u64(5), Some(Value { x: 5 }));
1526+
assert_eq!(from_f32(5f32), Some(Value { x: 5 }));
1527+
assert_eq!(from_f64(5f64), Some(Value { x: 5 }));
1528+
}
14841529
}

branches/try/src/libsyntax/ast.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -680,17 +680,11 @@ pub enum mac_ {
680680
mac_invoc_tt(Path,~[token_tree],SyntaxContext), // new macro-invocation
681681
}
682682

683-
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
684-
pub enum StrStyle {
685-
CookedStr,
686-
RawStr(uint)
687-
}
688-
689683
pub type lit = Spanned<lit_>;
690684

691685
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
692686
pub enum lit_ {
693-
lit_str(@str, StrStyle),
687+
lit_str(@str),
694688
lit_char(u32),
695689
lit_int(i64, int_ty),
696690
lit_uint(u64, uint_ty),
@@ -868,7 +862,6 @@ pub enum asm_dialect {
868862
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
869863
pub struct inline_asm {
870864
asm: @str,
871-
asm_str_style: StrStyle,
872865
clobbers: @str,
873866
inputs: ~[(@str, @Expr)],
874867
outputs: ~[(@str, @Expr)],
@@ -1034,7 +1027,7 @@ pub enum view_item_ {
10341027
// optional @str: if present, this is a location (containing
10351028
// arbitrary characters) from which to fetch the crate sources
10361029
// For example, extern mod whatever = "github.com/mozilla/rust"
1037-
view_item_extern_mod(Ident, Option<(@str, StrStyle)>, ~[@MetaItem], NodeId),
1030+
view_item_extern_mod(Ident, Option<@str>, ~[@MetaItem], NodeId),
10381031
view_item_use(~[@view_path]),
10391032
}
10401033

branches/try/src/libsyntax/attr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl AttrMetaMethods for MetaItem {
6767
match self.node {
6868
MetaNameValue(_, ref v) => {
6969
match v.node {
70-
ast::lit_str(s, _) => Some(s),
70+
ast::lit_str(s) => Some(s),
7171
_ => None,
7272
}
7373
},
@@ -127,7 +127,7 @@ impl AttributeMethods for Attribute {
127127
/* Constructors */
128128

129129
pub fn mk_name_value_item_str(name: @str, value: @str) -> @MetaItem {
130-
let value_lit = dummy_spanned(ast::lit_str(value, ast::CookedStr));
130+
let value_lit = dummy_spanned(ast::lit_str(value));
131131
mk_name_value_item(name, value_lit)
132132
}
133133

@@ -153,7 +153,7 @@ pub fn mk_attr(item: @MetaItem) -> Attribute {
153153

154154
pub fn mk_sugared_doc_attr(text: @str, lo: BytePos, hi: BytePos) -> Attribute {
155155
let style = doc_comment_style(text);
156-
let lit = spanned(lo, hi, ast::lit_str(text, ast::CookedStr));
156+
let lit = spanned(lo, hi, ast::lit_str(text));
157157
let attr = Attribute_ {
158158
style: style,
159159
value: @spanned(lo, hi, MetaNameValue(@"doc", lit)),

0 commit comments

Comments
 (0)