Skip to content

Commit 212e031

Browse files
committed
std: Remove old_io/old_path from the prelude
This commit removes the reexports of `old_io` traits as well as `old_path` types and traits from the prelude. This functionality is now all deprecated and needs to be removed to make way for other functionality like `Seek` in the `std::io` module (currently reexported as `NewSeek` in the io prelude). Closes rust-lang#23377 Closes rust-lang#23378
1 parent 68d6941 commit 212e031

Some content is hidden

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

74 files changed

+372
-297
lines changed

src/compiletest/procsrv.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010

1111
#![allow(deprecated)] // for old path, for dynamic_lib
1212

13-
use std::process::{ExitStatus, Command, Child, Output, Stdio};
14-
use std::io::prelude::*;
1513
use std::dynamic_lib::DynamicLibrary;
14+
use std::io::prelude::*;
15+
use std::old_path::Path;
16+
use std::process::{ExitStatus, Command, Child, Output, Stdio};
1617

1718
fn add_target_env(cmd: &mut Command, lib_path: &str, aux_path: Option<&str>) {
1819
// Need to be sure to put both the lib_path and the aux path in the dylib

src/libcollections/fmt.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@
262262
//!
263263
//! ```
264264
//! # #![allow(unused_must_use)]
265+
//! use std::io::Write;
265266
//! let mut w = Vec::new();
266267
//! write!(&mut w, "Hello {}!", "world");
267268
//! ```
@@ -288,15 +289,15 @@
288289
//!
289290
//! ```
290291
//! use std::fmt;
291-
//! use std::old_io;
292+
//! use std::io::{self, Write};
292293
//!
293294
//! fmt::format(format_args!("this returns {}", "String"));
294295
//!
295-
//! let mut some_writer = old_io::stdout();
296+
//! let mut some_writer = io::stdout();
296297
//! write!(&mut some_writer, "{}", format_args!("print with a {}", "macro"));
297298
//!
298299
//! fn my_fmt_fn(args: fmt::Arguments) {
299-
//! write!(&mut old_io::stdout(), "{}", args);
300+
//! write!(&mut io::stdout(), "{}", args);
300301
//! }
301302
//! my_fmt_fn(format_args!("or a {} too", "function"));
302303
//! ```

src/libcore/macros.rs

+1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ macro_rules! try {
176176
///
177177
/// ```
178178
/// # #![allow(unused_must_use)]
179+
/// use std::io::Write;
179180
///
180181
/// let mut w = Vec::new();
181182
/// write!(&mut w, "test");

src/libcore/prelude.rs

-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ pub use marker::{Copy, Send, Sized, Sync};
2929
pub use ops::{Drop, Fn, FnMut, FnOnce};
3030

3131
// Reexported functions
32-
#[allow(deprecated)]
33-
pub use iter::range;
3432
pub use mem::drop;
3533

3634
// Reexported types and traits

src/libcore/result.rs

+13-7
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@
110110
//! something like this:
111111
//!
112112
//! ```{.ignore}
113-
//! use std::old_io::{File, Open, Write};
113+
//! use std::old_io::*;
114+
//! use std::old_path::Path;
114115
//!
115116
//! let mut file = File::open_mode(&Path::new("valuable_data.txt"), Open, Write);
116117
//! // If `write_line` errors, then we'll never know, because the return
@@ -128,7 +129,8 @@
128129
//! a marginally useful message indicating why:
129130
//!
130131
//! ```{.no_run}
131-
//! use std::old_io::{File, Open, Write};
132+
//! use std::old_io::*;
133+
//! use std::old_path::Path;
132134
//!
133135
//! let mut file = File::open_mode(&Path::new("valuable_data.txt"), Open, Write);
134136
//! file.write_line("important message").ok().expect("failed to write message");
@@ -138,7 +140,8 @@
138140
//! You might also simply assert success:
139141
//!
140142
//! ```{.no_run}
141-
//! # use std::old_io::{File, Open, Write};
143+
//! # use std::old_io::*;
144+
//! # use std::old_path::Path;
142145
//!
143146
//! # let mut file = File::open_mode(&Path::new("valuable_data.txt"), Open, Write);
144147
//! assert!(file.write_line("important message").is_ok());
@@ -148,7 +151,8 @@
148151
//! Or propagate the error up the call stack with `try!`:
149152
//!
150153
//! ```
151-
//! # use std::old_io::{File, Open, Write, IoError};
154+
//! # use std::old_io::*;
155+
//! # use std::old_path::Path;
152156
//! fn write_message() -> Result<(), IoError> {
153157
//! let mut file = File::open_mode(&Path::new("valuable_data.txt"), Open, Write);
154158
//! try!(file.write_line("important message"));
@@ -167,7 +171,8 @@
167171
//! It replaces this:
168172
//!
169173
//! ```
170-
//! use std::old_io::{File, Open, Write, IoError};
174+
//! use std::old_io::*;
175+
//! use std::old_path::Path;
171176
//!
172177
//! struct Info {
173178
//! name: String,
@@ -191,7 +196,8 @@
191196
//! With this:
192197
//!
193198
//! ```
194-
//! use std::old_io::{File, Open, Write, IoError};
199+
//! use std::old_io::*;
200+
//! use std::old_path::Path;
195201
//!
196202
//! struct Info {
197203
//! name: String,
@@ -446,7 +452,7 @@ impl<T, E> Result<T, E> {
446452
/// ignoring I/O and parse errors:
447453
///
448454
/// ```
449-
/// use std::old_io::IoResult;
455+
/// use std::old_io::*;
450456
///
451457
/// let mut buffer: &[u8] = b"1\n2\n3\n4\n";
452458
/// let mut buffer = &mut buffer;

src/libcoretest/str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn test_bool_from_str() {
3535
fn check_contains_all_substrings(s: &str) {
3636
assert!(s.contains(""));
3737
for i in 0..s.len() {
38-
for j in range(i+1, s.len() + 1) {
38+
for j in i+1..s.len() + 1 {
3939
assert!(s.contains(&s[i..j]));
4040
}
4141
}

src/librustc_back/fs.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use std::io;
12-
#[allow(deprecated)] use std::old_path;
12+
#[allow(deprecated)] use std::old_path::{self, GenericPath};
1313
#[allow(deprecated)] use std::old_io;
1414
use std::path::{Path, PathBuf};
1515

@@ -72,6 +72,7 @@ mod test {
7272
use std::old_io::fs::{File, symlink, mkdir, mkdir_recursive};
7373
use super::old_realpath as realpath;
7474
use std::old_io::TempDir;
75+
use std::old_path::{Path, GenericPath};
7576

7677
#[test]
7778
fn realpath_works() {

src/librustdoc/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ use std::path::PathBuf;
6464
use std::rc::Rc;
6565
use std::sync::mpsc::channel;
6666

67+
#[allow(deprecated)] use std::old_path::Path;
68+
6769
use externalfiles::ExternalHtml;
6870
use serialize::Decodable;
6971
use serialize::json::{self, Json};

src/librustdoc/plugins.rs

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use std::dynamic_lib as dl;
1616
use serialize::json;
1717
use std::mem;
1818
use std::string::String;
19+
use std::old_path::{Path, GenericPath};
1920

2021
pub type PluginJson = Option<(String, json::Json)>;
2122
pub type PluginResult = (clean::Crate, PluginJson);

src/libserialize/json.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2622,6 +2622,7 @@ mod tests {
26222622
use std::{i64, u64, f32, f64};
26232623
use std::collections::BTreeMap;
26242624
use std::string;
2625+
use std::old_io::Writer;
26252626

26262627
#[derive(RustcDecodable, Eq, PartialEq, Debug)]
26272628
struct OptionData {

src/libserialize/serialize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Core encoding and decoding interfaces.
1515
*/
1616

1717
#[allow(deprecated)]
18-
use std::old_path;
18+
use std::old_path::{self, GenericPath};
1919
use std::path;
2020
use std::rc::Rc;
2121
use std::cell::{Cell, RefCell};

src/libstd/dynamic_lib.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@
1818

1919
use prelude::v1::*;
2020

21+
use env;
2122
use ffi::CString;
2223
use mem;
23-
use env;
24-
use str;
24+
use old_path::{Path, GenericPath};
2525
use os;
26+
use str;
2627

2728
pub struct DynamicLibrary {
2829
handle: *mut u8
@@ -133,15 +134,15 @@ mod test {
133134
use super::*;
134135
use prelude::v1::*;
135136
use libc;
137+
use old_path::Path;
136138
use mem;
137139

138140
#[test]
139141
#[cfg_attr(any(windows, target_os = "android"), ignore)] // FIXME #8818, #10379
140142
fn test_loading_cosine() {
141143
// The math library does not need to be loaded since it is already
142144
// statically linked in
143-
let none: Option<&Path> = None; // appease the typechecker
144-
let libm = match DynamicLibrary::open(none) {
145+
let libm = match DynamicLibrary::open(None) {
145146
Err(error) => panic!("Could not load self as module: {}", error),
146147
Ok(libm) => libm
147148
};

src/libstd/env.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -729,10 +729,11 @@ mod arch {
729729
mod tests {
730730
use prelude::v1::*;
731731
use super::*;
732+
732733
use iter::repeat;
733734
use rand::{self, Rng};
734735
use ffi::{OsString, OsStr};
735-
use path::PathBuf;
736+
use path::{Path, PathBuf};
736737

737738
fn make_rand_name() -> OsString {
738739
let mut rng = rand::thread_rng();

src/libstd/fs/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,7 @@ mod tests {
801801
use prelude::v1::*;
802802
use io::prelude::*;
803803

804+
use env;
804805
use fs::{self, File, OpenOptions};
805806
use io::{ErrorKind, SeekFrom};
806807
use path::PathBuf;
@@ -848,8 +849,7 @@ mod tests {
848849
}
849850

850851
pub fn tmpdir() -> TempDir {
851-
let s = os::tmpdir();
852-
let p = Path2::new(s.as_str().unwrap());
852+
let p = env::temp_dir();
853853
let ret = p.join(&format!("rust-{}", rand::random::<u32>()));
854854
check!(fs::create_dir(&ret));
855855
TempDir(ret)
@@ -1082,7 +1082,7 @@ mod tests {
10821082
let dir = &tmpdir.join("di_readdir");
10831083
check!(fs::create_dir(dir));
10841084
let prefix = "foo";
1085-
for n in range(0, 3) {
1085+
for n in 0..3 {
10861086
let f = dir.join(&format!("{}.txt", n));
10871087
let mut w = check!(File::create(&f));
10881088
let msg_str = format!("{}{}", prefix, n.to_string());

src/libstd/io/prelude.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,5 @@
2323
2424
#![stable(feature = "rust1", since = "1.0.0")]
2525

26-
pub use super::{Read, Write, BufRead};
26+
pub use super::{Read, Write, BufRead, Seek};
2727
pub use fs::PathExt;
28-
29-
// FIXME: pub use as `Seek` when the name isn't in the actual prelude any more
30-
pub use super::Seek as NewSeek;

src/libstd/num/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1650,7 +1650,7 @@ mod tests {
16501650
#![test]
16511651
assert_eq!((0 as $T).next_power_of_two(), 1);
16521652
let mut next_power = 1;
1653-
for i in range::<$T>(1, 40) {
1653+
for i in 1 as $T..40 {
16541654
assert_eq!(i.next_power_of_two(), next_power);
16551655
if i == next_power { next_power *= 2 }
16561656
}
@@ -1673,7 +1673,7 @@ mod tests {
16731673
assert_eq!(($T::MAX - 1).checked_next_power_of_two(), None);
16741674
assert_eq!($T::MAX.checked_next_power_of_two(), None);
16751675
let mut next_power = 1;
1676-
for i in range::<$T>(1, 40) {
1676+
for i in 1 as $T..40 {
16771677
assert_eq!(i.checked_next_power_of_two(), Some(next_power));
16781678
if i == next_power { next_power *= 2 }
16791679
}

src/libstd/old_io/buffered.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ use vec::Vec;
3333
/// # Examples
3434
///
3535
/// ```
36-
/// use std::old_io::{BufferedReader, File};
36+
/// use std::old_io::*;
37+
/// use std::old_path::Path;
3738
///
3839
/// let file = File::open(&Path::new("message.txt"));
3940
/// let mut reader = BufferedReader::new(file);
@@ -136,7 +137,8 @@ impl<R: Reader> Reader for BufferedReader<R> {
136137
/// # Examples
137138
///
138139
/// ```
139-
/// use std::old_io::{BufferedWriter, File};
140+
/// use std::old_io::*;
141+
/// use std::old_path::Path;
140142
///
141143
/// let file = File::create(&Path::new("message.txt")).unwrap();
142144
/// let mut writer = BufferedWriter::new(file);
@@ -323,7 +325,8 @@ impl<W: Reader> Reader for InternalBufferedWriter<W> {
323325
///
324326
/// ```
325327
/// # #![allow(unused_must_use)]
326-
/// use std::old_io::{BufferedStream, File};
328+
/// use std::old_io::*;
329+
/// use std::old_path::Path;
327330
///
328331
/// let file = File::open(&Path::new("message.txt"));
329332
/// let mut stream = BufferedStream::new(file);
@@ -422,7 +425,7 @@ impl<S: Stream> Writer for BufferedStream<S> {
422425
#[cfg(test)]
423426
mod test {
424427
extern crate test;
425-
use old_io;
428+
use old_io::{self, Reader, Writer, Buffer, BufferPrelude};
426429
use prelude::v1::*;
427430
use super::*;
428431
use super::super::{IoResult, EndOfFile};

src/libstd/old_io/comm_adapters.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use vec::Vec;
2424
///
2525
/// ```
2626
/// use std::sync::mpsc::channel;
27-
/// use std::old_io::ChanReader;
27+
/// use std::old_io::*;
2828
///
2929
/// let (tx, rx) = channel();
3030
/// # drop(tx);
@@ -116,7 +116,7 @@ impl Reader for ChanReader {
116116
/// ```
117117
/// # #![allow(unused_must_use)]
118118
/// use std::sync::mpsc::channel;
119-
/// use std::old_io::ChanWriter;
119+
/// use std::old_io::*;
120120
///
121121
/// let (tx, rx) = channel();
122122
/// # drop(rx);
@@ -160,7 +160,7 @@ mod test {
160160

161161
use sync::mpsc::channel;
162162
use super::*;
163-
use old_io;
163+
use old_io::{self, Reader, Writer, Buffer};
164164
use thread;
165165

166166
#[test]

src/libstd/old_io/extensions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 {
179179
#[cfg(test)]
180180
mod test {
181181
use prelude::v1::*;
182-
use old_io;
182+
use old_io::{self, Reader, Writer};
183183
use old_io::{MemReader, BytesReader};
184184

185185
struct InitialZeroByteReader {

0 commit comments

Comments
 (0)