Skip to content

Commit c6860dc

Browse files
committed
---
yaml --- r: 80700 b: refs/heads/try c: 68a9137 h: refs/heads/master v: v3
1 parent ffc5e5b commit c6860dc

File tree

8 files changed

+106
-245
lines changed

8 files changed

+106
-245
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: 4c6bf4872012c010f84dc7fa2cdfe87522533f89
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cbd1eefbd350797b783df119fed7956d7e1c74ad
5-
refs/heads/try: 9a5f95a82c2836fa6c57ede49d27c060f2377fa1
5+
refs/heads/try: 68a9137eacb7ea1e61f80279eff03bf758e16e71
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libextra/fileinput.rs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -417,20 +417,23 @@ mod test {
417417

418418
use super::{FileInput, make_path_option_vec, input_vec, input_vec_state};
419419

420-
use std::io;
420+
use std::rt::io;
421+
use std::rt::io::Writer;
422+
use std::rt::io::file;
421423
use std::uint;
422424
use std::vec;
423425

424426
fn make_file(path : &Path, contents: &[~str]) {
425-
let file = io::file_writer(path, [io::Create, io::Truncate]).unwrap();
427+
let mut file = file::open(path, io::CreateOrTruncate, io::Write).unwrap();
426428

427429
for str in contents.iter() {
428-
file.write_str(*str);
429-
file.write_char('\n');
430+
file.write(str.as_bytes());
431+
file.write(['\n' as u8]);
430432
}
431433
}
432434

433435
#[test]
436+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
434437
fn test_make_path_option_vec() {
435438
let strs = [~"some/path",
436439
~"some/other/path"];
@@ -445,6 +448,7 @@ mod test {
445448
}
446449
447450
#[test]
451+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
448452
fn test_fileinput_read_byte() {
449453
let filenames = make_path_option_vec(vec::from_fn(
450454
3,
@@ -475,6 +479,7 @@ mod test {
475479
}
476480
477481
#[test]
482+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
478483
fn test_fileinput_read() {
479484
let filenames = make_path_option_vec(vec::from_fn(
480485
3,
@@ -495,6 +500,7 @@ mod test {
495500
}
496501

497502
#[test]
503+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
498504
fn test_input_vec() {
499505
let mut all_lines = ~[];
500506
let filenames = make_path_option_vec(vec::from_fn(
@@ -518,6 +524,7 @@ mod test {
518524
}
519525

520526
#[test]
527+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
521528
fn test_input_vec_state() {
522529
let filenames = make_path_option_vec(vec::from_fn(
523530
3,
@@ -540,6 +547,7 @@ mod test {
540547
}
541548

542549
#[test]
550+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
543551
fn test_empty_files() {
544552
let filenames = make_path_option_vec(vec::from_fn(
545553
3,
@@ -564,18 +572,21 @@ mod test {
564572
}
565573
566574
#[test]
575+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
567576
fn test_no_trailing_newline() {
568577
let f1 =
569578
Some(Path("tmp/lib-fileinput-test-no-trailing-newline-1.tmp"));
570579
let f2 =
571580
Some(Path("tmp/lib-fileinput-test-no-trailing-newline-2.tmp"));
572581
573-
let wr = io::file_writer(f1.get_ref(),
574-
[io::Create, io::Truncate]).unwrap();
575-
wr.write_str("1\n2");
576-
let wr = io::file_writer(f2.get_ref(),
577-
[io::Create, io::Truncate]).unwrap();
578-
wr.write_str("3\n4");
582+
{
583+
let mut wr = file::open(f1.get_ref(), io::CreateOrTruncate,
584+
io::Write).unwrap();
585+
wr.write("1\n2".as_bytes());
586+
let mut wr = file::open(f2.get_ref(), io::CreateOrTruncate,
587+
io::Write).unwrap();
588+
wr.write("3\n4".as_bytes());
589+
}
579590
580591
let mut lines = ~[];
581592
do input_vec(~[f1, f2]) |line| {
@@ -587,6 +598,7 @@ mod test {
587598
588599
589600
#[test]
601+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
590602
fn test_next_file() {
591603
let filenames = make_path_option_vec(vec::from_fn(
592604
3,
@@ -618,6 +630,7 @@ mod test {
618630
619631
#[test]
620632
#[should_fail]
633+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
621634
fn test_input_vec_missing_file() {
622635
do input_vec(make_path_option_vec([~"this/file/doesnt/exist"], true)) |line| {
623636
println(line);

branches/try/src/libstd/fmt/mod.rs

Lines changed: 16 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Some examples of the `format!` extension are:
3636
format!("Hello") // => ~"Hello"
3737
format!("Hello, {:s}!", "world") // => ~"Hello, world!"
3838
format!("The number is {:d}", 1) // => ~"The number is 1"
39-
format!("{:?}", ~[3, 4]) // => ~"~[3, 4]"
39+
format!("{}", ~[3, 4]) // => ~"~[3, 4]"
4040
format!("{value}", value=4) // => ~"4"
4141
format!("{} {}", 1, 2) // => ~"1 2"
4242
~~~
@@ -363,32 +363,6 @@ pub struct Argument<'self> {
363363
priv value: &'self util::Void,
364364
}
365365

366-
impl<'self> Arguments<'self> {
367-
/// When using the format_args!() macro, this function is used to generate the
368-
/// Arguments structure. The compiler inserts an `unsafe` block to call this,
369-
/// which is valid because the compiler performs all necessary validation to
370-
/// ensure that the resulting call to format/write would be safe.
371-
#[doc(hidden)] #[inline]
372-
pub unsafe fn new<'a>(fmt: &'static [rt::Piece<'static>],
373-
args: &'a [Argument<'a>]) -> Arguments<'a> {
374-
Arguments{ fmt: cast::transmute(fmt), args: args }
375-
}
376-
}
377-
378-
/// This structure represents a safely precompiled version of a format string
379-
/// and its arguments. This cannot be generated at runtime because it cannot
380-
/// safely be done so, so no constructors are given and the fields are private
381-
/// to prevent modification.
382-
///
383-
/// The `format_args!` macro will safely create an instance of this structure
384-
/// and pass it to a user-supplied function. The macro validates the format
385-
/// string at compile-time so usage of the `write` and `format` functions can
386-
/// be safely performed.
387-
pub struct Arguments<'self> {
388-
priv fmt: &'self [rt::Piece<'self>],
389-
priv args: &'self [Argument<'self>],
390-
}
391-
392366
/// When a format is not otherwise specified, types are formatted by ascribing
393367
/// to this trait. There is not an explicit way of selecting this trait to be
394368
/// used for formatting, it is only if no other format is specified.
@@ -436,26 +410,6 @@ pub trait Float { fn fmt(&Self, &mut Formatter); }
436410
/// and a list of arguments. The arguments will be formatted according to the
437411
/// specified format string into the output stream provided.
438412
///
439-
/// # Arguments
440-
///
441-
/// * output - the buffer to write output to
442-
/// * args - the precompiled arguments generated by `format_args!`
443-
///
444-
/// # Example
445-
///
446-
/// ~~~{.rust}
447-
/// use std::fmt;
448-
/// let w: &mut io::Writer = ...;
449-
/// format_args!(|args| { fmt::write(w, args) }, "Hello, {}!", "world");
450-
/// ~~~
451-
pub fn write(output: &mut io::Writer, args: &Arguments) {
452-
unsafe { write_unsafe(output, args.fmt, args.args) }
453-
}
454-
455-
/// The `write_unsafe` function takes an output stream, a precompiled format
456-
/// string, and a list of arguments. The arguments will be formatted according
457-
/// to the specified format string into the output stream provided.
458-
///
459413
/// See the documentation for `format` for why this function is unsafe and care
460414
/// should be taken if calling it manually.
461415
///
@@ -472,9 +426,8 @@ pub fn write(output: &mut io::Writer, args: &Arguments) {
472426
///
473427
/// Note that this function assumes that there are enough arguments for the
474428
/// format string.
475-
pub unsafe fn write_unsafe(output: &mut io::Writer,
476-
fmt: &[rt::Piece],
477-
args: &[Argument]) {
429+
pub unsafe fn write(output: &mut io::Writer,
430+
fmt: &[rt::Piece], args: &[Argument]) {
478431
let mut formatter = Formatter {
479432
flags: 0,
480433
width: None,
@@ -493,25 +446,6 @@ pub unsafe fn write_unsafe(output: &mut io::Writer,
493446
/// The format function takes a precompiled format string and a list of
494447
/// arguments, to return the resulting formatted string.
495448
///
496-
/// # Arguments
497-
///
498-
/// * args - a structure of arguments generated via the `format_args!` macro.
499-
/// Because this structure can only be safely generated at
500-
/// compile-time, this function is safe.
501-
///
502-
/// # Example
503-
///
504-
/// ~~~{.rust}
505-
/// use std::fmt;
506-
/// let s = format_args!(fmt::format, "Hello, {}!", "world");
507-
/// assert_eq!(s, "Hello, world!");
508-
/// ~~~
509-
pub fn format(args: &Arguments) -> ~str {
510-
unsafe { format_unsafe(args.fmt, args.args) }
511-
}
512-
513-
/// The unsafe version of the formatting function.
514-
///
515449
/// This is currently an unsafe function because the types of all arguments
516450
/// aren't verified by immediate callers of this function. This currently does
517451
/// not validate that the correct types of arguments are specified for each
@@ -531,9 +465,9 @@ pub fn format(args: &Arguments) -> ~str {
531465
///
532466
/// Note that this function assumes that there are enough arguments for the
533467
/// format string.
534-
pub unsafe fn format_unsafe(fmt: &[rt::Piece], args: &[Argument]) -> ~str {
468+
pub unsafe fn format(fmt: &[rt::Piece], args: &[Argument]) -> ~str {
535469
let mut output = MemWriter::new();
536-
write_unsafe(&mut output as &mut io::Writer, fmt, args);
470+
write(&mut output as &mut io::Writer, fmt, args);
537471
return str::from_utf8_owned(output.inner());
538472
}
539473

@@ -806,7 +740,7 @@ impl<'self> Formatter<'self> {
806740

807741
/// This is a function which calls are emitted to by the compiler itself to
808742
/// create the Argument structures that are passed into the `format` function.
809-
#[doc(hidden)] #[inline]
743+
#[doc(hidden)]
810744
pub fn argument<'a, T>(f: extern "Rust" fn(&T, &mut Formatter),
811745
t: &'a T) -> Argument<'a> {
812746
unsafe {
@@ -819,14 +753,14 @@ pub fn argument<'a, T>(f: extern "Rust" fn(&T, &mut Formatter),
819753

820754
/// When the compiler determines that the type of an argument *must* be a string
821755
/// (such as for select), then it invokes this method.
822-
#[doc(hidden)] #[inline]
756+
#[doc(hidden)]
823757
pub fn argumentstr<'a>(s: &'a &str) -> Argument<'a> {
824758
argument(String::fmt, s)
825759
}
826760

827761
/// When the compiler determines that the type of an argument *must* be a uint
828762
/// (such as for plural), then it invokes this method.
829-
#[doc(hidden)] #[inline]
763+
#[doc(hidden)]
830764
pub fn argumentuint<'a>(s: &'a uint) -> Argument<'a> {
831765
argument(Unsigned::fmt, s)
832766
}
@@ -965,8 +899,14 @@ impl<T> Pointer for *T {
965899
}
966900
}
967901
}
902+
968903
impl<T> Pointer for *mut T {
969-
fn fmt(t: &*mut T, f: &mut Formatter) { Pointer::fmt(&(*t as *T), f) }
904+
fn fmt(t: &*mut T, f: &mut Formatter) {
905+
f.flags |= 1 << (parse::FlagAlternate as uint);
906+
do ::uint::to_str_bytes(*t as uint, 16) |buf| {
907+
f.pad_integral(buf, "0x", true);
908+
}
909+
}
970910
}
971911

972912
// Implementation of Default for various core types
@@ -1000,6 +940,7 @@ delegate!(f64 to Float)
1000940
impl<T> Default for *T {
1001941
fn fmt(me: &*T, f: &mut Formatter) { Pointer::fmt(me, f) }
1002942
}
943+
1003944
impl<T> Default for *mut T {
1004945
fn fmt(me: &*mut T, f: &mut Formatter) { Pointer::fmt(me, f) }
1005946
}

branches/try/src/libsyntax/ext/base.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,6 @@ pub fn syntax_expander_table() -> SyntaxEnv {
161161
builtin_normal_tt_no_ctxt(ext::ifmt::expand_write));
162162
syntax_expanders.insert(intern(&"writeln"),
163163
builtin_normal_tt_no_ctxt(ext::ifmt::expand_writeln));
164-
syntax_expanders.insert(intern(&"format_args"),
165-
builtin_normal_tt_no_ctxt(ext::ifmt::expand_format_args));
166164
syntax_expanders.insert(
167165
intern(&"auto_encode"),
168166
@SE(ItemDecorator(ext::auto_encode::expand_auto_encode)));

0 commit comments

Comments
 (0)