rollup merge of #22127: alexcrichton/stability-holes

There are a number of holes that the stability lint did not previously cover,
including:

* Types
* Bounds on type parameters on functions and impls
* Where clauses
* Imports
* Patterns (structs and enums)

These holes have all been fixed by overriding the `visit_path` function on the
AST visitor instead of a few specialized cases. This change also necessitated a
few stability changes:

* The `collections::fmt` module is now stable (it was already supposed to be).
* The `thread_local:👿:Key` type is now stable (it was already supposed to
  be).
* The `std::rt::{begin_unwind, begin_unwind_fmt}` functions are now stable.
  These are required via the `panic!` macro.
* The `std::old_io::stdio::{println, println_args}` functions are now stable.
  These are required by the `print!` and `println!` macros.
* The `ops::{FnOnce, FnMut, Fn}` traits are now `#[stable]`. This is required to
  make bounds with these traits stable. Note that manual implementations of
  these traits are still gated by default, this stability only allows bounds
  such as `F: FnOnce()`.

Closes #8962
Closes #16360
Closes #20327
This commit is contained in:
Alex Crichton
2015-02-11 14:02:04 -08:00
35 changed files with 187 additions and 127 deletions

View File

@@ -250,7 +250,7 @@ use char::CharExt;
use default::Default;
use error::Error;
use fmt;
use int;
use isize;
use iter::{Iterator, IteratorExt};
use marker::Sized;
use mem::transmute;
@@ -266,7 +266,7 @@ use slice::SliceExt;
use str::StrExt;
use str;
use string::String;
use uint;
use usize;
use unicode;
use vec::Vec;
@@ -712,28 +712,28 @@ pub trait Reader {
///
/// The number of bytes returned is system-dependent.
fn read_le_uint(&mut self) -> IoResult<uint> {
self.read_le_uint_n(uint::BYTES).map(|i| i as uint)
self.read_le_uint_n(usize::BYTES).map(|i| i as uint)
}
/// Reads a little-endian integer.
///
/// The number of bytes returned is system-dependent.
fn read_le_int(&mut self) -> IoResult<int> {
self.read_le_int_n(int::BYTES).map(|i| i as int)
self.read_le_int_n(isize::BYTES).map(|i| i as int)
}
/// Reads a big-endian unsigned integer.
///
/// The number of bytes returned is system-dependent.
fn read_be_uint(&mut self) -> IoResult<uint> {
self.read_be_uint_n(uint::BYTES).map(|i| i as uint)
self.read_be_uint_n(usize::BYTES).map(|i| i as uint)
}
/// Reads a big-endian integer.
///
/// The number of bytes returned is system-dependent.
fn read_be_int(&mut self) -> IoResult<int> {
self.read_be_int_n(int::BYTES).map(|i| i as int)
self.read_be_int_n(isize::BYTES).map(|i| i as int)
}
/// Reads a big-endian `u64`.
@@ -1096,25 +1096,25 @@ pub trait Writer {
/// Write a little-endian uint (number of bytes depends on system).
#[inline]
fn write_le_uint(&mut self, n: uint) -> IoResult<()> {
extensions::u64_to_le_bytes(n as u64, uint::BYTES, |v| self.write_all(v))
extensions::u64_to_le_bytes(n as u64, usize::BYTES, |v| self.write_all(v))
}
/// Write a little-endian int (number of bytes depends on system).
#[inline]
fn write_le_int(&mut self, n: int) -> IoResult<()> {
extensions::u64_to_le_bytes(n as u64, int::BYTES, |v| self.write_all(v))
extensions::u64_to_le_bytes(n as u64, isize::BYTES, |v| self.write_all(v))
}
/// Write a big-endian uint (number of bytes depends on system).
#[inline]
fn write_be_uint(&mut self, n: uint) -> IoResult<()> {
extensions::u64_to_be_bytes(n as u64, uint::BYTES, |v| self.write_all(v))
extensions::u64_to_be_bytes(n as u64, usize::BYTES, |v| self.write_all(v))
}
/// Write a big-endian int (number of bytes depends on system).
#[inline]
fn write_be_int(&mut self, n: int) -> IoResult<()> {
extensions::u64_to_be_bytes(n as u64, int::BYTES, |v| self.write_all(v))
extensions::u64_to_be_bytes(n as u64, isize::BYTES, |v| self.write_all(v))
}
/// Write a big-endian u64 (8 bytes).
@@ -1844,7 +1844,7 @@ mod tests {
use self::BadReaderBehavior::*;
use super::{IoResult, Reader, MemReader, NoProgress, InvalidInput, Writer};
use prelude::v1::{Ok, Vec, Buffer, SliceExt};
use uint;
use usize;
#[derive(Clone, PartialEq, Debug)]
enum BadReaderBehavior {
@@ -1891,24 +1891,24 @@ mod tests {
#[test]
fn test_read_at_least() {
let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()),
vec![GoodBehavior(uint::MAX)]);
vec![GoodBehavior(usize::MAX)]);
let buf = &mut [0u8; 5];
assert!(r.read_at_least(1, buf).unwrap() >= 1);
assert!(r.read_exact(5).unwrap().len() == 5); // read_exact uses read_at_least
assert!(r.read_at_least(0, buf).is_ok());
let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()),
vec![BadBehavior(50), GoodBehavior(uint::MAX)]);
vec![BadBehavior(50), GoodBehavior(usize::MAX)]);
assert!(r.read_at_least(1, buf).unwrap() >= 1);
let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()),
vec![BadBehavior(1), GoodBehavior(1),
BadBehavior(50), GoodBehavior(uint::MAX)]);
BadBehavior(50), GoodBehavior(usize::MAX)]);
assert!(r.read_at_least(1, buf).unwrap() >= 1);
assert!(r.read_at_least(1, buf).unwrap() >= 1);
let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()),
vec![BadBehavior(uint::MAX)]);
vec![BadBehavior(usize::MAX)]);
assert_eq!(r.read_at_least(1, buf).unwrap_err().kind, NoProgress);
let mut r = MemReader::new(b"hello, world!".to_vec());
@@ -1919,23 +1919,23 @@ mod tests {
#[test]
fn test_push_at_least() {
let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()),
vec![GoodBehavior(uint::MAX)]);
vec![GoodBehavior(usize::MAX)]);
let mut buf = Vec::new();
assert!(r.push_at_least(1, 5, &mut buf).unwrap() >= 1);
assert!(r.push_at_least(0, 5, &mut buf).is_ok());
let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()),
vec![BadBehavior(50), GoodBehavior(uint::MAX)]);
vec![BadBehavior(50), GoodBehavior(usize::MAX)]);
assert!(r.push_at_least(1, 5, &mut buf).unwrap() >= 1);
let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()),
vec![BadBehavior(1), GoodBehavior(1),
BadBehavior(50), GoodBehavior(uint::MAX)]);
BadBehavior(50), GoodBehavior(usize::MAX)]);
assert!(r.push_at_least(1, 5, &mut buf).unwrap() >= 1);
assert!(r.push_at_least(1, 5, &mut buf).unwrap() >= 1);
let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()),
vec![BadBehavior(uint::MAX)]);
vec![BadBehavior(usize::MAX)]);
assert_eq!(r.push_at_least(1, 5, &mut buf).unwrap_err().kind, NoProgress);
let mut r = MemReader::new(b"hello, world!".to_vec());