Skip to content

Commit 5897937

Browse files
committed
---
yaml --- r: 155033 b: refs/heads/try2 c: 9f8ec42 h: refs/heads/master i: 155031: 07c77db v: v3
1 parent 4d9c605 commit 5897937

Some content is hidden

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

55 files changed

+1782
-1570
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: 9c68679f2ebd5b165694e9346e4ad96a3e32aceb
8+
refs/heads/try2: 9f8ec427e57a7da4d935fb19148586fae0d7f3c5
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/etc/get-snapshot.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ def unpack_snapshot(triple, dl_path):
5252
if len(sys.argv) == 3:
5353
dl_path = sys.argv[2]
5454
else:
55-
snap = determine_curr_snapshot(triple)
55+
# There are no 64-bit Windows snapshots yet, so we'll use 32-bit ones instead, for now
56+
snap_triple = triple if triple != "x86_64-w64-mingw32" else "i686-w64-mingw32"
57+
snap = determine_curr_snapshot(snap_triple)
5658
dl = os.path.join(download_dir_base, snap)
5759
url = download_url_base + "/" + snap
5860
print("determined most recent snapshot: " + snap)

branches/try2/src/libcore/fmt/mod.rs

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ impl<'a> Arguments<'a> {
113113
/// Arguments structure. The compiler inserts an `unsafe` block to call this,
114114
/// which is valid because the compiler performs all necessary validation to
115115
/// ensure that the resulting call to format/write would be safe.
116+
#[cfg(not(stage0))]
116117
#[doc(hidden)] #[inline]
117118
pub unsafe fn new<'a>(pieces: &'static [&'static str],
118119
args: &'a [Argument<'a>]) -> Arguments<'a> {
@@ -126,6 +127,7 @@ impl<'a> Arguments<'a> {
126127
/// This function is used to specify nonstandard formatting parameters.
127128
/// The `pieces` array must be at least as long as `fmt` to construct
128129
/// a valid Arguments structure.
130+
#[cfg(not(stage0))]
129131
#[doc(hidden)] #[inline]
130132
pub unsafe fn with_placeholders<'a>(pieces: &'static [&'static str],
131133
fmt: &'static [rt::Argument<'static>],
@@ -136,6 +138,13 @@ impl<'a> Arguments<'a> {
136138
args: args
137139
}
138140
}
141+
142+
#[cfg(stage0)]
143+
#[doc(hidden)] #[inline]
144+
pub unsafe fn new<'a>(fmt: &'static [rt::Piece<'static>],
145+
args: &'a [Argument<'a>]) -> Arguments<'a> {
146+
Arguments{ fmt: mem::transmute(fmt), args: args }
147+
}
139148
}
140149

141150
/// This structure represents a safely precompiled version of a format string
@@ -147,6 +156,7 @@ impl<'a> Arguments<'a> {
147156
/// and pass it to a function or closure, passed as the first argument. The
148157
/// macro validates the format string at compile-time so usage of the `write`
149158
/// and `format` functions can be safely performed.
159+
#[cfg(not(stage0))]
150160
pub struct Arguments<'a> {
151161
// Format string pieces to print.
152162
pieces: &'a [&'a str],
@@ -159,6 +169,12 @@ pub struct Arguments<'a> {
159169
args: &'a [Argument<'a>],
160170
}
161171

172+
#[cfg(stage0)] #[doc(hidden)]
173+
pub struct Arguments<'a> {
174+
fmt: &'a [rt::Piece<'a>],
175+
args: &'a [Argument<'a>],
176+
}
177+
162178
impl<'a> Show for Arguments<'a> {
163179
fn fmt(&self, fmt: &mut Formatter) -> Result {
164180
write(fmt.buf, self)
@@ -280,6 +296,7 @@ uniform_fn_call_workaround! {
280296
secret_upper_exp, UpperExp;
281297
}
282298

299+
#[cfg(not(stage0))]
283300
static DEFAULT_ARGUMENT: rt::Argument<'static> = rt::Argument {
284301
position: rt::ArgumentNext,
285302
format: rt::FormatSpec {
@@ -299,6 +316,7 @@ static DEFAULT_ARGUMENT: rt::Argument<'static> = rt::Argument {
299316
///
300317
/// * output - the buffer to write output to
301318
/// * args - the precompiled arguments generated by `format_args!`
319+
#[cfg(not(stage0))]
302320
pub fn write(output: &mut FormatWriter, args: &Arguments) -> Result {
303321
let mut formatter = Formatter {
304322
flags: 0,
@@ -342,11 +360,30 @@ pub fn write(output: &mut FormatWriter, args: &Arguments) -> Result {
342360
Ok(())
343361
}
344362

363+
#[cfg(stage0)] #[doc(hidden)]
364+
pub fn write(output: &mut FormatWriter, args: &Arguments) -> Result {
365+
let mut formatter = Formatter {
366+
flags: 0,
367+
width: None,
368+
precision: None,
369+
buf: output,
370+
align: rt::AlignUnknown,
371+
fill: ' ',
372+
args: args.args,
373+
curarg: args.args.iter(),
374+
};
375+
for piece in args.fmt.iter() {
376+
try!(formatter.run(piece));
377+
}
378+
Ok(())
379+
}
380+
345381
impl<'a> Formatter<'a> {
346382

347383
// First up is the collection of functions used to execute a format string
348384
// at runtime. This consumes all of the compile-time statics generated by
349385
// the format! syntax extension.
386+
#[cfg(not(stage0))]
350387
fn run(&mut self, arg: &rt::Argument) -> Result {
351388
// Fill in the format parameters into the formatter
352389
self.fill = arg.format.fill;
@@ -365,6 +402,30 @@ impl<'a> Formatter<'a> {
365402
(value.formatter)(value.value, self)
366403
}
367404

405+
#[cfg(stage0)] #[doc(hidden)]
406+
fn run(&mut self, piece: &rt::Piece) -> Result {
407+
match *piece {
408+
rt::String(s) => self.buf.write(s.as_bytes()),
409+
rt::Argument(ref arg) => {
410+
// Fill in the format parameters into the formatter
411+
self.fill = arg.format.fill;
412+
self.align = arg.format.align;
413+
self.flags = arg.format.flags;
414+
self.width = self.getcount(&arg.format.width);
415+
self.precision = self.getcount(&arg.format.precision);
416+
417+
// Extract the correct argument
418+
let value = match arg.position {
419+
rt::ArgumentNext => { *self.curarg.next().unwrap() }
420+
rt::ArgumentIs(i) => self.args[i],
421+
};
422+
423+
// Then actually do some printing
424+
(value.formatter)(value.value, self)
425+
}
426+
}
427+
}
428+
368429
fn getcount(&mut self, cnt: &rt::Count) -> Option<uint> {
369430
match *cnt {
370431
rt::CountIs(n) => { Some(n) }
@@ -415,7 +476,7 @@ impl<'a> Formatter<'a> {
415476

416477
let mut prefixed = false;
417478
if self.flags & (1 << (FlagAlternate as uint)) != 0 {
418-
prefixed = true; width += prefix.char_len();
479+
prefixed = true; width += prefix.len();
419480
}
420481

421482
// Writes the sign if it exists, and then the prefix if it was requested
@@ -501,7 +562,7 @@ impl<'a> Formatter<'a> {
501562
// If we're under both the maximum and the minimum width, then fill
502563
// up the minimum width with the specified string + some alignment.
503564
Some(width) => {
504-
self.with_padding(width - s.char_len(), rt::AlignLeft, |me| {
565+
self.with_padding(width - s.len(), rt::AlignLeft, |me| {
505566
me.buf.write(s.as_bytes())
506567
})
507568
}

branches/try2/src/librustc/front/feature_gate.rs

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,15 @@ impl<'a> Context<'a> {
143143
}
144144
}
145145

146-
impl<'a, 'v> Visitor<'v> for Context<'a> {
147-
fn visit_ident(&mut self, sp: Span, id: ast::Ident) {
146+
impl<'a> Visitor<()> for Context<'a> {
147+
fn visit_ident(&mut self, sp: Span, id: ast::Ident, _: ()) {
148148
if !token::get_ident(id).get().is_ascii() {
149149
self.gate_feature("non_ascii_idents", sp,
150150
"non-ascii idents are not fully supported.");
151151
}
152152
}
153153

154-
fn visit_view_item(&mut self, i: &ast::ViewItem) {
154+
fn visit_view_item(&mut self, i: &ast::ViewItem, _: ()) {
155155
match i.node {
156156
ast::ViewItemUse(ref path) => {
157157
match path.node {
@@ -173,10 +173,10 @@ impl<'a, 'v> Visitor<'v> for Context<'a> {
173173
}
174174
}
175175
}
176-
visit::walk_view_item(self, i)
176+
visit::walk_view_item(self, i, ())
177177
}
178178

179-
fn visit_item(&mut self, i: &ast::Item) {
179+
fn visit_item(&mut self, i: &ast::Item, _:()) {
180180
for attr in i.attrs.iter() {
181181
if attr.name().equiv(&("thread_local")) {
182182
self.gate_feature("thread_local", i.span,
@@ -252,10 +252,10 @@ impl<'a, 'v> Visitor<'v> for Context<'a> {
252252
_ => {}
253253
}
254254

255-
visit::walk_item(self, i);
255+
visit::walk_item(self, i, ());
256256
}
257257

258-
fn visit_mac(&mut self, macro: &ast::Mac) {
258+
fn visit_mac(&mut self, macro: &ast::Mac, _: ()) {
259259
let ast::MacInvocTT(ref path, _, _) = macro.node;
260260
let id = path.segments.last().unwrap().identifier;
261261
let quotes = ["quote_tokens", "quote_expr", "quote_ty",
@@ -299,16 +299,16 @@ impl<'a, 'v> Visitor<'v> for Context<'a> {
299299
}
300300
}
301301

302-
fn visit_foreign_item(&mut self, i: &ast::ForeignItem) {
302+
fn visit_foreign_item(&mut self, i: &ast::ForeignItem, _: ()) {
303303
if attr::contains_name(i.attrs.as_slice(), "linkage") {
304304
self.gate_feature("linkage", i.span,
305305
"the `linkage` attribute is experimental \
306306
and not portable across platforms")
307307
}
308-
visit::walk_foreign_item(self, i)
308+
visit::walk_foreign_item(self, i, ())
309309
}
310310

311-
fn visit_ty(&mut self, t: &ast::Ty) {
311+
fn visit_ty(&mut self, t: &ast::Ty, _: ()) {
312312
match t.node {
313313
ast::TyClosure(closure) if closure.onceness == ast::Once => {
314314
self.gate_feature("once_fns", t.span,
@@ -325,10 +325,10 @@ impl<'a, 'v> Visitor<'v> for Context<'a> {
325325
_ => {}
326326
}
327327

328-
visit::walk_ty(self, t);
328+
visit::walk_ty(self, t, ());
329329
}
330330

331-
fn visit_expr(&mut self, e: &ast::Expr) {
331+
fn visit_expr(&mut self, e: &ast::Expr, _: ()) {
332332
match e.node {
333333
ast::ExprUnary(ast::UnBox, _) => {
334334
self.gate_box(e.span);
@@ -346,10 +346,10 @@ impl<'a, 'v> Visitor<'v> for Context<'a> {
346346
}
347347
_ => {}
348348
}
349-
visit::walk_expr(self, e);
349+
visit::walk_expr(self, e, ());
350350
}
351351

352-
fn visit_generics(&mut self, generics: &ast::Generics) {
352+
fn visit_generics(&mut self, generics: &ast::Generics, _: ()) {
353353
for type_parameter in generics.ty_params.iter() {
354354
match type_parameter.default {
355355
Some(ty) => {
@@ -360,18 +360,18 @@ impl<'a, 'v> Visitor<'v> for Context<'a> {
360360
None => {}
361361
}
362362
}
363-
visit::walk_generics(self, generics);
363+
visit::walk_generics(self, generics, ());
364364
}
365365

366-
fn visit_attribute(&mut self, attr: &ast::Attribute) {
366+
fn visit_attribute(&mut self, attr: &ast::Attribute, _: ()) {
367367
if attr::contains_name([*attr], "lang") {
368368
self.gate_feature("lang_items",
369369
attr.span,
370370
"language items are subject to change");
371371
}
372372
}
373373

374-
fn visit_pat(&mut self, pattern: &ast::Pat) {
374+
fn visit_pat(&mut self, pattern: &ast::Pat, (): ()) {
375375
match pattern.node {
376376
ast::PatVec(_, Some(_), ref last) if !last.is_empty() => {
377377
self.gate_feature("advanced_slice_patterns",
@@ -382,24 +382,25 @@ impl<'a, 'v> Visitor<'v> for Context<'a> {
382382
}
383383
_ => {}
384384
}
385-
visit::walk_pat(self, pattern)
385+
visit::walk_pat(self, pattern, ())
386386
}
387387

388388
fn visit_fn(&mut self,
389-
fn_kind: visit::FnKind<'v>,
390-
fn_decl: &'v ast::FnDecl,
391-
block: &'v ast::Block,
389+
fn_kind: &visit::FnKind,
390+
fn_decl: &ast::FnDecl,
391+
block: &ast::Block,
392392
span: Span,
393-
_: NodeId) {
394-
match fn_kind {
395-
visit::FkItemFn(_, _, _, abi) if abi == RustIntrinsic => {
393+
_: NodeId,
394+
(): ()) {
395+
match *fn_kind {
396+
visit::FkItemFn(_, _, _, ref abi) if *abi == RustIntrinsic => {
396397
self.gate_feature("intrinsics",
397398
span,
398399
"intrinsics are subject to change")
399400
}
400401
_ => {}
401402
}
402-
visit::walk_fn(self, fn_kind, fn_decl, block, span);
403+
visit::walk_fn(self, fn_kind, fn_decl, block, span, ());
403404
}
404405
}
405406

@@ -452,7 +453,7 @@ pub fn check_crate(sess: &Session, krate: &ast::Crate) {
452453
}
453454
}
454455

455-
visit::walk_crate(&mut cx, krate);
456+
visit::walk_crate(&mut cx, krate, ());
456457

457458
sess.abort_if_errors();
458459

branches/try2/src/librustc/front/show_span.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ struct ShowSpanVisitor<'a> {
2323
sess: &'a Session
2424
}
2525

26-
impl<'a, 'v> Visitor<'v> for ShowSpanVisitor<'a> {
27-
fn visit_expr(&mut self, e: &ast::Expr) {
26+
impl<'a> Visitor<()> for ShowSpanVisitor<'a> {
27+
fn visit_expr(&mut self, e: &ast::Expr, _: ()) {
2828
self.sess.span_note(e.span, "expression");
29-
visit::walk_expr(self, e);
29+
visit::walk_expr(self, e, ());
3030
}
3131

32-
fn visit_mac(&mut self, macro: &ast::Mac) {
33-
visit::walk_mac(self, macro);
32+
fn visit_mac(&mut self, macro: &ast::Mac, e: ()) {
33+
visit::walk_mac(self, macro, e);
3434
}
3535
}
3636

3737
pub fn run(sess: &Session, krate: &ast::Crate) {
3838
let mut v = ShowSpanVisitor { sess: sess };
39-
visit::walk_crate(&mut v, krate);
39+
visit::walk_crate(&mut v, krate, ());
4040
}

0 commit comments

Comments
 (0)