Skip to content

Rollup of PRs in the queue; Friday #23107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 69 commits into from
Mar 7, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
29938ff
Fix struct stat on arm linux
krdln Mar 4, 2015
61a2766
Note the alternate form of vec in trpl
steveklabnik Mar 4, 2015
b1e0dfb
docs(path.rs): fix ends_with method
ctjhoa Mar 4, 2015
a037cdf
Fix broken link in old rust guide
davbo Mar 4, 2015
0dfa997
std: Stabilize portions of the `io` module
alexcrichton Mar 3, 2015
9e28156
rustdoc: Move sidebar items into shared JavaScript.
lifthrasiir Mar 5, 2015
3f4181a
iOS: open file on aarch64 breaks permissions
vhbit Feb 26, 2015
7bcf7fb
Use more associated types in core::iter.
huonw Mar 4, 2015
18f1e40
doc example does nothing
Mar 5, 2015
e316c66
debuginfo: Add `debuginfo::with_source_location_override()` function...
michaelwoerister Mar 5, 2015
4a6fb45
rustdoc: Reworded comments to give the rationale for JS.
lifthrasiir Mar 5, 2015
215d287
debuginfo: Add test case for `extern "C"` functions.
michaelwoerister Mar 5, 2015
951ef9d
fix for new attributes failing. issue #22964
awlnx Mar 5, 2015
7ed418c
std: Deprecate the old_io::process module
alexcrichton Mar 5, 2015
1eb37bf
Fix Playpen Links Containing Multiple Examples
killercup Mar 5, 2015
f0897aa
OIBIT: for `PhantomData<T>` check `T` rather than the struct itself
Mar 5, 2015
9319252
rustc: Don't emit dep-info for imported files
alexcrichton Mar 5, 2015
d5d8345
rustc: Add a debug_assertions #[cfg] directive
alexcrichton Mar 2, 2015
628f5d2
std: Stabilize the `ffi` module
alexcrichton Mar 2, 2015
6148537
mk: Once again rename the beta channel artifacts as 'beta'
brson Mar 5, 2015
d3e7700
std: net: enable bind_error test on all platforms
stepancheg Mar 5, 2015
73b0b25
std: Stabilize the `fs` module
alexcrichton Mar 4, 2015
a08f129
fix minor grammar mistake in paths documentation
posborne Mar 6, 2015
65b4eda
std: Fix peeling ports from addresses
alexcrichton Mar 6, 2015
8655e94
'ignore-fast' directives do nothing
brson Mar 6, 2015
1552f67
Remove run-pass/lint-cstack.rs. No longer testing anything.
brson Mar 6, 2015
96b1f0c
Fix reference to 'librlibc' in libcore docs
wesleywiser Mar 6, 2015
ccd83da
file permission: remove executable bit from *.rs
Mar 6, 2015
e80fc10
Rollup merge of #22862 - vhbit:broken-open, r=alexcrichton
Manishearth Mar 6, 2015
9eb596c
Rollup merge of #22899 - huonw:macro-stability, r=alexcrichton
Manishearth Mar 6, 2015
efb487b
Rollup merge of #22980 - alexcrichton:debug-assertions, r=pnkfelix
Manishearth Mar 6, 2015
32631b4
Rollup merge of #23010 - alexcrichton:deprecate-some-old-io, r=aturon
Manishearth Mar 6, 2015
e99b00f
Rollup merge of #23039 - steveklabnik:doc_vec_macro, r=alexcrichton
Manishearth Mar 6, 2015
7a12c03
Rollup merge of #23060 - lifthrasiir:rustdoc-sidebar-in-js, r=alexcri…
Manishearth Mar 6, 2015
c39833e
Rollup merge of #23070 - krdln:fix-stat-arm, r=alexcrichton
Manishearth Mar 6, 2015
d77fc9f
Rollup merge of #23074 - michaelwoerister:constants-debug-locs, r=ale…
Manishearth Mar 6, 2015
c9063e0
Rollup merge of #23079 - alexcrichton:deprecate-process, r=aturon
Manishearth Mar 6, 2015
fe41c93
Rollup merge of #23081 - alexcrichton:stabilize-fs, r=aturon
Manishearth Mar 6, 2015
0b7117b
Rollup merge of #23090 - alexcrichton:dep-info, r=pnkfelix
Manishearth Mar 6, 2015
4993fd0
Rollup merge of #23095 - stepancheg:test-bind-fail, r=alexcrichton
Manishearth Mar 6, 2015
3f94260
Fix an easy to trigger deadlock in std::io::stdio
nagisa Mar 5, 2015
707f7a1
Check that traits with default impls have no methods
Mar 6, 2015
f2a1cf2
Rollup merge of #23098 - brson:ignore-fast, r=alexcrichton
Manishearth Mar 6, 2015
56e0229
Rollup merge of #23099 - brson:lint-cstack, r=alexcrichton
Manishearth Mar 6, 2015
7a2eea5
Rollup merge of #23101 - laijs:fix-file-perm, r=alexcrichton
Manishearth Mar 6, 2015
4176398
Rollup merge of #23025 - huonw:better-iter-infer, r=Gankro
Manishearth Mar 6, 2015
55087e7
Rollup merge of #23045 - ctjhoa:master, r=Manishearth
Manishearth Mar 6, 2015
ce2d04a
Rollup merge of #23048 - davbo:fix-broken-link-in-old-guide, r=brson
Manishearth Mar 6, 2015
2fcdd82
Rollup merge of #23056 - awlnx:master, r=nrc
Manishearth Mar 6, 2015
babd41e
Rollup merge of #23067 - oli-obk:doc_examle_fix, r=alexcrichton
Manishearth Mar 6, 2015
a14d6a9
Rollup merge of #23082 - killercup:patch-6, r=alexcrichton
Manishearth Mar 6, 2015
88cef03
Rollup merge of #23094 - brson:beta, r=huonw
Manishearth Mar 6, 2015
ae16afb
Rollup merge of #23096 - posborne:paths-documentation-grammar-fix, r=…
Manishearth Mar 6, 2015
aaaa431
Rollup merge of #23100 - wesleywiser:fix_23059, r=brson
Manishearth Mar 6, 2015
61c6b19
BufferedWriter -> BufWriter (fixup #23060)
Manishearth Mar 6, 2015
7ed4660
Rollup merge of #22474 - iKevinY:pandoc-version-check, r=brson
Manishearth Mar 6, 2015
8a391dd
move check into wf pass, add a test for assoc types
Mar 6, 2015
f7594e1
Remove two green threading tests
brson Mar 6, 2015
9aea749
std: Deprecate the std::old_io::net primitives
alexcrichton Feb 25, 2015
16ff140
std: Ignore a test on windows
alexcrichton Mar 6, 2015
1a30412
Suppress some warnings about features
alexcrichton Mar 6, 2015
fd86a01
rollup merge of #22813: alexcrichton/deprecate-net
alexcrichton Mar 6, 2015
2bd02ca
rollup merge of #22975: alexcrichton/stabilize-ffi
alexcrichton Mar 6, 2015
697de42
rollup merge of #23087: nagisa/std-undeadlock
alexcrichton Mar 6, 2015
31af637
rollup merge of #23091: japaric/phantom
alexcrichton Mar 6, 2015
3c2c516
rollup merge of #23097: alexcrichton/issue-23076
alexcrichton Mar 6, 2015
bc409cb
rollup merge of #23117: japaric/default-impl
alexcrichton Mar 6, 2015
11ddfb8
rollup merge of #23124: brson/oldtests
alexcrichton Mar 6, 2015
aed31ee
Test fixes and rebase conflicts
alexcrichton Mar 6, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
std: Stabilize the fs module
This commit performs a stabilization pass over the `std::fs` module now that
it's had some time to bake. The change was largely just adding `#[stable]` tags,
but there are a few APIs that remain `#[unstable]`.

The following apis are now marked `#[stable]`:

* `std::fs` (the name)
* `File`
* `Metadata`
* `ReadDir`
* `DirEntry`
* `OpenOptions`
* `Permissions`
* `File::{open, create}`
* `File::{sync_all, sync_data}`
* `File::set_len`
* `File::metadata`
* Trait implementations for `File` and `&File`
* `OpenOptions::new`
* `OpenOptions::{read, write, append, truncate, create}`
* `OpenOptions::open` - this function was modified, however, to not attempt to
  reject cross-platform openings of directories. This means that some platforms
  will succeed in opening a directory and others will fail.
* `Metadata::{is_dir, is_file, len, permissions}`
* `Permissions::{readonly, set_readonly}`
* `Iterator for ReadDir`
* `DirEntry::path`
* `remove_file` - like with `OpenOptions::open`, the extra windows code to
  remove a readonly file has been removed. This means that removing a readonly
  file will succeed on some platforms but fail on others.
* `metadata`
* `rename`
* `copy`
* `hard_link`
* `soft_link`
* `read_link`
* `create_dir`
* `create_dir_all`
* `remove_dir`
* `remove_dir_all`
* `read_dir`

The following apis remain `#[unstable]`.

* `WalkDir` and `walk` - there are many methods by which a directory walk can be
  constructed, and it's unclear whether the current semantics are the right
  ones. For example symlinks are not handled super well currently. This is now
  behind a new `fs_walk` feature.
* `File::path` - this is an extra abstraction which the standard library
  provides on top of what the system offers and it's unclear whether we should
  be doing so. This is now behind a new `file_path` feature.
* `Metadata::{accessed, modified}` - we do not currently have a good
  abstraction for a moment in time which is what these APIs should likely be
  returning, so these remain `#[unstable]` for now. These are now behind a new
  `fs_time` feature
* `set_file_times` - like with `Metadata::accessed`, we do not currently have
  the appropriate abstraction for the arguments here so this API remains
  unstable behind the `fs_time` feature gate.
* `PathExt` - the precise set of methods on this trait may change over time and
  some methods may be removed. This API remains unstable behind the `path_ext`
  feature gate.
* `set_permissions` - we may wish to expose a more granular ability to set the
  permissions on a file instead of just a blanket "set all permissions" method.
  This function remains behind the `fs` feature.

The following apis are now `#[deprecated]`

* The `TempDir` type is now entirely deprecated and is [located on
  crates.io][tempdir] as the `tempdir` crate with [its source][github] at
  rust-lang/tempdir.

[tempdir]: https://crates.io/crates/tempdir
[github]: https://github.com/rust-lang/tempdir

The stability of some of these APIs has been questioned over the past few weeks
in using these APIs, and it is intentional that the majority of APIs here are
marked `#[stable]`. The `std::fs` module has a lot of room to grow and the
material is [being tracked in a RFC issue][rfc-issue].

[rfc-issue]: rust-lang/rfcs#939

[breaking-change]
  • Loading branch information
alexcrichton committed Mar 6, 2015
commit 73b0b25e326687aba319df99aee4b0c4124d4498
2 changes: 1 addition & 1 deletion src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#![feature(path)]
#![feature(os)]
#![feature(io)]
#![feature(fs)]
#![feature(net)]
#![feature(path_ext)]

#![deny(warnings)]

Expand Down
2 changes: 1 addition & 1 deletion src/libgetopts/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@
#![feature(collections)]
#![feature(int_uint)]
#![feature(staged_api)]
#![feature(str_words)]
#![feature(core)]
#![feature(str_words)]
#![cfg_attr(test, feature(rustc_private))]

#[cfg(test)] #[macro_use] extern crate log;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
#![feature(std_misc)]
#![feature(os)]
#![feature(path)]
#![feature(fs)]
#![feature(io)]
#![feature(path_ext)]
#![cfg_attr(test, feature(test))]

extern crate arena;
Expand Down
4 changes: 3 additions & 1 deletion src/librustc_back/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
//! A helper class for dealing with static archives

use std::env;
use std::fs::{self, TempDir};
use std::fs;
use std::io::prelude::*;
use std::io;
use std::path::{Path, PathBuf};
use std::process::{Command, Output, Stdio};
use std::str;
use syntax::diagnostic::Handler as ErrorHandler;

use tempdir::TempDir;

pub const METADATA_FILENAME: &'static str = "rust.metadata.bin";

pub struct ArchiveConfig<'a> {
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_back/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#![feature(collections)]
#![feature(core)]
#![feature(old_fs)]
#![feature(fs)]
#![feature(hash)]
#![feature(int_uint)]
#![feature(io)]
Expand All @@ -44,14 +43,16 @@
#![feature(path)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(tempdir)]
#![feature(rand)]
#![feature(path_ext)]

extern crate syntax;
extern crate serialize;
#[macro_use] extern crate log;

pub mod abi;
pub mod archive;
pub mod tempdir;
pub mod arm;
pub mod fs;
pub mod mips;
Expand Down
121 changes: 121 additions & 0 deletions src/librustc_back/tempdir.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::env;
use std::io::{self, Error, ErrorKind};
use std::fs;
use std::path::{self, PathBuf, AsPath};
use std::rand::{thread_rng, Rng};

/// A wrapper for a path to temporary directory implementing automatic
/// scope-based deletion.
pub struct TempDir {
path: Option<PathBuf>,
}

// How many times should we (re)try finding an unused random name? It should be
// enough that an attacker will run out of luck before we run out of patience.
const NUM_RETRIES: u32 = 1 << 31;
// How many characters should we include in a random file name? It needs to
// be enough to dissuade an attacker from trying to preemptively create names
// of that length, but not so huge that we unnecessarily drain the random number
// generator of entropy.
const NUM_RAND_CHARS: uint = 12;

impl TempDir {
/// Attempts to make a temporary directory inside of `tmpdir` whose name
/// will have the prefix `prefix`. The directory will be automatically
/// deleted once the returned wrapper is destroyed.
///
/// If no directory can be created, `Err` is returned.
#[allow(deprecated)] // rand usage
pub fn new_in<P: AsPath + ?Sized>(tmpdir: &P, prefix: &str)
-> io::Result<TempDir> {
let storage;
let mut tmpdir = tmpdir.as_path();
if !tmpdir.is_absolute() {
let cur_dir = try!(env::current_dir());
storage = cur_dir.join(tmpdir);
tmpdir = &storage;
// return TempDir::new_in(&cur_dir.join(tmpdir), prefix);
}

let mut rng = thread_rng();
for _ in 0..NUM_RETRIES {
let suffix: String = rng.gen_ascii_chars().take(NUM_RAND_CHARS).collect();
let leaf = if prefix.len() > 0 {
format!("{}.{}", prefix, suffix)
} else {
// If we're given an empty string for a prefix, then creating a
// directory starting with "." would lead to it being
// semi-invisible on some systems.
suffix
};
let path = tmpdir.join(&leaf);
match fs::create_dir(&path) {
Ok(_) => return Ok(TempDir { path: Some(path) }),
Err(ref e) if e.kind() == ErrorKind::PathAlreadyExists => {}
Err(e) => return Err(e)
}
}

Err(Error::new(ErrorKind::PathAlreadyExists,
"too many temporary directories already exist",
None))
}

/// Attempts to make a temporary directory inside of `env::temp_dir()` whose
/// name will have the prefix `prefix`. The directory will be automatically
/// deleted once the returned wrapper is destroyed.
///
/// If no directory can be created, `Err` is returned.
#[allow(deprecated)]
pub fn new(prefix: &str) -> io::Result<TempDir> {
TempDir::new_in(&env::temp_dir(), prefix)
}

/// Unwrap the wrapped `std::path::Path` from the `TempDir` wrapper.
/// This discards the wrapper so that the automatic deletion of the
/// temporary directory is prevented.
pub fn into_path(mut self) -> PathBuf {
self.path.take().unwrap()
}

/// Access the wrapped `std::path::Path` to the temporary directory.
pub fn path(&self) -> &path::Path {
self.path.as_ref().unwrap()
}

/// Close and remove the temporary directory
///
/// Although `TempDir` removes the directory on drop, in the destructor
/// any errors are ignored. To detect errors cleaning up the temporary
/// directory, call `close` instead.
pub fn close(mut self) -> io::Result<()> {
self.cleanup_dir()
}

fn cleanup_dir(&mut self) -> io::Result<()> {
match self.path {
Some(ref p) => fs::remove_dir_all(p),
None => Ok(())
}
}
}

impl Drop for TempDir {
fn drop(&mut self) {
let _ = self.cleanup_dir();
}
}

// the tests for this module need to change the path using change_dir,
// and this doesn't play nicely with other tests so these unit tests are located
// in src/test/run-pass/tempfile.rs
1 change: 0 additions & 1 deletion src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#![feature(exit_status)]
#![feature(path)]
#![feature(io)]
#![feature(fs)]

extern crate arena;
extern crate flate;
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_trans/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ use middle::ty::{self, Ty};
use util::common::time;
use util::ppaux;
use util::sha2::{Digest, Sha256};
use rustc_back::tempdir::TempDir;

use std::ffi::{AsOsStr, OsString};
use std::fs::{self, TempDir, PathExt};
use std::fs::{self, PathExt};
use std::io::{self, Read, Write};
use std::mem;
use std::path::{Path, PathBuf};
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_trans/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
#![feature(std_misc)]
#![feature(unicode)]
#![feature(io)]
#![feature(fs)]
#![feature(path)]
#![feature(os)]
#![feature(tempdir)]
#![feature(path_ext)]
#![feature(fs)]

extern crate arena;
extern crate flate;
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@
#![feature(unicode)]
#![feature(str_words)]
#![feature(io)]
#![feature(fs)]
#![feature(path)]
#![feature(tempdir)]
#![feature(path_ext)]

extern crate arena;
extern crate getopts;
Expand All @@ -47,6 +46,7 @@ extern crate rustc_trans;
extern crate rustc_driver;
extern crate rustc_resolve;
extern crate rustc_lint;
extern crate rustc_back;
extern crate serialize;
extern crate syntax;
extern crate "test" as testing;
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use std::collections::{HashSet, HashMap};
use std::dynamic_lib::DynamicLibrary;
use std::env;
use std::ffi::OsString;
use std::fs::TempDir;
use std::old_io;
use std::io;
use std::path::PathBuf;
Expand All @@ -28,6 +27,7 @@ use rustc_lint;
use rustc::session::{self, config};
use rustc::session::config::get_unstable_features_setting;
use rustc::session::search_paths::{SearchPaths, PathKind};
use rustc_back::tempdir::TempDir;
use rustc_driver::{driver, Compilation};
use syntax::codemap::CodeMap;
use syntax::diagnostic;
Expand Down
Loading