Skip to content

Commit 3b1b581

Browse files
committed
---
yaml --- r: 148862 b: refs/heads/try2 c: f9a32cd h: refs/heads/master v: v3
1 parent ea9052e commit 3b1b581

File tree

16 files changed

+275
-326
lines changed

16 files changed

+275
-326
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: 2a7c5e0b724d8318a7e7762e483c225e8a7420a1
8+
refs/heads/try2: f9a32cdabc1680b89bd7b579dc1e3f8f18c28257
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libnative/io/timer_timerfd.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,15 @@ fn helper(input: libc::c_int, messages: Port<Req>) {
9696
if fd == input {
9797
let mut buf = [0, ..1];
9898
// drain the input file descriptor of its input
99-
FileDesc::new(fd, false).inner_read(buf).unwrap();
99+
let _ = FileDesc::new(fd, false).inner_read(buf).unwrap();
100100
incoming = true;
101101
} else {
102102
let mut bits = [0, ..8];
103103
// drain the timerfd of how many times its fired
104104
//
105105
// FIXME: should this perform a send() this number of
106106
// times?
107-
FileDesc::new(fd, false).inner_read(bits).unwrap();
107+
let _ = FileDesc::new(fd, false).inner_read(bits).unwrap();
108108
let remove = {
109109
match map.find(&fd).expect("fd unregistered") {
110110
&(ref c, oneshot) => !c.try_send(()) || oneshot
@@ -166,7 +166,8 @@ impl Timer {
166166
}
167167

168168
pub fn sleep(ms: u64) {
169-
unsafe { libc::usleep((ms * 1000) as libc::c_uint); }
169+
// FIXME: this can fail because of EINTR, what do do?
170+
let _ = unsafe { libc::usleep((ms * 1000) as libc::c_uint) };
170171
}
171172

172173
fn remove(&mut self) {

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,10 @@ method of the signature:
163163
164164
```rust
165165
# use std;
166+
# mod fmt { pub type Result = (); }
166167
# struct T;
167168
# trait SomeName<T> {
168-
fn fmt(value: &T, f: &mut std::fmt::Formatter);
169+
fn fmt(value: &T, f: &mut std::fmt::Formatter) -> fmt::Result;
169170
# }
170171
```
171172
@@ -174,7 +175,14 @@ emit output into the `f.buf` stream. It is up to each format trait
174175
implementation to correctly adhere to the requested formatting parameters. The
175176
values of these parameters will be listed in the fields of the `Formatter`
176177
struct. In order to help with this, the `Formatter` struct also provides some
177-
helper methods. An example of implementing the formatting traits would look
178+
helper methods.
179+
180+
Additionally, the return value of this function is `fmt::Result` which is a
181+
typedef to `Result<(), IoError>` (also known as `IoError<()>`). Formatting
182+
implementations should ensure that they return errors from `write!` correctly
183+
(propagating errors upward).
184+
185+
An example of implementing the formatting traits would look
178186
like:
179187
180188
```rust
@@ -187,7 +195,7 @@ struct Vector2D {
187195
}
188196
189197
impl fmt::Show for Vector2D {
190-
fn fmt(obj: &Vector2D, f: &mut fmt::Formatter) {
198+
fn fmt(obj: &Vector2D, f: &mut fmt::Formatter) -> fmt::Result {
191199
// The `f.buf` value is of the type `&mut io::Writer`, which is what th
192200
// write! macro is expecting. Note that this formatting ignores the
193201
// various flags provided to format strings.
@@ -198,7 +206,7 @@ impl fmt::Show for Vector2D {
198206
// Different traits allow different forms of output of a type. The meaning of
199207
// this format is to print the magnitude of a vector.
200208
impl fmt::Binary for Vector2D {
201-
fn fmt(obj: &Vector2D, f: &mut fmt::Formatter) {
209+
fn fmt(obj: &Vector2D, f: &mut fmt::Formatter) -> fmt::Result {
202210
let magnitude = (obj.x * obj.x + obj.y * obj.y) as f64;
203211
let magnitude = magnitude.sqrt();
204212
@@ -207,7 +215,7 @@ impl fmt::Binary for Vector2D {
207215
// for details, and the function `pad` can be used to pad strings.
208216
let decimals = f.precision.unwrap_or(3);
209217
let string = f64::to_str_exact(magnitude, decimals);
210-
f.pad_integral(string.as_bytes(), "", true);
218+
f.pad_integral(string.as_bytes(), "", true)
211219
}
212220
}
213221
@@ -242,6 +250,7 @@ strings and instead directly write the output. Under the hood, this function is
242250
actually invoking the `write` function defined in this module. Example usage is:
243251
244252
```rust
253+
# #[allow(unused_must_use)];
245254
use std::io;
246255
247256
let mut w = io::MemWriter::new();
@@ -655,11 +664,12 @@ uniform_fn_call_workaround! {
655664
/// # Example
656665
///
657666
/// ```rust
667+
/// # #[allow(unused_must_use)];
658668
/// use std::fmt;
659669
/// use std::io;
660670
///
661671
/// let w = &mut io::stdout() as &mut io::Writer;
662-
/// format_args!(|args| { fmt::write(w, args) }, "Hello, {}!", "world");
672+
/// format_args!(|args| { fmt::write(w, args); }, "Hello, {}!", "world");
663673
/// ```
664674
pub fn write(output: &mut io::Writer, args: &Arguments) -> Result {
665675
unsafe { write_unsafe(output, args.fmt, args.args) }

branches/try2/src/libstd/io/buffered.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,13 @@ use vec;
3131
/// ```rust
3232
/// use std::io::{BufferedReader, File};
3333
///
34-
/// # let _g = ::std::io::ignore_io_error();
3534
/// let file = File::open(&Path::new("message.txt"));
3635
/// let mut reader = BufferedReader::new(file);
3736
///
3837
/// let mut buf = [0, ..100];
3938
/// match reader.read(buf) {
40-
/// Some(nread) => println!("Read {} bytes", nread),
41-
/// None => println!("At the end of the file!")
39+
/// Ok(nread) => println!("Read {} bytes", nread),
40+
/// Err(e) => println!("error reading: {}", e)
4241
/// }
4342
/// ```
4443
pub struct BufferedReader<R> {
@@ -121,9 +120,9 @@ impl<R: Reader> Reader for BufferedReader<R> {
121120
/// # Example
122121
///
123122
/// ```rust
123+
/// # #[allow(unused_must_use)];
124124
/// use std::io::{BufferedWriter, File};
125125
///
126-
/// # let _g = ::std::io::ignore_io_error();
127126
/// let file = File::open(&Path::new("message.txt"));
128127
/// let mut writer = BufferedWriter::new(file);
129128
///
@@ -268,9 +267,9 @@ impl<W: Reader> Reader for InternalBufferedWriter<W> {
268267
/// # Example
269268
///
270269
/// ```rust
270+
/// # #[allow(unused_must_use)];
271271
/// use std::io::{BufferedStream, File};
272272
///
273-
/// # let _g = ::std::io::ignore_io_error();
274273
/// let file = File::open(&Path::new("message.txt"));
275274
/// let mut stream = BufferedStream::new(file);
276275
///
@@ -279,8 +278,8 @@ impl<W: Reader> Reader for InternalBufferedWriter<W> {
279278
///
280279
/// let mut buf = [0, ..100];
281280
/// match stream.read(buf) {
282-
/// Some(nread) => println!("Read {} bytes", nread),
283-
/// None => println!("At the end of the stream!")
281+
/// Ok(nread) => println!("Read {} bytes", nread),
282+
/// Err(e) => println!("error reading: {}", e)
284283
/// }
285284
/// ```
286285
pub struct BufferedStream<S> {

0 commit comments

Comments
 (0)