Skip to content

Commit f683ded

Browse files
committed
---
yaml --- r: 82973 b: refs/heads/auto c: d7dfe0a h: refs/heads/master i: 82971: b4f2dc5 v: v3
1 parent b60bdb6 commit f683ded

File tree

38 files changed

+300
-137
lines changed

38 files changed

+300
-137
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 132099950fc1d157b9af0130cf3f1eb20a263541
16+
refs/heads/auto: d7dfe0ae34eb9a818dcbdb5646e21e721ffb3c33
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/doc/rust.md

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

240240
~~~~~~~~ {.ebnf .gram}
241241
char_lit : '\x27' char_body '\x27' ;
242-
string_lit : '"' string_body * '"' ;
242+
string_lit : '"' string_body * '"' | 'r' raw_string ;
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 '#' ;
249250
250251
common_escape : '\x5c'
251252
| 'n' | 'r' | 't' | '0'
@@ -267,9 +268,10 @@ which must be _escaped_ by a preceding U+005C character (`\`).
267268

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

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

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

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+
291319
#### Number literals
292320

293321
~~~~~~~~ {.ebnf .gram}

branches/auto/doc/tutorial.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,12 @@ 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-
More on strings [later](#vectors-and-strings).
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).
357362

358363
The nil type, written `()`, has a single value, also written `()`.
359364

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ 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'
151152

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

branches/auto/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()));
410+
nospan(ast::lit_str(ast_util::path_name_i(path).to_managed(), ast::CookedStr));
411411

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

branches/auto/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) => {
145+
Some((p, _path_str_style)) => {
146146
let p_path = Path(p);
147147
match p_path.filestem() {
148148
Some(s) =>

branches/auto/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/auto/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/auto/src/librustc/middle/check_match.rs

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use syntax::codemap::{Span, dummy_sp, Spanned};
2828
use syntax::visit;
2929
use syntax::visit::{Visitor,fn_kind};
3030

31-
struct MatchCheckCtxt {
31+
pub struct MatchCheckCtxt {
3232
tcx: ty::ctxt,
3333
method_map: method_map,
3434
moves_map: moves::MovesMap
@@ -64,7 +64,7 @@ pub fn check_crate(tcx: ty::ctxt,
6464
tcx.sess.abort_if_errors();
6565
}
6666

67-
fn check_expr(v: &mut CheckMatchVisitor,
67+
pub fn check_expr(v: &mut CheckMatchVisitor,
6868
cx: @MatchCheckCtxt,
6969
ex: @Expr,
7070
s: ()) {
@@ -115,7 +115,7 @@ fn check_expr(v: &mut CheckMatchVisitor,
115115
}
116116

117117
// Check for unreachable patterns
118-
fn check_arms(cx: &MatchCheckCtxt, arms: &[Arm]) {
118+
pub fn check_arms(cx: &MatchCheckCtxt, arms: &[Arm]) {
119119
let mut seen = ~[];
120120
for arm in arms.iter() {
121121
for pat in arm.pats.iter() {
@@ -154,14 +154,14 @@ fn check_arms(cx: &MatchCheckCtxt, arms: &[Arm]) {
154154
}
155155
}
156156

157-
fn raw_pat(p: @Pat) -> @Pat {
157+
pub fn raw_pat(p: @Pat) -> @Pat {
158158
match p.node {
159159
PatIdent(_, _, Some(s)) => { raw_pat(s) }
160160
_ => { p }
161161
}
162162
}
163163

164-
fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, pats: ~[@Pat]) {
164+
pub fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, pats: ~[@Pat]) {
165165
assert!((!pats.is_empty()));
166166
let ext = match is_useful(cx, &pats.map(|p| ~[*p]), [wild()]) {
167167
not_useful => {
@@ -209,12 +209,12 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, pats: ~[@Pat]) {
209209
cx.tcx.sess.span_err(sp, msg);
210210
}
211211

212-
type matrix = ~[~[@Pat]];
212+
pub type matrix = ~[~[@Pat]];
213213

214-
enum useful { useful(ty::t, ctor), useful_, not_useful }
214+
pub enum useful { useful(ty::t, ctor), useful_, not_useful }
215215

216216
#[deriving(Eq)]
217-
enum ctor {
217+
pub enum ctor {
218218
single,
219219
variant(DefId),
220220
val(const_val),
@@ -235,7 +235,7 @@ enum ctor {
235235

236236
// Note: is_useful doesn't work on empty types, as the paper notes.
237237
// So it assumes that v is non-empty.
238-
fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@Pat]) -> useful {
238+
pub fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@Pat]) -> useful {
239239
if m.len() == 0u { return useful_; }
240240
if m[0].len() == 0u { return not_useful; }
241241
let real_pat = match m.iter().find(|r| r[0].id != 0) {
@@ -314,7 +314,7 @@ fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@Pat]) -> useful {
314314
}
315315
}
316316

317-
fn is_useful_specialized(cx: &MatchCheckCtxt,
317+
pub fn is_useful_specialized(cx: &MatchCheckCtxt,
318318
m: &matrix,
319319
v: &[@Pat],
320320
ctor: ctor,
@@ -330,7 +330,7 @@ fn is_useful_specialized(cx: &MatchCheckCtxt,
330330
}
331331
}
332332

333-
fn pat_ctor_id(cx: &MatchCheckCtxt, p: @Pat) -> Option<ctor> {
333+
pub fn pat_ctor_id(cx: &MatchCheckCtxt, p: @Pat) -> Option<ctor> {
334334
let pat = raw_pat(p);
335335
match pat.node {
336336
PatWild => { None }
@@ -366,7 +366,7 @@ fn pat_ctor_id(cx: &MatchCheckCtxt, p: @Pat) -> Option<ctor> {
366366
}
367367
}
368368

369-
fn is_wild(cx: &MatchCheckCtxt, p: @Pat) -> bool {
369+
pub fn is_wild(cx: &MatchCheckCtxt, p: @Pat) -> bool {
370370
let pat = raw_pat(p);
371371
match pat.node {
372372
PatWild => { true }
@@ -380,7 +380,7 @@ fn is_wild(cx: &MatchCheckCtxt, p: @Pat) -> bool {
380380
}
381381
}
382382

383-
fn missing_ctor(cx: &MatchCheckCtxt,
383+
pub fn missing_ctor(cx: &MatchCheckCtxt,
384384
m: &matrix,
385385
left_ty: ty::t)
386386
-> Option<ctor> {
@@ -505,7 +505,7 @@ fn missing_ctor(cx: &MatchCheckCtxt,
505505
}
506506
}
507507

508-
fn ctor_arity(cx: &MatchCheckCtxt, ctor: &ctor, ty: ty::t) -> uint {
508+
pub fn ctor_arity(cx: &MatchCheckCtxt, ctor: &ctor, ty: ty::t) -> uint {
509509
match ty::get(ty).sty {
510510
ty::ty_tup(ref fs) => fs.len(),
511511
ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_rptr(*) => 1u,
@@ -528,11 +528,11 @@ fn ctor_arity(cx: &MatchCheckCtxt, ctor: &ctor, ty: ty::t) -> uint {
528528
}
529529
}
530530

531-
fn wild() -> @Pat {
531+
pub fn wild() -> @Pat {
532532
@Pat {id: 0, node: PatWild, span: dummy_sp()}
533533
}
534534

535-
fn specialize(cx: &MatchCheckCtxt,
535+
pub fn specialize(cx: &MatchCheckCtxt,
536536
r: &[@Pat],
537537
ctor_id: &ctor,
538538
arity: uint,
@@ -662,14 +662,15 @@ fn specialize(cx: &MatchCheckCtxt,
662662
_ => None
663663
}
664664
}
665-
PatStruct(_, ref pattern_fields, _) => {
665+
PatStruct(_, ref flds, _) => {
666666
// Is this a struct or an enum variant?
667667
match cx.tcx.def_map.get_copy(&pat_id) {
668668
DefVariant(_, variant_id, _) => {
669669
if variant(variant_id) == *ctor_id {
670-
let struct_fields = ty::lookup_struct_fields(cx.tcx, variant_id);
671-
let args = struct_fields.map(|sf| {
672-
match pattern_fields.iter().find(|f| f.ident.name == sf.name) {
670+
// FIXME #4731: Is this right? --pcw
671+
let args = flds.map(|ty_field| {
672+
match flds.iter().find(|f|
673+
f.ident == ty_field.ident) {
673674
Some(f) => f.pat,
674675
_ => wild()
675676
}
@@ -699,7 +700,7 @@ fn specialize(cx: &MatchCheckCtxt,
699700
}
700701
}
701702
let args = class_fields.iter().map(|class_field| {
702-
match pattern_fields.iter().find(|f|
703+
match flds.iter().find(|f|
703704
f.ident.name == class_field.name) {
704705
Some(f) => f.pat,
705706
_ => wild()
@@ -797,12 +798,12 @@ fn specialize(cx: &MatchCheckCtxt,
797798
}
798799
}
799800

800-
fn default(cx: &MatchCheckCtxt, r: &[@Pat]) -> Option<~[@Pat]> {
801+
pub fn default(cx: &MatchCheckCtxt, r: &[@Pat]) -> Option<~[@Pat]> {
801802
if is_wild(cx, r[0]) { Some(r.tail().to_owned()) }
802803
else { None }
803804
}
804805

805-
fn check_local(v: &mut CheckMatchVisitor,
806+
pub fn check_local(v: &mut CheckMatchVisitor,
806807
cx: &MatchCheckCtxt,
807808
loc: @Local,
808809
s: ()) {
@@ -816,7 +817,7 @@ fn check_local(v: &mut CheckMatchVisitor,
816817
check_legality_of_move_bindings(cx, false, [ loc.pat ]);
817818
}
818819

819-
fn check_fn(v: &mut CheckMatchVisitor,
820+
pub fn check_fn(v: &mut CheckMatchVisitor,
820821
cx: &MatchCheckCtxt,
821822
kind: &visit::fn_kind,
822823
decl: &fn_decl,
@@ -833,7 +834,7 @@ fn check_fn(v: &mut CheckMatchVisitor,
833834
}
834835
}
835836

836-
fn is_refutable(cx: &MatchCheckCtxt, pat: &Pat) -> bool {
837+
pub fn is_refutable(cx: &MatchCheckCtxt, pat: &Pat) -> bool {
837838
match cx.tcx.def_map.find(&pat.id) {
838839
Some(&DefVariant(enum_id, _, _)) => {
839840
if ty::enum_variants(cx.tcx, enum_id).len() != 1u {
@@ -871,7 +872,7 @@ fn is_refutable(cx: &MatchCheckCtxt, pat: &Pat) -> bool {
871872

872873
// Legality of move bindings checking
873874

874-
fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
875+
pub fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
875876
has_guard: bool,
876877
pats: &[@Pat]) {
877878
let tcx = cx.tcx;

branches/auto/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/auto/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/auto/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/auto/src/librustc/middle/trans/glue.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ pub fn trans_struct_drop_flag(bcx: @mut Block, t: ty::t, v0: ValueRef, dtor_did:
423423
bcx = drop_ty(bcx, llfld_a, fld.mt.ty);
424424
}
425425

426+
Store(bcx, C_u8(0), drop_flag);
426427
bcx
427428
}
428429
}
@@ -594,6 +595,23 @@ pub fn make_take_glue(bcx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
594595
bcx
595596
}
596597
ty::ty_opaque_closure_ptr(_) => bcx,
598+
ty::ty_struct(did, _) => {
599+
let tcx = bcx.tcx();
600+
let bcx = iter_structural_ty(bcx, v, t, take_ty);
601+
602+
match ty::ty_dtor(tcx, did) {
603+
ty::TraitDtor(_, false) => {
604+
// Zero out the struct
605+
unsafe {
606+
let ty = Type::from_ref(llvm::LLVMTypeOf(v));
607+
memzero(&B(bcx), v, ty);
608+
}
609+
610+
}
611+
_ => { }
612+
}
613+
bcx
614+
}
597615
_ if ty::type_is_structural(t) => {
598616
iter_structural_ty(bcx, v, t, take_ty)
599617
}

0 commit comments

Comments
 (0)