Auto merge of #32112 - alexcrichton:fix-issues, r=aturon

std: Fix tracking issues and clean deprecated APIs

This PR fixes up a number of discrepancies found with tracking issues (some closed, some needed new ones, etc), and also cleans out all pre-1.8 deprecated APIs. The big beast here was dealing with `std::dynamic_lib`, and via many applications of a large hammer it's now out of the standard library.
This commit is contained in:
bors 2016-03-12 13:21:06 -08:00
commit a2c56de764
87 changed files with 471 additions and 2472 deletions

View file

@ -8,13 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(dynamic_lib)]
#![feature(rustc_private)]
// We're testing linkage visibility; the compiler warns us, but we want to
// do the runtime check that these functions aren't exported.
#![allow(private_no_mangle_fns)]
use std::dynamic_lib::DynamicLibrary;
extern crate rustc_back;
use rustc_back::dynamic_lib::DynamicLibrary;
#[no_mangle]
pub fn foo() { bar(); }

View file

@ -8,7 +8,17 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::borrow::IntoCow;
use std::borrow::Cow;
pub trait IntoCow<'a, B: ?Sized> where B: ToOwned {
fn into_cow(self) -> Cow<'a, B>;
}
impl<'a> IntoCow<'a, str> for String {
fn into_cow(self) -> Cow<'a, str> {
Cow::Owned(self)
}
}
fn main() {
<String as IntoCow>::into_cow("foo".to_string());

View file

@ -8,9 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(dynamic_lib)]
#![feature(rustc_private)]
use std::dynamic_lib::DynamicLibrary;
extern crate rustc_back;
use rustc_back::dynamic_lib::DynamicLibrary;
use std::path::Path;
pub fn main() {

View file

@ -1,16 +1,18 @@
-include ../tools.mk
OUT := $(TMPDIR)/out
ifndef IS_WINDOWS
all: time
time: libc
mkdir -p out/time out/time/deps
ln -sf out/libc/liblibc.rlib out/time/deps/
$(RUSTC) in/time/lib.rs -Ldependency=out/time/deps/
mkdir -p $(OUT)/time $(OUT)/time/deps
ln -sf $(OUT)/libc/liblibc.rlib $(OUT)/time/deps/
$(RUSTC) in/time/lib.rs -Ldependency=$(OUT)/time/deps/
libc:
mkdir -p out/libc
$(RUSTC) in/libc/lib.rs --crate-name=libc -o out/libc/liblibc.rlib
mkdir -p $(OUT)/libc
$(RUSTC) in/libc/lib.rs --crate-name=libc -o $(OUT)/libc/liblibc.rlib
else
all:
endif

View file

@ -1,8 +1,10 @@
-include ../tools.mk
LOG := $(TMPDIR)/foo.log
all:
cp foo.rs $(TMPDIR)
cd $(TMPDIR)
-$(RUSTC) -Z unstable-options --error-format=json foo.rs 2>foo.log
grep -q '{"message":"unresolved name `y`","code":{"code":"E0425","explanation":"\\nAn unresolved name was used. Example of erroneous codes.*"},"level":"error","spans":\[{"file_name":"foo.rs","byte_start":496,"byte_end":497,"line_start":12,"line_end":12,"column_start":18,"column_end":19}\],"children":\[\]}' foo.log
grep -q '{"message":".*","code":{"code":"E0277","explanation":"\\nYou tried.*"},"level":"error","spans":\[{.*}\],"children":\[{"message":"the .*","code":null,"level":"help","spans":\[{"file_name":"foo.rs","byte_start":504,"byte_end":516,"line_start":14,"line_end":14,"column_start":0,"column_end":0}\],"children":\[\]},{"message":" <u8 as core::ops::Add>","code":null,"level":"help",' foo.log
-$(RUSTC) -Z unstable-options --error-format=json foo.rs 2>$(LOG)
grep -q '{"message":"unresolved name `y`","code":{"code":"E0425","explanation":"\\nAn unresolved name was used. Example of erroneous codes.*"},"level":"error","spans":\[{"file_name":"foo.rs","byte_start":496,"byte_end":497,"line_start":12,"line_end":12,"column_start":18,"column_end":19}\],"children":\[\]}' $(LOG)
grep -q '{"message":".*","code":{"code":"E0277","explanation":"\\nYou tried.*"},"level":"error","spans":\[{.*}\],"children":\[{"message":"the .*","code":null,"level":"help","spans":\[{"file_name":"foo.rs","byte_start":504,"byte_end":516,"line_start":14,"line_end":14,"column_start":0,"column_end":0}\],"children":\[\]},{"message":" <u8 as core::ops::Add>","code":null,"level":"help",' $(LOG)

View file

@ -1,22 +0,0 @@
// Copyright 2012-2014 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.
#![feature(rustc_private)]
extern crate arena;
use arena::Arena;
pub fn main() {
let mut arena = Arena::new();
let p = &mut arena;
let x = p.alloc(|| 4_usize);
println!("{}", *x);
assert_eq!(*x, 4_usize);
}

View file

@ -15,7 +15,6 @@
// ignore-emscripten
// no-prefer-dynamic
#![feature(convert)]
#![feature(libc)]
extern crate libc;
@ -23,7 +22,8 @@ extern crate libc;
use libc::c_char;
use libc::execve;
use std::env;
use std::ffi::OsStr;
use std::ffi::CString;
use std::os::unix::prelude::*;
use std::ptr;
fn main() {
@ -34,8 +34,11 @@ fn main() {
return;
}
let current_exe = env::current_exe().unwrap().into_os_string().to_cstring().unwrap();
let new_env_var = OsStr::new("FOOBAR").to_cstring().unwrap();
let current_exe = CString::new(env::current_exe()
.unwrap()
.as_os_str()
.as_bytes()).unwrap();
let new_env_var = CString::new("FOOBAR").unwrap();
let filename: *const c_char = current_exe.as_ptr();
let argv: &[*const c_char] = &[filename, filename, ptr::null()];
let envp: &[*const c_char] = &[new_env_var.as_ptr(), ptr::null()];

View file

@ -10,15 +10,14 @@
// pretty-expanded FIXME #23616
#![feature(num_bits_bytes)]
use std::u8;
mod u8 {
pub const BITS: usize = 8;
}
const NUM: usize = u8::BITS;
struct MyStruct { nums: [usize; 8] }
fn main() {
let _s = MyStruct { nums: [0; NUM] };
}

View file

@ -10,7 +10,7 @@
// pretty-expanded FIXME #23616
#![feature(fs, net, fs_walk)]
#![feature(fs, net)]
use std::{fs, net};
@ -22,7 +22,6 @@ fn main() {
assert_both::<fs::Metadata>();
assert_both::<fs::ReadDir>();
assert_both::<fs::DirEntry>();
assert_send::<fs::WalkDir>();
assert_both::<fs::OpenOptions>();
assert_both::<fs::Permissions>();

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(iter_min_max, cmp_partial, iter_cmp)]
use std::fmt::Debug;
use std::cmp::{self, PartialOrd, Ordering};
@ -43,13 +41,13 @@ fn main() {
// `min` should return the left when the values are equal
assert_eq!(data.iter().min(), Some(&a));
assert_eq!(data.iter().min_by(|a| a.n), Some(&a));
assert_eq!(data.iter().min_by_key(|a| a.n), Some(&a));
assert_eq!(cmp::min(a, b), a);
assert_eq!(cmp::min(b, a), b);
// `max` should return the right when the values are equal
assert_eq!(data.iter().max(), Some(&f));
assert_eq!(data.iter().max_by(|a| a.n), Some(&f));
assert_eq!(data.iter().max_by_key(|a| a.n), Some(&f));
assert_eq!(cmp::max(e, f), f);
assert_eq!(cmp::max(f, e), e);

View file

@ -12,7 +12,7 @@
//
// Test std::num::Wrapping<T> for {uN, iN, usize, isize}
#![feature(num_bits_bytes, test)]
#![feature(test)]
extern crate test;
@ -22,9 +22,40 @@ use std::ops::{
AddAssign, SubAssign, MulAssign, DivAssign, RemAssign, BitXorAssign, BitOrAssign, BitAndAssign,
Shl, Shr, ShlAssign, ShrAssign
};
use std::{i8, i16, i32, i64, isize, u8, u16, u32, u64, usize};
use test::black_box;
macro_rules! int_modules {
($(($name:ident, $size:expr),)*) => ($(
mod $name {
pub const BITS: usize = $size;
pub use std::$name::*;
}
)*)
}
int_modules! {
(i8, 8),
(i16, 16),
(i32, 32),
(i64, 64),
(u8, 8),
(u16, 16),
(u32, 32),
(u64, 64),
}
#[cfg(target_pointer_width = "32")]
int_modules! {
(isize, 32),
(usize, 32),
}
#[cfg(target_pointer_width = "64")]
int_modules! {
(isize, 64),
(usize, 64),
}
fn main() {
test_ops();
test_op_assigns();

View file

@ -8,57 +8,55 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(collections, into_cow)]
extern crate collections;
use std::collections::HashMap;
use std::borrow::{Cow, IntoCow};
use std::borrow::Cow;
use std::borrow::Cow::Borrowed as B;
use std::borrow::Cow::Owned as O;
type SendStr = Cow<'static, str>;
pub fn main() {
fn main() {
let mut map: HashMap<SendStr, usize> = HashMap::new();
assert!(map.insert("foo".into_cow(), 42).is_none());
assert!(map.insert("foo".to_string().into_cow(), 42).is_some());
assert!(map.insert("foo".into_cow(), 42).is_some());
assert!(map.insert("foo".to_string().into_cow(), 42).is_some());
assert!(map.insert(B("foo"), 42).is_none());
assert!(map.insert(O("foo".to_string()), 42).is_some());
assert!(map.insert(B("foo"), 42).is_some());
assert!(map.insert(O("foo".to_string()), 42).is_some());
assert!(map.insert("foo".into_cow(), 43).is_some());
assert!(map.insert("foo".to_string().into_cow(), 44).is_some());
assert!(map.insert("foo".into_cow(), 45).is_some());
assert!(map.insert("foo".to_string().into_cow(), 46).is_some());
assert!(map.insert(B("foo"), 43).is_some());
assert!(map.insert(O("foo".to_string()), 44).is_some());
assert!(map.insert(B("foo"), 45).is_some());
assert!(map.insert(O("foo".to_string()), 46).is_some());
let v = 46;
assert_eq!(map.get(&"foo".to_string().into_cow()), Some(&v));
assert_eq!(map.get(&"foo".into_cow()), Some(&v));
assert_eq!(map.get(&O("foo".to_string())), Some(&v));
assert_eq!(map.get(&B("foo")), Some(&v));
let (a, b, c, d) = (50, 51, 52, 53);
assert!(map.insert("abc".into_cow(), a).is_none());
assert!(map.insert("bcd".to_string().into_cow(), b).is_none());
assert!(map.insert("cde".into_cow(), c).is_none());
assert!(map.insert("def".to_string().into_cow(), d).is_none());
assert!(map.insert(B("abc"), a).is_none());
assert!(map.insert(O("bcd".to_string()), b).is_none());
assert!(map.insert(B("cde"), c).is_none());
assert!(map.insert(O("def".to_string()), d).is_none());
assert!(map.insert("abc".into_cow(), a).is_some());
assert!(map.insert("bcd".to_string().into_cow(), b).is_some());
assert!(map.insert("cde".into_cow(), c).is_some());
assert!(map.insert("def".to_string().into_cow(), d).is_some());
assert!(map.insert(B("abc"), a).is_some());
assert!(map.insert(O("bcd".to_string()), b).is_some());
assert!(map.insert(B("cde"), c).is_some());
assert!(map.insert(O("def".to_string()), d).is_some());
assert!(map.insert("abc".to_string().into_cow(), a).is_some());
assert!(map.insert("bcd".into_cow(), b).is_some());
assert!(map.insert("cde".to_string().into_cow(), c).is_some());
assert!(map.insert("def".into_cow(), d).is_some());
assert!(map.insert(O("abc".to_string()), a).is_some());
assert!(map.insert(B("bcd"), b).is_some());
assert!(map.insert(O("cde".to_string()), c).is_some());
assert!(map.insert(B("def"), d).is_some());
assert_eq!(map.get("abc"), Some(&a));
assert_eq!(map.get("bcd"), Some(&b));
assert_eq!(map.get("cde"), Some(&c));
assert_eq!(map.get("def"), Some(&d));
assert_eq!(map.get(&"abc".into_cow()), Some(&a));
assert_eq!(map.get(&"bcd".into_cow()), Some(&b));
assert_eq!(map.get(&"cde".into_cow()), Some(&c));
assert_eq!(map.get(&"def".into_cow()), Some(&d));
assert_eq!(map.get(&B("abc")), Some(&a));
assert_eq!(map.get(&B("bcd")), Some(&b));
assert_eq!(map.get(&B("cde")), Some(&c));
assert_eq!(map.get(&B("def")), Some(&d));
}

View file

@ -8,61 +8,58 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::collections::BTreeMap;
use std::borrow::Cow;
#![feature(collections, into_cow)]
extern crate collections;
use self::collections::BTreeMap;
use std::borrow::{Cow, IntoCow};
use std::borrow::Cow::{Owned as O, Borrowed as B};
type SendStr = Cow<'static, str>;
pub fn main() {
fn main() {
let mut map: BTreeMap<SendStr, usize> = BTreeMap::new();
assert!(map.insert("foo".into_cow(), 42).is_none());
assert!(map.insert("foo".to_string().into_cow(), 42).is_some());
assert!(map.insert("foo".into_cow(), 42).is_some());
assert!(map.insert("foo".to_string().into_cow(), 42).is_some());
assert!(map.insert(B("foo"), 42).is_none());
assert!(map.insert(O("foo".to_string()), 42).is_some());
assert!(map.insert(B("foo"), 42).is_some());
assert!(map.insert(O("foo".to_string()), 42).is_some());
assert!(map.insert("foo".into_cow(), 43).is_some());
assert!(map.insert("foo".to_string().into_cow(), 44).is_some());
assert!(map.insert("foo".into_cow(), 45).is_some());
assert!(map.insert("foo".to_string().into_cow(), 46).is_some());
assert!(map.insert(B("foo"), 43).is_some());
assert!(map.insert(O("foo".to_string()), 44).is_some());
assert!(map.insert(B("foo"), 45).is_some());
assert!(map.insert(O("foo".to_string()), 46).is_some());
let v = 46;
assert_eq!(map.get(&"foo".to_string().into_cow()), Some(&v));
assert_eq!(map.get(&"foo".into_cow()), Some(&v));
assert_eq!(map.get(&O("foo".to_string())), Some(&v));
assert_eq!(map.get(&B("foo")), Some(&v));
let (a, b, c, d) = (50, 51, 52, 53);
assert!(map.insert("abc".into_cow(), a).is_none());
assert!(map.insert("bcd".to_string().into_cow(), b).is_none());
assert!(map.insert("cde".into_cow(), c).is_none());
assert!(map.insert("def".to_string().into_cow(), d).is_none());
assert!(map.insert(B("abc"), a).is_none());
assert!(map.insert(O("bcd".to_string()), b).is_none());
assert!(map.insert(B("cde"), c).is_none());
assert!(map.insert(O("def".to_string()), d).is_none());
assert!(map.insert("abc".into_cow(), a).is_some());
assert!(map.insert("bcd".to_string().into_cow(), b).is_some());
assert!(map.insert("cde".into_cow(), c).is_some());
assert!(map.insert("def".to_string().into_cow(), d).is_some());
assert!(map.insert(B("abc"), a).is_some());
assert!(map.insert(O("bcd".to_string()), b).is_some());
assert!(map.insert(B("cde"), c).is_some());
assert!(map.insert(O("def".to_string()), d).is_some());
assert!(map.insert("abc".to_string().into_cow(), a).is_some());
assert!(map.insert("bcd".into_cow(), b).is_some());
assert!(map.insert("cde".to_string().into_cow(), c).is_some());
assert!(map.insert("def".into_cow(), d).is_some());
assert!(map.insert(O("abc".to_string()), a).is_some());
assert!(map.insert(B("bcd"), b).is_some());
assert!(map.insert(O("cde".to_string()), c).is_some());
assert!(map.insert(B("def"), d).is_some());
assert_eq!(map.get(&"abc".into_cow()), Some(&a));
assert_eq!(map.get(&"bcd".into_cow()), Some(&b));
assert_eq!(map.get(&"cde".into_cow()), Some(&c));
assert_eq!(map.get(&"def".into_cow()), Some(&d));
assert_eq!(map.get(&B("abc")), Some(&a));
assert_eq!(map.get(&B("bcd")), Some(&b));
assert_eq!(map.get(&B("cde")), Some(&c));
assert_eq!(map.get(&B("def")), Some(&d));
assert_eq!(map.get(&"abc".to_string().into_cow()), Some(&a));
assert_eq!(map.get(&"bcd".to_string().into_cow()), Some(&b));
assert_eq!(map.get(&"cde".to_string().into_cow()), Some(&c));
assert_eq!(map.get(&"def".to_string().into_cow()), Some(&d));
assert_eq!(map.get(&O("abc".to_string())), Some(&a));
assert_eq!(map.get(&O("bcd".to_string())), Some(&b));
assert_eq!(map.get(&O("cde".to_string())), Some(&c));
assert_eq!(map.get(&O("def".to_string())), Some(&d));
assert!(map.remove(&"foo".into_cow()).is_some());
assert!(map.remove(&B("foo")).is_some());
assert_eq!(map.into_iter().map(|(k, v)| format!("{}{}", k, v))
.collect::<Vec<String>>()
.concat(),

View file

@ -24,7 +24,6 @@ fn main() {
assert_both::<sync::Mutex<()>>();
assert_both::<sync::Condvar>();
assert_both::<sync::RwLock<()>>();
assert_both::<sync::Semaphore>();
assert_both::<sync::Barrier>();
assert_both::<sync::Arc<()>>();
assert_both::<sync::Weak<()>>();

View file

@ -8,9 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(into_cow)]
use std::borrow::{Cow, IntoCow};
use std::borrow::{Cow, ToOwned};
use std::default::Default;
use std::iter::FromIterator;
use std::ops::Add;
@ -25,6 +23,16 @@ pub trait Rand: Default + Sized {
}
impl Rand for i32 { }
pub trait IntoCow<'a, B: ?Sized> where B: ToOwned {
fn into_cow(self) -> Cow<'a, B>;
}
impl<'a> IntoCow<'a, str> for String {
fn into_cow(self) -> Cow<'a, str> {
Cow::Owned(self)
}
}
#[derive(PartialEq, Eq)]
struct Newt<T>(T);

View file

@ -8,15 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(vec_push_all)]
use std::vec;
pub fn main() {
let a: Vec<isize> = vec!(1, 2, 3, 4, 5);
let b: Vec<isize> = vec!(6, 7, 8, 9, 0);
let mut v: Vec<isize> = a;
v.push_all(&b);
v.extend_from_slice(&b);
println!("{}", v[9]);
assert_eq!(v[0], 1);
assert_eq!(v[7], 8);

View file

@ -10,7 +10,7 @@
// ignore-emscripten no threads support
#![feature(rand, num_bits_bytes)]
#![feature(rand)]
#![feature(const_fn)]
use std::sync::atomic::{AtomicUsize, Ordering};
@ -47,7 +47,6 @@ impl Drop for DropCounter {
}
pub fn main() {
assert!(MAX_LEN <= std::usize::BITS);
// len can't go above 64.
for len in 2..MAX_LEN {
for _ in 0..REPEATS {