Merge remote-tracking branch 'nrc/sized-2' into rollup
Conflicts: src/liballoc/boxed.rs src/libcollections/btree/map.rs src/libcollections/slice.rs src/libcore/borrow.rs src/libcore/cmp.rs src/libcore/ops.rs src/libstd/c_str.rs src/libstd/collections/hash/map.rs src/libsyntax/parse/obsolete.rs src/test/compile-fail/unboxed-closure-sugar-default.rs src/test/compile-fail/unboxed-closure-sugar-equiv.rs src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs src/test/compile-fail/unboxed-closure-sugar-region.rs src/test/compile-fail/unsized3.rs src/test/run-pass/associated-types-conditional-dispatch.rs
This commit is contained in:
commit
384e218789
@ -75,14 +75,14 @@ impl<T: Clone> Clone for Box<T> {
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<Sized? T: PartialEq> PartialEq for Box<T> {
|
||||
impl<T: ?Sized + PartialEq> PartialEq for Box<T> {
|
||||
#[inline]
|
||||
fn eq(&self, other: &Box<T>) -> bool { PartialEq::eq(&**self, &**other) }
|
||||
#[inline]
|
||||
fn ne(&self, other: &Box<T>) -> bool { PartialEq::ne(&**self, &**other) }
|
||||
}
|
||||
#[stable]
|
||||
impl<Sized? T: PartialOrd> PartialOrd for Box<T> {
|
||||
impl<T: ?Sized + PartialOrd> PartialOrd for Box<T> {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &Box<T>) -> Option<Ordering> {
|
||||
PartialOrd::partial_cmp(&**self, &**other)
|
||||
@ -97,16 +97,16 @@ impl<Sized? T: PartialOrd> PartialOrd for Box<T> {
|
||||
fn gt(&self, other: &Box<T>) -> bool { PartialOrd::gt(&**self, &**other) }
|
||||
}
|
||||
#[stable]
|
||||
impl<Sized? T: Ord> Ord for Box<T> {
|
||||
impl<T: ?Sized + Ord> Ord for Box<T> {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &Box<T>) -> Ordering {
|
||||
Ord::cmp(&**self, &**other)
|
||||
}
|
||||
|
||||
#[stable]}
|
||||
impl<Sized? T: Eq> Eq for Box<T> {}
|
||||
impl<T: ?Sized + Eq> Eq for Box<T> {}
|
||||
|
||||
impl<S: hash::Writer, Sized? T: Hash<S>> Hash<S> for Box<T> {
|
||||
impl<S: hash::Writer, T: ?Sized + Hash<S>> Hash<S> for Box<T> {
|
||||
#[inline]
|
||||
fn hash(&self, state: &mut S) {
|
||||
(**self).hash(state);
|
||||
@ -143,7 +143,7 @@ impl BoxAny for Box<Any> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Sized? T: fmt::Show> fmt::Show for Box<T> {
|
||||
impl<T: ?Sized + fmt::Show> fmt::Show for Box<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
(**self).fmt(f)
|
||||
}
|
||||
@ -156,14 +156,14 @@ impl fmt::Show for Box<Any> {
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<Sized? T> Deref for Box<T> {
|
||||
impl<T: ?Sized> Deref for Box<T> {
|
||||
type Target = T;
|
||||
|
||||
fn deref(&self) -> &T { &**self }
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<Sized? T> DerefMut for Box<T> {
|
||||
impl<T: ?Sized> DerefMut for Box<T> {
|
||||
fn deref_mut(&mut self) -> &mut T { &mut **self }
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ pub struct Values<'a, K: 'a, V: 'a> {
|
||||
|
||||
#[stable]
|
||||
/// A view into a single entry in a map, which may either be vacant or occupied.
|
||||
pub enum Entry<'a, Sized? Q:'a, K:'a, V:'a> {
|
||||
pub enum Entry<'a, Q: ?Sized +'a, K:'a, V:'a> {
|
||||
/// A vacant Entry
|
||||
Vacant(VacantEntry<'a, Q, K, V>),
|
||||
/// An occupied Entry
|
||||
@ -139,7 +139,7 @@ pub enum Entry<'a, Sized? Q:'a, K:'a, V:'a> {
|
||||
|
||||
#[stable]
|
||||
/// A vacant Entry.
|
||||
pub struct VacantEntry<'a, Sized? Q:'a, K:'a, V:'a> {
|
||||
pub struct VacantEntry<'a, Q: ?Sized +'a, K:'a, V:'a> {
|
||||
key: &'a Q,
|
||||
stack: stack::SearchStack<'a, K, V, node::handle::Edge, node::handle::Leaf>,
|
||||
}
|
||||
@ -214,7 +214,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
|
||||
/// assert_eq!(map.get(&2), None);
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn get<Sized? Q>(&self, key: &Q) -> Option<&V> where Q: BorrowFrom<K> + Ord {
|
||||
pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V> where Q: BorrowFrom<K> + Ord {
|
||||
let mut cur_node = &self.root;
|
||||
loop {
|
||||
match Node::search(cur_node, key) {
|
||||
@ -246,7 +246,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
|
||||
/// assert_eq!(map.contains_key(&2), false);
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn contains_key<Sized? Q>(&self, key: &Q) -> bool where Q: BorrowFrom<K> + Ord {
|
||||
pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool where Q: BorrowFrom<K> + Ord {
|
||||
self.get(key).is_some()
|
||||
}
|
||||
|
||||
@ -270,7 +270,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
|
||||
/// ```
|
||||
// See `get` for implementation notes, this is basically a copy-paste with mut's added
|
||||
#[stable]
|
||||
pub fn get_mut<Sized? Q>(&mut self, key: &Q) -> Option<&mut V> where Q: BorrowFrom<K> + Ord {
|
||||
pub fn get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut V> where Q: BorrowFrom<K> + Ord {
|
||||
// temp_node is a Borrowck hack for having a mutable value outlive a loop iteration
|
||||
let mut temp_node = &mut self.root;
|
||||
loop {
|
||||
@ -440,7 +440,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
|
||||
/// assert_eq!(map.remove(&1), None);
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn remove<Sized? Q>(&mut self, key: &Q) -> Option<V> where Q: BorrowFrom<K> + Ord {
|
||||
pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<V> where Q: BorrowFrom<K> + Ord {
|
||||
// See `swap` for a more thorough description of the stuff going on in here
|
||||
let mut stack = stack::PartialSearchStack::new(self);
|
||||
loop {
|
||||
@ -878,7 +878,7 @@ impl<K: Show, V: Show> Show for BTreeMap<K, V> {
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<K: Ord, Sized? Q, V> Index<Q> for BTreeMap<K, V>
|
||||
impl<K: Ord, Q: ?Sized, V> Index<Q> for BTreeMap<K, V>
|
||||
where Q: BorrowFrom<K> + Ord
|
||||
{
|
||||
type Output = V;
|
||||
@ -889,7 +889,7 @@ impl<K: Ord, Sized? Q, V> Index<Q> for BTreeMap<K, V>
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<K: Ord, Sized? Q, V> IndexMut<Q> for BTreeMap<K, V>
|
||||
impl<K: Ord, Q: ?Sized, V> IndexMut<Q> for BTreeMap<K, V>
|
||||
where Q: BorrowFrom<K> + Ord
|
||||
{
|
||||
type Output = V;
|
||||
@ -1111,7 +1111,7 @@ impl<'a, K, V> DoubleEndedIterator for Values<'a, K, V> {
|
||||
#[stable]
|
||||
impl<'a, K, V> ExactSizeIterator for Values<'a, K, V> {}
|
||||
|
||||
impl<'a, Sized? Q, K: Ord, V> Entry<'a, Q, K, V> {
|
||||
impl<'a, Q: ?Sized, K: Ord, V> Entry<'a, Q, K, V> {
|
||||
#[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
|
||||
/// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant
|
||||
pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, Q, K, V>> {
|
||||
@ -1122,7 +1122,7 @@ impl<'a, Sized? Q, K: Ord, V> Entry<'a, Q, K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Sized? Q: ToOwned<K>, K: Ord, V> VacantEntry<'a, Q, K, V> {
|
||||
impl<'a, Q: ?Sized + ToOwned<K>, K: Ord, V> VacantEntry<'a, Q, K, V> {
|
||||
#[stable]
|
||||
/// Sets the value of the entry with the VacantEntry's key,
|
||||
/// and returns a mutable reference to it.
|
||||
@ -1362,7 +1362,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
|
||||
/// ```
|
||||
/// The key must have the same ordering before or after `.to_owned()` is called.
|
||||
#[stable]
|
||||
pub fn entry<'a, Sized? Q>(&'a mut self, mut key: &'a Q) -> Entry<'a, Q, K, V>
|
||||
pub fn entry<'a, Q: ?Sized>(&'a mut self, mut key: &'a Q) -> Entry<'a, Q, K, V>
|
||||
where Q: Ord + ToOwned<K>
|
||||
{
|
||||
// same basic logic of `swap` and `pop`, blended together
|
||||
|
@ -517,7 +517,7 @@ impl<K: Ord, V> Node<K, V> {
|
||||
/// Searches for the given key in the node. If it finds an exact match,
|
||||
/// `Found` will be yielded with the matching index. If it doesn't find an exact match,
|
||||
/// `GoDown` will be yielded with the index of the subtree the key must lie in.
|
||||
pub fn search<Sized? Q, NodeRef: Deref<Target=Node<K, V>>>(node: NodeRef, key: &Q)
|
||||
pub fn search<Q: ?Sized, NodeRef: Deref<Target=Node<K, V>>>(node: NodeRef, key: &Q)
|
||||
-> SearchResult<NodeRef> where Q: BorrowFrom<K> + Ord {
|
||||
// FIXME(Gankro): Tune when to search linear or binary based on B (and maybe K/V).
|
||||
// For the B configured as of this writing (B = 6), binary search was *significantly*
|
||||
@ -536,7 +536,7 @@ impl<K: Ord, V> Node<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
fn search_linear<Sized? Q>(&self, key: &Q) -> (bool, uint) where Q: BorrowFrom<K> + Ord {
|
||||
fn search_linear<Q: ?Sized>(&self, key: &Q) -> (bool, uint) where Q: BorrowFrom<K> + Ord {
|
||||
for (i, k) in self.keys().iter().enumerate() {
|
||||
match key.cmp(BorrowFrom::borrow_from(k)) {
|
||||
Greater => {},
|
||||
|
@ -299,7 +299,7 @@ impl<T: Ord> BTreeSet<T> {
|
||||
/// assert_eq!(set.contains(&4), false);
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn contains<Sized? Q>(&self, value: &Q) -> bool where Q: BorrowFrom<T> + Ord {
|
||||
pub fn contains<Q: ?Sized>(&self, value: &Q) -> bool where Q: BorrowFrom<T> + Ord {
|
||||
self.map.contains_key(value)
|
||||
}
|
||||
|
||||
@ -429,7 +429,7 @@ impl<T: Ord> BTreeSet<T> {
|
||||
/// assert_eq!(set.remove(&2), false);
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn remove<Sized? Q>(&mut self, value: &Q) -> bool where Q: BorrowFrom<T> + Ord {
|
||||
pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool where Q: BorrowFrom<T> + Ord {
|
||||
self.map.remove(value).is_some()
|
||||
}
|
||||
}
|
||||
|
@ -1008,7 +1008,7 @@ impl<T: Ord> OrdSliceExt<T> for [T] {
|
||||
|
||||
#[unstable = "U should be an associated type"]
|
||||
/// An extension trait for concatenating slices
|
||||
pub trait SliceConcatExt<Sized? T, U> {
|
||||
pub trait SliceConcatExt<T: ?Sized, U> {
|
||||
/// Flattens a slice of `T` into a single value `U`.
|
||||
#[stable]
|
||||
fn concat(&self) -> U;
|
||||
|
@ -54,39 +54,39 @@ use self::Cow::*;
|
||||
|
||||
/// A trait for borrowing data.
|
||||
#[old_orphan_check]
|
||||
pub trait BorrowFrom<Sized? Owned> {
|
||||
pub trait BorrowFrom<Owned: ?Sized> {
|
||||
/// Immutably borrow from an owned value.
|
||||
fn borrow_from(owned: &Owned) -> &Self;
|
||||
}
|
||||
|
||||
/// A trait for mutably borrowing data.
|
||||
#[old_orphan_check]
|
||||
pub trait BorrowFromMut<Sized? Owned> : BorrowFrom<Owned> {
|
||||
pub trait BorrowFromMut<Owned: ?Sized> : BorrowFrom<Owned> {
|
||||
/// Mutably borrow from an owned value.
|
||||
fn borrow_from_mut(owned: &mut Owned) -> &mut Self;
|
||||
}
|
||||
|
||||
impl<Sized? T> BorrowFrom<T> for T {
|
||||
impl<T: ?Sized> BorrowFrom<T> for T {
|
||||
fn borrow_from(owned: &T) -> &T { owned }
|
||||
}
|
||||
|
||||
impl<Sized? T> BorrowFromMut<T> for T {
|
||||
impl<T: ?Sized> BorrowFromMut<T> for T {
|
||||
fn borrow_from_mut(owned: &mut T) -> &mut T { owned }
|
||||
}
|
||||
|
||||
impl<'a, Sized? T> BorrowFrom<&'a T> for T {
|
||||
impl<'a, T: ?Sized> BorrowFrom<&'a T> for T {
|
||||
fn borrow_from<'b>(owned: &'b &'a T) -> &'b T { &**owned }
|
||||
}
|
||||
|
||||
impl<'a, Sized? T> BorrowFrom<&'a mut T> for T {
|
||||
impl<'a, T: ?Sized> BorrowFrom<&'a mut T> for T {
|
||||
fn borrow_from<'b>(owned: &'b &'a mut T) -> &'b T { &**owned }
|
||||
}
|
||||
|
||||
impl<'a, Sized? T> BorrowFromMut<&'a mut T> for T {
|
||||
impl<'a, T: ?Sized> BorrowFromMut<&'a mut T> for T {
|
||||
fn borrow_from_mut<'b>(owned: &'b mut &'a mut T) -> &'b mut T { &mut **owned }
|
||||
}
|
||||
|
||||
impl<'a, T, Sized? B> BorrowFrom<Cow<'a, T, B>> for B where B: ToOwned<T> {
|
||||
impl<'a, T, B: ?Sized> BorrowFrom<Cow<'a, T, B>> for B where B: ToOwned<T> {
|
||||
fn borrow_from<'b>(owned: &'b Cow<'a, T, B>) -> &'b B {
|
||||
&**owned
|
||||
}
|
||||
@ -94,12 +94,12 @@ impl<'a, T, Sized? B> BorrowFrom<Cow<'a, T, B>> for B where B: ToOwned<T> {
|
||||
|
||||
/// Trait for moving into a `Cow`
|
||||
#[old_orphan_check]
|
||||
pub trait IntoCow<'a, T, Sized? B> {
|
||||
pub trait IntoCow<'a, T, B: ?Sized> {
|
||||
/// Moves `self` into `Cow`
|
||||
fn into_cow(self) -> Cow<'a, T, B>;
|
||||
}
|
||||
|
||||
impl<'a, T, Sized? B> IntoCow<'a, T, B> for Cow<'a, T, B> where B: ToOwned<T> {
|
||||
impl<'a, T, B: ?Sized> IntoCow<'a, T, B> for Cow<'a, T, B> where B: ToOwned<T> {
|
||||
fn into_cow(self) -> Cow<'a, T, B> {
|
||||
self
|
||||
}
|
||||
@ -133,7 +133,7 @@ impl<T> ToOwned<T> for T where T: Clone {
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
pub enum Cow<'a, T, Sized? B: 'a> where B: ToOwned<T> {
|
||||
pub enum Cow<'a, T, B: ?Sized + 'a> where B: ToOwned<T> {
|
||||
/// Borrowed data.
|
||||
Borrowed(&'a B),
|
||||
|
||||
@ -142,7 +142,7 @@ pub enum Cow<'a, T, Sized? B: 'a> where B: ToOwned<T> {
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, T, Sized? B> Clone for Cow<'a, T, B> where B: ToOwned<T> {
|
||||
impl<'a, T, B: ?Sized> Clone for Cow<'a, T, B> where B: ToOwned<T> {
|
||||
fn clone(&self) -> Cow<'a, T, B> {
|
||||
match *self {
|
||||
Borrowed(b) => Borrowed(b),
|
||||
@ -154,7 +154,7 @@ impl<'a, T, Sized? B> Clone for Cow<'a, T, B> where B: ToOwned<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T, Sized? B> Cow<'a, T, B> where B: ToOwned<T> {
|
||||
impl<'a, T, B: ?Sized> Cow<'a, T, B> where B: ToOwned<T> {
|
||||
/// Acquire a mutable reference to the owned form of the data.
|
||||
///
|
||||
/// Copies the data if it is not already owned.
|
||||
@ -196,7 +196,7 @@ impl<'a, T, Sized? B> Cow<'a, T, B> where B: ToOwned<T> {
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, T, Sized? B> Deref for Cow<'a, T, B> where B: ToOwned<T> {
|
||||
impl<'a, T, B: ?Sized> Deref for Cow<'a, T, B> where B: ToOwned<T> {
|
||||
type Target = B;
|
||||
|
||||
fn deref(&self) -> &B {
|
||||
@ -208,10 +208,10 @@ impl<'a, T, Sized? B> Deref for Cow<'a, T, B> where B: ToOwned<T> {
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, T, Sized? B> Eq for Cow<'a, T, B> where B: Eq + ToOwned<T> {}
|
||||
impl<'a, T, B: ?Sized> Eq for Cow<'a, T, B> where B: Eq + ToOwned<T> {}
|
||||
|
||||
#[stable]
|
||||
impl<'a, T, Sized? B> Ord for Cow<'a, T, B> where B: Ord + ToOwned<T> {
|
||||
impl<'a, T, B: ?Sized> Ord for Cow<'a, T, B> where B: Ord + ToOwned<T> {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &Cow<'a, T, B>) -> Ordering {
|
||||
Ord::cmp(&**self, &**other)
|
||||
@ -219,7 +219,7 @@ impl<'a, T, Sized? B> Ord for Cow<'a, T, B> where B: Ord + ToOwned<T> {
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, 'b, T, U, Sized? B, Sized? C> PartialEq<Cow<'b, U, C>> for Cow<'a, T, B> where
|
||||
impl<'a, 'b, T, U, B: ?Sized, C: ?Sized> PartialEq<Cow<'b, U, C>> for Cow<'a, T, B> where
|
||||
B: PartialEq<C> + ToOwned<T>,
|
||||
C: ToOwned<U>,
|
||||
{
|
||||
@ -230,14 +230,14 @@ impl<'a, 'b, T, U, Sized? B, Sized? C> PartialEq<Cow<'b, U, C>> for Cow<'a, T, B
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, T, Sized? B> PartialOrd for Cow<'a, T, B> where B: PartialOrd + ToOwned<T> {
|
||||
impl<'a, T, B: ?Sized> PartialOrd for Cow<'a, T, B> where B: PartialOrd + ToOwned<T> {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &Cow<'a, T, B>) -> Option<Ordering> {
|
||||
PartialOrd::partial_cmp(&**self, &**other)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T, Sized? B> fmt::Show for Cow<'a, T, B> where B: fmt::Show + ToOwned<T>, T: fmt::Show {
|
||||
impl<'a, T, B: ?Sized> fmt::Show for Cow<'a, T, B> where B: fmt::Show + ToOwned<T>, T: fmt::Show {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
Borrowed(ref b) => fmt::Show::fmt(b, f),
|
||||
|
@ -43,7 +43,7 @@ pub trait Clone : Sized {
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, Sized? T> Clone for &'a T {
|
||||
impl<'a, T: ?Sized> Clone for &'a T {
|
||||
/// Return a shallow copy of the reference.
|
||||
#[inline]
|
||||
fn clone(&self) -> &'a T { *self }
|
||||
|
@ -70,7 +70,7 @@ use option::Option::{self, Some, None};
|
||||
#[lang="eq"]
|
||||
#[stable]
|
||||
#[old_orphan_check]
|
||||
pub trait PartialEq<Sized? Rhs = Self> {
|
||||
pub trait PartialEq<Rhs: ?Sized = Self> {
|
||||
/// This method tests for `self` and `other` values to be equal, and is used by `==`.
|
||||
#[stable]
|
||||
fn eq(&self, other: &Rhs) -> bool;
|
||||
@ -225,7 +225,7 @@ impl PartialOrd for Ordering {
|
||||
/// 5.11).
|
||||
#[lang="ord"]
|
||||
#[stable]
|
||||
pub trait PartialOrd<Sized? Rhs = Self>: PartialEq<Rhs> {
|
||||
pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
|
||||
/// This method returns an ordering between `self` and `other` values
|
||||
/// if one exists.
|
||||
#[stable]
|
||||
@ -429,14 +429,14 @@ mod impls {
|
||||
// & pointers
|
||||
|
||||
#[stable]
|
||||
impl<'a, 'b, Sized? A, Sized? B> PartialEq<&'b B> for &'a A where A: PartialEq<B> {
|
||||
impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b B> for &'a A where A: PartialEq<B> {
|
||||
#[inline]
|
||||
fn eq(&self, other: & &'b B) -> bool { PartialEq::eq(*self, *other) }
|
||||
#[inline]
|
||||
fn ne(&self, other: & &'b B) -> bool { PartialEq::ne(*self, *other) }
|
||||
}
|
||||
#[stable]
|
||||
impl<'a, 'b, Sized? A, Sized? B> PartialOrd<&'b B> for &'a A where A: PartialOrd<B> {
|
||||
impl<'a, 'b, A: ?Sized, B: ?Sized> PartialOrd<&'b B> for &'a A where A: PartialOrd<B> {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &&'b B) -> Option<Ordering> {
|
||||
PartialOrd::partial_cmp(*self, *other)
|
||||
@ -451,24 +451,24 @@ mod impls {
|
||||
fn gt(&self, other: & &'b B) -> bool { PartialOrd::gt(*self, *other) }
|
||||
}
|
||||
#[stable]
|
||||
impl<'a, Sized? A> Ord for &'a A where A: Ord {
|
||||
impl<'a, A: ?Sized> Ord for &'a A where A: Ord {
|
||||
#[inline]
|
||||
fn cmp(&self, other: & &'a A) -> Ordering { Ord::cmp(*self, *other) }
|
||||
}
|
||||
#[stable]
|
||||
impl<'a, Sized? A> Eq for &'a A where A: Eq {}
|
||||
impl<'a, A: ?Sized> Eq for &'a A where A: Eq {}
|
||||
|
||||
// &mut pointers
|
||||
|
||||
#[stable]
|
||||
impl<'a, 'b, Sized? A, Sized? B> PartialEq<&'b mut B> for &'a mut A where A: PartialEq<B> {
|
||||
impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b mut B> for &'a mut A where A: PartialEq<B> {
|
||||
#[inline]
|
||||
fn eq(&self, other: &&'b mut B) -> bool { PartialEq::eq(*self, *other) }
|
||||
#[inline]
|
||||
fn ne(&self, other: &&'b mut B) -> bool { PartialEq::ne(*self, *other) }
|
||||
}
|
||||
#[stable]
|
||||
impl<'a, 'b, Sized? A, Sized? B> PartialOrd<&'b mut B> for &'a mut A where A: PartialOrd<B> {
|
||||
impl<'a, 'b, A: ?Sized, B: ?Sized> PartialOrd<&'b mut B> for &'a mut A where A: PartialOrd<B> {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &&'b mut B) -> Option<Ordering> {
|
||||
PartialOrd::partial_cmp(*self, *other)
|
||||
@ -483,15 +483,15 @@ mod impls {
|
||||
fn gt(&self, other: &&'b mut B) -> bool { PartialOrd::gt(*self, *other) }
|
||||
}
|
||||
#[stable]
|
||||
impl<'a, Sized? A> Ord for &'a mut A where A: Ord {
|
||||
impl<'a, A: ?Sized> Ord for &'a mut A where A: Ord {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &&'a mut A) -> Ordering { Ord::cmp(*self, *other) }
|
||||
}
|
||||
#[stable]
|
||||
impl<'a, Sized? A> Eq for &'a mut A where A: Eq {}
|
||||
impl<'a, A: ?Sized> Eq for &'a mut A where A: Eq {}
|
||||
|
||||
#[stable]
|
||||
impl<'a, 'b, Sized? A, Sized? B> PartialEq<&'b mut B> for &'a A where A: PartialEq<B> {
|
||||
impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b mut B> for &'a A where A: PartialEq<B> {
|
||||
#[inline]
|
||||
fn eq(&self, other: &&'b mut B) -> bool { PartialEq::eq(*self, *other) }
|
||||
#[inline]
|
||||
@ -499,7 +499,7 @@ mod impls {
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, 'b, Sized? A, Sized? B> PartialEq<&'b B> for &'a mut A where A: PartialEq<B> {
|
||||
impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b B> for &'a mut A where A: PartialEq<B> {
|
||||
#[inline]
|
||||
fn eq(&self, other: &&'b B) -> bool { PartialEq::eq(*self, *other) }
|
||||
#[inline]
|
||||
|
@ -78,9 +78,9 @@ pub trait Writer {
|
||||
// This Adapter is needed to allow `self` (of type `&mut
|
||||
// Self`) to be cast to a FormatWriter (below) without
|
||||
// requiring a `Sized` bound.
|
||||
struct Adapter<'a,Sized? T:'a>(&'a mut T);
|
||||
struct Adapter<'a,T: ?Sized +'a>(&'a mut T);
|
||||
|
||||
impl<'a, Sized? T> Writer for Adapter<'a, T>
|
||||
impl<'a, T: ?Sized> Writer for Adapter<'a, T>
|
||||
where T: Writer
|
||||
{
|
||||
fn write_str(&mut self, s: &str) -> Result {
|
||||
@ -592,10 +592,10 @@ pub fn argumentuint<'a>(s: &'a uint) -> Argument<'a> {
|
||||
|
||||
// Implementations of the core formatting traits
|
||||
|
||||
impl<'a, Sized? T: Show> Show for &'a T {
|
||||
impl<'a, T: ?Sized + Show> Show for &'a T {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result { (**self).fmt(f) }
|
||||
}
|
||||
impl<'a, Sized? T: Show> Show for &'a mut T {
|
||||
impl<'a, T: ?Sized + Show> Show for &'a mut T {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result { (**self).fmt(f) }
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ pub trait Hash<S = sip::SipState> {
|
||||
/// containers like `HashMap`, which need a generic way hash multiple types.
|
||||
pub trait Hasher<S> {
|
||||
/// Compute the hash of a value.
|
||||
fn hash<Sized? T: Hash<S>>(&self, value: &T) -> u64;
|
||||
fn hash<T: ?Sized + Hash<S>>(&self, value: &T) -> u64;
|
||||
}
|
||||
|
||||
#[allow(missing_docs)]
|
||||
@ -194,14 +194,14 @@ impl<S: Writer, T: Hash<S>> Hash<S> for [T] {
|
||||
}
|
||||
|
||||
|
||||
impl<'a, S: Writer, Sized? T: Hash<S>> Hash<S> for &'a T {
|
||||
impl<'a, S: Writer, T: ?Sized + Hash<S>> Hash<S> for &'a T {
|
||||
#[inline]
|
||||
fn hash(&self, state: &mut S) {
|
||||
(**self).hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, S: Writer, Sized? T: Hash<S>> Hash<S> for &'a mut T {
|
||||
impl<'a, S: Writer, T: ?Sized + Hash<S>> Hash<S> for &'a mut T {
|
||||
#[inline]
|
||||
fn hash(&self, state: &mut S) {
|
||||
(**self).hash(state);
|
||||
@ -233,7 +233,7 @@ impl<S: Writer> Hash<S> for TypeId {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T, Sized? B, S> Hash<S> for Cow<'a, T, B> where B: Hash<S> + ToOwned<T> {
|
||||
impl<'a, T, B: ?Sized, S> Hash<S> for Cow<'a, T, B> where B: Hash<S> + ToOwned<T> {
|
||||
#[inline]
|
||||
fn hash(&self, state: &mut S) {
|
||||
Hash::hash(&**self, state)
|
||||
|
@ -239,7 +239,7 @@ impl SipHasher {
|
||||
|
||||
impl Hasher<SipState> for SipHasher {
|
||||
#[inline]
|
||||
fn hash<Sized? T: Hash<SipState>>(&self, value: &T) -> u64 {
|
||||
fn hash<T: ?Sized + Hash<SipState>>(&self, value: &T) -> u64 {
|
||||
let mut state = SipState::new_with_keys(self.k0, self.k1);
|
||||
value.hash(&mut state);
|
||||
state.result()
|
||||
@ -255,7 +255,7 @@ impl Default for SipHasher {
|
||||
|
||||
/// Hashes a value using the SipHash algorithm.
|
||||
#[inline]
|
||||
pub fn hash<Sized? T: Hash<SipState>>(value: &T) -> u64 {
|
||||
pub fn hash<T: ?Sized + Hash<SipState>>(value: &T) -> u64 {
|
||||
let mut state = SipState::new();
|
||||
value.hash(&mut state);
|
||||
state.result()
|
||||
@ -263,7 +263,7 @@ pub fn hash<Sized? T: Hash<SipState>>(value: &T) -> u64 {
|
||||
|
||||
/// Hashes a value with the SipHash algorithm with the provided keys.
|
||||
#[inline]
|
||||
pub fn hash_with_keys<Sized? T: Hash<SipState>>(k0: u64, k1: u64, value: &T) -> u64 {
|
||||
pub fn hash_with_keys<T: ?Sized + Hash<SipState>>(k0: u64, k1: u64, value: &T) -> u64 {
|
||||
let mut state = SipState::new_with_keys(k0, k1);
|
||||
value.hash(&mut state);
|
||||
state.result()
|
||||
|
@ -133,10 +133,10 @@ pub mod marker {
|
||||
/// for some lifetime `'a`, but not the other way around).
|
||||
#[lang="covariant_type"]
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct CovariantType<Sized? T>;
|
||||
pub struct CovariantType<T: ?Sized>;
|
||||
|
||||
impl<Sized? T> Copy for CovariantType<T> {}
|
||||
impl<Sized? T> Clone for CovariantType<T> {
|
||||
impl<T: ?Sized> Copy for CovariantType<T> {}
|
||||
impl<T: ?Sized> Clone for CovariantType<T> {
|
||||
fn clone(&self) -> CovariantType<T> { *self }
|
||||
}
|
||||
|
||||
@ -181,10 +181,10 @@ pub mod marker {
|
||||
/// arguments of type `U`, hence such a conversion is safe.
|
||||
#[lang="contravariant_type"]
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct ContravariantType<Sized? T>;
|
||||
pub struct ContravariantType<T: ?Sized>;
|
||||
|
||||
impl<Sized? T> Copy for ContravariantType<T> {}
|
||||
impl<Sized? T> Clone for ContravariantType<T> {
|
||||
impl<T: ?Sized> Copy for ContravariantType<T> {}
|
||||
impl<T: ?Sized> Clone for ContravariantType<T> {
|
||||
fn clone(&self) -> ContravariantType<T> { *self }
|
||||
}
|
||||
|
||||
@ -211,10 +211,10 @@ pub mod marker {
|
||||
/// interior mutability.
|
||||
#[lang="invariant_type"]
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct InvariantType<Sized? T>;
|
||||
pub struct InvariantType<T: ?Sized>;
|
||||
|
||||
impl<Sized? T> Copy for InvariantType<T> {}
|
||||
impl<Sized? T> Clone for InvariantType<T> {
|
||||
impl<T: ?Sized> Copy for InvariantType<T> {}
|
||||
impl<T: ?Sized> Clone for InvariantType<T> {
|
||||
fn clone(&self) -> InvariantType<T> { *self }
|
||||
}
|
||||
|
||||
|
@ -320,7 +320,7 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
|
||||
#[inline]
|
||||
#[unstable = "this function may be removed in the future due to its \
|
||||
questionable utility"]
|
||||
pub unsafe fn copy_lifetime<'a, Sized? S, Sized? T: 'a>(_ptr: &'a S,
|
||||
pub unsafe fn copy_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a S,
|
||||
ptr: &T) -> &'a T {
|
||||
transmute(ptr)
|
||||
}
|
||||
@ -329,7 +329,7 @@ pub unsafe fn copy_lifetime<'a, Sized? S, Sized? T: 'a>(_ptr: &'a S,
|
||||
#[inline]
|
||||
#[unstable = "this function may be removed in the future due to its \
|
||||
questionable utility"]
|
||||
pub unsafe fn copy_mut_lifetime<'a, Sized? S, Sized? T: 'a>(_ptr: &'a mut S,
|
||||
pub unsafe fn copy_mut_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a mut S,
|
||||
ptr: &mut T)
|
||||
-> &'a mut T {
|
||||
transmute(ptr)
|
||||
|
@ -802,8 +802,8 @@ shr_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 }
|
||||
/// }
|
||||
/// ```
|
||||
#[lang="index"]
|
||||
pub trait Index<Sized? Index> {
|
||||
type Sized? Output;
|
||||
pub trait Index<Index: ?Sized> {
|
||||
type Output: ?Sized;
|
||||
|
||||
/// The method for the indexing (`Foo[Bar]`) operation
|
||||
fn index<'a>(&'a self, index: &Index) -> &'a Self::Output;
|
||||
@ -839,8 +839,8 @@ pub trait Index<Sized? Index> {
|
||||
/// }
|
||||
/// ```
|
||||
#[lang="index_mut"]
|
||||
pub trait IndexMut<Sized? Index> {
|
||||
type Sized? Output;
|
||||
pub trait IndexMut<Index: ?Sized> {
|
||||
type Output: ?Sized;
|
||||
|
||||
/// The method for the indexing (`Foo[Bar]`) operation
|
||||
fn index_mut<'a>(&'a mut self, index: &Index) -> &'a mut Self::Output;
|
||||
@ -884,7 +884,7 @@ pub trait IndexMut<Sized? Index> {
|
||||
/// }
|
||||
/// ```
|
||||
#[lang="slice"]
|
||||
pub trait Slice<Sized? Idx, Sized? Result> {
|
||||
pub trait Slice<Idx: ?Sized, Result: ?Sized> {
|
||||
/// The method for the slicing operation foo[]
|
||||
fn as_slice_<'a>(&'a self) -> &'a Result;
|
||||
/// The method for the slicing operation foo[from..]
|
||||
@ -933,7 +933,7 @@ pub trait Slice<Sized? Idx, Sized? Result> {
|
||||
/// }
|
||||
/// ```
|
||||
#[lang="slice_mut"]
|
||||
pub trait SliceMut<Sized? Idx, Sized? Result> {
|
||||
pub trait SliceMut<Idx: ?Sized, Result: ?Sized> {
|
||||
/// The method for the slicing operation foo[]
|
||||
fn as_mut_slice_<'a>(&'a mut self) -> &'a mut Result;
|
||||
/// The method for the slicing operation foo[from..]
|
||||
@ -1071,7 +1071,7 @@ pub struct RangeTo<Idx> {
|
||||
#[stable]
|
||||
pub trait Deref {
|
||||
#[stable]
|
||||
type Sized? Target;
|
||||
type Target: ?Sized;
|
||||
|
||||
/// The method called to dereference a value
|
||||
#[stable]
|
||||
@ -1079,14 +1079,14 @@ pub trait Deref {
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, Sized? T> Deref for &'a T {
|
||||
impl<'a, T: ?Sized> Deref for &'a T {
|
||||
type Target = T;
|
||||
|
||||
fn deref(&self) -> &T { *self }
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, Sized? T> Deref for &'a mut T {
|
||||
impl<'a, T: ?Sized> Deref for &'a mut T {
|
||||
type Target = T;
|
||||
|
||||
fn deref(&self) -> &T { *self }
|
||||
@ -1138,7 +1138,7 @@ pub trait DerefMut: Deref {
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, Sized? T> DerefMut for &'a mut T {
|
||||
impl<'a, T: ?Sized> DerefMut for &'a mut T {
|
||||
fn deref_mut(&mut self) -> &mut T { *self }
|
||||
}
|
||||
|
||||
@ -1166,8 +1166,8 @@ pub trait FnOnce<Args,Result> {
|
||||
extern "rust-call" fn call_once(self, args: Args) -> Result;
|
||||
}
|
||||
|
||||
impl<Sized? F,A,R> FnMut<A,R> for F
|
||||
where F : Fn<A,R>
|
||||
impl<F: ?Sized, A, R> FnMut<A, R> for F
|
||||
where F : Fn<A, R>
|
||||
{
|
||||
extern "rust-call" fn call_mut(&mut self, args: A) -> R {
|
||||
self.call(args)
|
||||
|
@ -626,13 +626,13 @@ impl<T> AsSlice<T> for [T] {
|
||||
}
|
||||
|
||||
#[experimental = "trait is experimental"]
|
||||
impl<'a, T, Sized? U: AsSlice<T>> AsSlice<T> for &'a U {
|
||||
impl<'a, T, U: ?Sized + AsSlice<T>> AsSlice<T> for &'a U {
|
||||
#[inline(always)]
|
||||
fn as_slice(&self) -> &[T] { AsSlice::as_slice(*self) }
|
||||
}
|
||||
|
||||
#[experimental = "trait is experimental"]
|
||||
impl<'a, T, Sized? U: AsSlice<T>> AsSlice<T> for &'a mut U {
|
||||
impl<'a, T, U: ?Sized + AsSlice<T>> AsSlice<T> for &'a mut U {
|
||||
#[inline(always)]
|
||||
fn as_slice(&self) -> &[T] { AsSlice::as_slice(*self) }
|
||||
}
|
||||
|
@ -1155,7 +1155,7 @@ impl Str for str {
|
||||
fn as_slice<'a>(&'a self) -> &'a str { self }
|
||||
}
|
||||
|
||||
impl<'a, Sized? S> Str for &'a S where S: Str {
|
||||
impl<'a, S: ?Sized> Str for &'a S where S: Str {
|
||||
#[inline]
|
||||
fn as_slice(&self) -> &str { Str::as_slice(*self) }
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ use core::hash::{Hash, Hasher, Writer};
|
||||
struct MyWriterHasher;
|
||||
|
||||
impl Hasher<MyWriter> for MyWriterHasher {
|
||||
fn hash<Sized? T: Hash<MyWriter>>(&self, value: &T) -> u64 {
|
||||
fn hash<T: ?Sized + Hash<MyWriter>>(&self, value: &T) -> u64 {
|
||||
let mut state = MyWriter { hash: 0 };
|
||||
value.hash(&mut state);
|
||||
state.hash
|
||||
|
@ -25,7 +25,7 @@ use std::slice;
|
||||
|
||||
// Note 2: Once Dynamically Sized Types (DST) lands, it might be
|
||||
// reasonable to replace this with something like `enum MaybeOwned<'a,
|
||||
// Sized? U>{ Owned(Box<U>), Borrowed(&'a U) }`; and then `U` could be
|
||||
// U: ?Sized>{ Owned(Box<U>), Borrowed(&'a U) }`; and then `U` could be
|
||||
// instantiated with `[T]` or `str`, etc. Of course, that would imply
|
||||
// removing the `Growable` variant, which relates to note 1 above.
|
||||
// Alternatively, we might add `MaybeOwned` for the general case but
|
||||
|
@ -121,7 +121,7 @@ impl<'a, 'tcx> IntrinsicCheckingVisitor<'a, 'tcx> {
|
||||
// However, it's not as simple as checking whether `T :
|
||||
// Sized`, because even if `T : Sized` does not hold, that
|
||||
// just means that `T` *may* not be sized. After all, even a
|
||||
// type parameter `Sized? T` could be bound to a sized
|
||||
// type parameter `T: ?Sized` could be bound to a sized
|
||||
// type. (Issue #20116)
|
||||
//
|
||||
// To handle this, we first check for "interior" type
|
||||
@ -139,16 +139,16 @@ impl<'a, 'tcx> IntrinsicCheckingVisitor<'a, 'tcx> {
|
||||
// exhaustively checking all possible combinations. Here are some examples:
|
||||
//
|
||||
// ```
|
||||
// fn foo<T,U>() {
|
||||
// fn foo<T, U>() {
|
||||
// // T=int, U=int
|
||||
// }
|
||||
//
|
||||
// fn bar<Sized? T,U>() {
|
||||
// fn bar<T: ?Sized, U>() {
|
||||
// // T=int, U=int
|
||||
// // T=[int], U=int
|
||||
// }
|
||||
//
|
||||
// fn baz<Sized? T, Sized?U>() {
|
||||
// fn baz<T: ?Sized, U: ?Sized>() {
|
||||
// // T=int, U=int
|
||||
// // T=[int], U=int
|
||||
// // T=int, U=[int]
|
||||
|
@ -75,7 +75,7 @@ pub struct FnvHasher;
|
||||
pub struct FnvState(u64);
|
||||
|
||||
impl Hasher<FnvState> for FnvHasher {
|
||||
fn hash<Sized? T: Hash<FnvState>>(&self, t: &T) -> u64 {
|
||||
fn hash<T: ?Sized + Hash<FnvState>>(&self, t: &T) -> u64 {
|
||||
let mut state = FnvState(0xcbf29ce484222325);
|
||||
t.hash(&mut state);
|
||||
let FnvState(ret) = state;
|
||||
|
@ -601,7 +601,7 @@ impl<'tcx> Repr<'tcx> for () {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, Sized? T:Repr<'tcx>> Repr<'tcx> for &'a T {
|
||||
impl<'a, 'tcx, T: ?Sized +Repr<'tcx>> Repr<'tcx> for &'a T {
|
||||
fn repr(&self, tcx: &ctxt<'tcx>) -> String {
|
||||
Repr::repr(*self, tcx)
|
||||
}
|
||||
|
@ -396,13 +396,13 @@ impl Decodable for () {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Sized? T: Encodable> Encodable for &'a T {
|
||||
impl<'a, T: ?Sized + Encodable> Encodable for &'a T {
|
||||
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
(**self).encode(s)
|
||||
}
|
||||
}
|
||||
|
||||
impl<Sized? T: Encodable> Encodable for Box<T> {
|
||||
impl<T: ?Sized + Encodable> Encodable for Box<T> {
|
||||
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
(**self).encode(s)
|
||||
}
|
||||
|
@ -378,13 +378,13 @@ impl<E, D:Decoder<E>> Decodable<D, E> for () {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, E, S: Encoder<E>, Sized? T: Encodable<S, E>> Encodable<S, E> for &'a T {
|
||||
impl<'a, E, S: Encoder<E>, T: ?Sized + Encodable<S, E>> Encodable<S, E> for &'a T {
|
||||
fn encode(&self, s: &mut S) -> Result<(), E> {
|
||||
(**self).encode(s)
|
||||
}
|
||||
}
|
||||
|
||||
impl<E, S: Encoder<E>, Sized? T: Encodable<S, E>> Encodable<S, E> for Box<T> {
|
||||
impl<E, S: Encoder<E>, T: ?Sized + Encodable<S, E>> Encodable<S, E> for Box<T> {
|
||||
fn encode(&self, s: &mut S) -> Result<(), E> {
|
||||
(**self).encode(s)
|
||||
}
|
||||
|
@ -440,14 +440,14 @@ impl<K, V, M> SearchResult<K, V, M> {
|
||||
}
|
||||
|
||||
impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
|
||||
fn make_hash<Sized? X: Hash<S>>(&self, x: &X) -> SafeHash {
|
||||
fn make_hash<X: ?Sized + Hash<S>>(&self, x: &X) -> SafeHash {
|
||||
table::make_hash(&self.hasher, x)
|
||||
}
|
||||
|
||||
/// Search for a key, yielding the index if it's found in the hashtable.
|
||||
/// If you already have the hash for the key lying around, use
|
||||
/// search_hashed.
|
||||
fn search<'a, Sized? Q>(&'a self, q: &Q) -> Option<FullBucketImm<'a, K, V>>
|
||||
fn search<'a, Q: ?Sized>(&'a self, q: &Q) -> Option<FullBucketImm<'a, K, V>>
|
||||
where Q: BorrowFrom<K> + Eq + Hash<S>
|
||||
{
|
||||
let hash = self.make_hash(q);
|
||||
@ -455,7 +455,7 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
|
||||
.into_option()
|
||||
}
|
||||
|
||||
fn search_mut<'a, Sized? Q>(&'a mut self, q: &Q) -> Option<FullBucketMut<'a, K, V>>
|
||||
fn search_mut<'a, Q: ?Sized>(&'a mut self, q: &Q) -> Option<FullBucketMut<'a, K, V>>
|
||||
where Q: BorrowFrom<K> + Eq + Hash<S>
|
||||
{
|
||||
let hash = self.make_hash(q);
|
||||
@ -923,7 +923,7 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
|
||||
#[stable]
|
||||
/// Gets the given key's corresponding entry in the map for in-place manipulation.
|
||||
/// Regardless of whether or not `to_owned()` has been called, the key must hash the same way.
|
||||
pub fn entry<'a, Sized? Q>(&'a mut self, key: &'a Q) -> Entry<'a, Q, K, V>
|
||||
pub fn entry<'a, Q: ?Sized>(&'a mut self, key: &'a Q) -> Entry<'a, Q, K, V>
|
||||
where Q: Eq + Hash<S> + ToOwned<K>
|
||||
{
|
||||
// Gotta resize now.
|
||||
@ -1030,7 +1030,7 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
|
||||
/// assert_eq!(map.get(&2), None);
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn get<Sized? Q>(&self, k: &Q) -> Option<&V>
|
||||
pub fn get<Q: ?Sized>(&self, k: &Q) -> Option<&V>
|
||||
where Q: Hash<S> + Eq + BorrowFrom<K>
|
||||
{
|
||||
self.search(k).map(|bucket| bucket.into_refs().1)
|
||||
@ -1053,7 +1053,7 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
|
||||
/// assert_eq!(map.contains_key(&2), false);
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn contains_key<Sized? Q>(&self, k: &Q) -> bool
|
||||
pub fn contains_key<Q: ?Sized>(&self, k: &Q) -> bool
|
||||
where Q: Hash<S> + Eq + BorrowFrom<K>
|
||||
{
|
||||
self.search(k).is_some()
|
||||
@ -1079,7 +1079,7 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
|
||||
/// assert_eq!(map[1], "b");
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn get_mut<Sized? Q>(&mut self, k: &Q) -> Option<&mut V>
|
||||
pub fn get_mut<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut V>
|
||||
where Q: Hash<S> + Eq + BorrowFrom<K>
|
||||
{
|
||||
self.search_mut(k).map(|bucket| bucket.into_mut_refs().1)
|
||||
@ -1131,7 +1131,7 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
|
||||
/// assert_eq!(map.remove(&1), None);
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn remove<Sized? Q>(&mut self, k: &Q) -> Option<V>
|
||||
pub fn remove<Q: ?Sized>(&mut self, k: &Q) -> Option<V>
|
||||
where Q: Hash<S> + Eq + BorrowFrom<K>
|
||||
{
|
||||
if self.table.size() == 0 {
|
||||
@ -1142,7 +1142,7 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
|
||||
}
|
||||
}
|
||||
|
||||
fn search_entry_hashed<'a, K, V, Sized? Q>(table: &'a mut RawTable<K,V>, hash: SafeHash, k: &'a Q)
|
||||
fn search_entry_hashed<'a, K, V, Q: ?Sized>(table: &'a mut RawTable<K,V>, hash: SafeHash, k: &'a Q)
|
||||
-> Entry<'a, Q, K, V>
|
||||
where Q: Eq + ToOwned<K>
|
||||
{
|
||||
@ -1227,7 +1227,7 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S> + Default> Default for HashMap<K, V, H>
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<K: Hash<S> + Eq, Sized? Q, V, S, H: Hasher<S>> Index<Q> for HashMap<K, V, H>
|
||||
impl<K: Hash<S> + Eq, Q: ?Sized, V, S, H: Hasher<S>> Index<Q> for HashMap<K, V, H>
|
||||
where Q: BorrowFrom<K> + Hash<S> + Eq
|
||||
{
|
||||
type Output = V;
|
||||
@ -1239,7 +1239,7 @@ impl<K: Hash<S> + Eq, Sized? Q, V, S, H: Hasher<S>> Index<Q> for HashMap<K, V, H
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<K: Hash<S> + Eq, Sized? Q, V, S, H: Hasher<S>> IndexMut<Q> for HashMap<K, V, H>
|
||||
impl<K: Hash<S> + Eq, Q: ?Sized, V, S, H: Hasher<S>> IndexMut<Q> for HashMap<K, V, H>
|
||||
where Q: BorrowFrom<K> + Hash<S> + Eq
|
||||
{
|
||||
type Output = V;
|
||||
@ -1331,7 +1331,7 @@ pub struct OccupiedEntry<'a, K: 'a, V: 'a> {
|
||||
|
||||
#[stable]
|
||||
/// A view into a single empty location in a HashMap
|
||||
pub struct VacantEntry<'a, Sized? Q: 'a, K: 'a, V: 'a> {
|
||||
pub struct VacantEntry<'a, Q: ?Sized + 'a, K: 'a, V: 'a> {
|
||||
hash: SafeHash,
|
||||
key: &'a Q,
|
||||
elem: VacantEntryState<K, V, &'a mut RawTable<K, V>>,
|
||||
@ -1339,7 +1339,7 @@ pub struct VacantEntry<'a, Sized? Q: 'a, K: 'a, V: 'a> {
|
||||
|
||||
#[stable]
|
||||
/// A view into a single location in a map, which may be vacant or occupied
|
||||
pub enum Entry<'a, Sized? Q: 'a, K: 'a, V: 'a> {
|
||||
pub enum Entry<'a, Q: ?Sized + 'a, K: 'a, V: 'a> {
|
||||
/// An occupied Entry
|
||||
Occupied(OccupiedEntry<'a, K, V>),
|
||||
/// A vacant Entry
|
||||
@ -1409,7 +1409,7 @@ impl<'a, K: 'a, V: 'a> Iterator for Drain<'a, K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Sized? Q, K, V> Entry<'a, Q, K, V> {
|
||||
impl<'a, Q: ?Sized, K, V> Entry<'a, Q, K, V> {
|
||||
#[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
|
||||
/// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant
|
||||
pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, Q, K, V>> {
|
||||
@ -1455,7 +1455,7 @@ impl<'a, K, V> OccupiedEntry<'a, K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Sized? Q: 'a + ToOwned<K>, K: 'a, V: 'a> VacantEntry<'a, Q, K, V> {
|
||||
impl<'a, Q: ?Sized + 'a + ToOwned<K>, K: 'a, V: 'a> VacantEntry<'a, Q, K, V> {
|
||||
#[stable]
|
||||
/// Sets the value of the entry with the VacantEntry's key,
|
||||
/// and returns a mutable reference to it
|
||||
|
@ -451,7 +451,7 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
|
||||
/// assert_eq!(set.contains(&4), false);
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn contains<Sized? Q>(&self, value: &Q) -> bool
|
||||
pub fn contains<Q: ?Sized>(&self, value: &Q) -> bool
|
||||
where Q: BorrowFrom<T> + Hash<S> + Eq
|
||||
{
|
||||
self.map.contains_key(value)
|
||||
@ -561,7 +561,7 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
|
||||
/// assert_eq!(set.remove(&2), false);
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn remove<Sized? Q>(&mut self, value: &Q) -> bool
|
||||
pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool
|
||||
where Q: BorrowFrom<T> + Hash<S> + Eq
|
||||
{
|
||||
self.map.remove(value).is_some()
|
||||
|
@ -138,7 +138,7 @@ impl SafeHash {
|
||||
/// We need to remove hashes of 0. That's reserved for empty buckets.
|
||||
/// This function wraps up `hash_keyed` to be the only way outside this
|
||||
/// module to generate a SafeHash.
|
||||
pub fn make_hash<Sized? T: Hash<S>, S, H: Hasher<S>>(hasher: &H, t: &T) -> SafeHash {
|
||||
pub fn make_hash<T: ?Sized + Hash<S>, S, H: Hasher<S>>(hasher: &H, t: &T) -> SafeHash {
|
||||
// We need to avoid 0u64 in order to prevent collisions with
|
||||
// EMPTY_HASH. We can maintain our precious uniform distribution
|
||||
// of initial indexes by unconditionally setting the MSB,
|
||||
|
@ -90,7 +90,7 @@ impl RandomSipHasher {
|
||||
|
||||
impl Hasher<sip::SipState> for RandomSipHasher {
|
||||
#[inline]
|
||||
fn hash<Sized? T: Hash<sip::SipState>>(&self, value: &T) -> u64 {
|
||||
fn hash<T: ?Sized + Hash<sip::SipState>>(&self, value: &T) -> u64 {
|
||||
self.hasher.hash(value)
|
||||
}
|
||||
}
|
||||
|
@ -1012,12 +1012,12 @@ pub trait Writer {
|
||||
fn write_fmt(&mut self, fmt: fmt::Arguments) -> IoResult<()> {
|
||||
// Create a shim which translates a Writer to a fmt::Writer and saves
|
||||
// off I/O errors. instead of discarding them
|
||||
struct Adaptor<'a, Sized? T:'a> {
|
||||
struct Adaptor<'a, T: ?Sized +'a> {
|
||||
inner: &'a mut T,
|
||||
error: IoResult<()>,
|
||||
}
|
||||
|
||||
impl<'a, Sized? T: Writer> fmt::Writer for Adaptor<'a, T> {
|
||||
impl<'a, T: ?Sized + Writer> fmt::Writer for Adaptor<'a, T> {
|
||||
fn write_str(&mut self, s: &str) -> fmt::Result {
|
||||
match self.inner.write(s.as_bytes()) {
|
||||
Ok(()) => Ok(()),
|
||||
@ -1597,11 +1597,11 @@ pub trait Acceptor<T> {
|
||||
/// `Some`. The `Some` contains the `IoResult` representing whether the
|
||||
/// connection attempt was successful. A successful connection will be wrapped
|
||||
/// in `Ok`. A failed connection is represented as an `Err`.
|
||||
pub struct IncomingConnections<'a, Sized? A:'a> {
|
||||
pub struct IncomingConnections<'a, A: ?Sized +'a> {
|
||||
inc: &'a mut A,
|
||||
}
|
||||
|
||||
impl<'a, T, Sized? A: Acceptor<T>> Iterator for IncomingConnections<'a, A> {
|
||||
impl<'a, T, A: ?Sized + Acceptor<T>> Iterator for IncomingConnections<'a, A> {
|
||||
type Item = IoResult<T>;
|
||||
|
||||
fn next(&mut self) -> Option<IoResult<T>> {
|
||||
|
@ -896,7 +896,7 @@ impl BytesContainer for CString {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Sized? T: BytesContainer> BytesContainer for &'a T {
|
||||
impl<'a, T: ?Sized + BytesContainer> BytesContainer for &'a T {
|
||||
#[inline]
|
||||
fn container_as_bytes(&self) -> &[u8] {
|
||||
(**self).container_as_bytes()
|
||||
|
@ -321,7 +321,7 @@ impl Path {
|
||||
|
||||
/// Returns a normalized byte vector representation of a path, by removing all empty
|
||||
/// components, and unnecessary . and .. components.
|
||||
fn normalize<Sized? V: AsSlice<u8>>(v: &V) -> Vec<u8> {
|
||||
fn normalize<V: ?Sized + AsSlice<u8>>(v: &V) -> Vec<u8> {
|
||||
// borrowck is being very picky
|
||||
let val = {
|
||||
let is_abs = !v.as_slice().is_empty() && v.as_slice()[0] == SEP_BYTE;
|
||||
|
@ -13,8 +13,6 @@
|
||||
//!
|
||||
//! Obsolete syntax that becomes too hard to parse can be removed.
|
||||
|
||||
pub use self::ObsoleteSyntax::*;
|
||||
|
||||
use ast::{Expr, ExprTup};
|
||||
use codemap::Span;
|
||||
use parse::parser;
|
||||
@ -24,18 +22,19 @@ use ptr::P;
|
||||
/// The specific types of unsupported syntax
|
||||
#[derive(Copy, PartialEq, Eq, Hash)]
|
||||
pub enum ObsoleteSyntax {
|
||||
ObsoleteForSized,
|
||||
ObsoleteOwnedType,
|
||||
ObsoleteOwnedExpr,
|
||||
ObsoleteOwnedPattern,
|
||||
ObsoleteOwnedVector,
|
||||
ObsoleteOwnedSelf,
|
||||
ObsoleteImportRenaming,
|
||||
ObsoleteSubsliceMatch,
|
||||
ObsoleteExternCrateRenaming,
|
||||
ObsoleteProcType,
|
||||
ObsoleteProcExpr,
|
||||
ObsoleteClosureType,
|
||||
Sized,
|
||||
ForSized,
|
||||
OwnedType,
|
||||
OwnedExpr,
|
||||
OwnedPattern,
|
||||
OwnedVector,
|
||||
OwnedSelf,
|
||||
ImportRenaming,
|
||||
SubsliceMatch,
|
||||
ExternCrateRenaming,
|
||||
ProcType,
|
||||
ProcExpr,
|
||||
ClosureType,
|
||||
}
|
||||
|
||||
pub trait ParserObsoleteMethods {
|
||||
@ -57,55 +56,59 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
|
||||
/// Reports an obsolete syntax non-fatal error.
|
||||
fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax) {
|
||||
let (kind_str, desc) = match kind {
|
||||
ObsoleteForSized => (
|
||||
ObsoleteSyntax::ForSized => (
|
||||
"for Sized?",
|
||||
"no longer required. Traits (and their `Self` type) do not have the `Sized` bound \
|
||||
by default",
|
||||
),
|
||||
ObsoleteProcType => (
|
||||
ObsoleteSyntax::ProcType => (
|
||||
"the `proc` type",
|
||||
"use unboxed closures instead",
|
||||
),
|
||||
ObsoleteProcExpr => (
|
||||
ObsoleteSyntax::ProcExpr => (
|
||||
"`proc` expression",
|
||||
"use a `move ||` expression instead",
|
||||
),
|
||||
ObsoleteOwnedType => (
|
||||
ObsoleteSyntax::OwnedType => (
|
||||
"`~` notation for owned pointers",
|
||||
"use `Box<T>` in `std::owned` instead"
|
||||
),
|
||||
ObsoleteOwnedExpr => (
|
||||
ObsoleteSyntax::OwnedExpr => (
|
||||
"`~` notation for owned pointer allocation",
|
||||
"use the `box` operator instead of `~`"
|
||||
),
|
||||
ObsoleteOwnedPattern => (
|
||||
ObsoleteSyntax::OwnedPattern => (
|
||||
"`~` notation for owned pointer patterns",
|
||||
"use the `box` operator instead of `~`"
|
||||
),
|
||||
ObsoleteOwnedVector => (
|
||||
ObsoleteSyntax::OwnedVector => (
|
||||
"`~[T]` is no longer a type",
|
||||
"use the `Vec` type instead"
|
||||
),
|
||||
ObsoleteOwnedSelf => (
|
||||
ObsoleteSyntax::OwnedSelf => (
|
||||
"`~self` is no longer supported",
|
||||
"write `self: Box<Self>` instead"
|
||||
),
|
||||
ObsoleteImportRenaming => (
|
||||
ObsoleteSyntax::ImportRenaming => (
|
||||
"`use foo = bar` syntax",
|
||||
"write `use bar as foo` instead"
|
||||
),
|
||||
ObsoleteSubsliceMatch => (
|
||||
ObsoleteSyntax::SubsliceMatch => (
|
||||
"subslice match syntax",
|
||||
"instead of `..xs`, write `xs..` in a pattern"
|
||||
),
|
||||
ObsoleteExternCrateRenaming => (
|
||||
ObsoleteSyntax::ExternCrateRenaming => (
|
||||
"`extern crate foo = bar` syntax",
|
||||
"write `extern crate bar as foo` instead"
|
||||
),
|
||||
ObsoleteClosureType => (
|
||||
ObsoleteSyntax::ClosureType => (
|
||||
"`|uint| -> bool` closure type syntax",
|
||||
"use unboxed closures instead, no type annotation needed"
|
||||
)
|
||||
),
|
||||
ObsoleteSyntax::Sized => (
|
||||
"`Sized? T` syntax for removing the `Sized` bound",
|
||||
"write `T: ?Sized` instead"
|
||||
),
|
||||
};
|
||||
|
||||
self.report(sp, kind, kind_str, desc);
|
||||
|
@ -1155,7 +1155,7 @@ impl<'a> Parser<'a> {
|
||||
let _ = self.parse_colon_then_ty_param_bounds(BoundParsingMode::Bare);
|
||||
let _ = self.parse_ret_ty();
|
||||
|
||||
self.obsolete(proc_span, ObsoleteProcType);
|
||||
self.obsolete(proc_span, ObsoleteSyntax::ProcType);
|
||||
|
||||
TyInfer
|
||||
}
|
||||
@ -1511,8 +1511,10 @@ impl<'a> Parser<'a> {
|
||||
self.bump();
|
||||
let last_span = self.last_span;
|
||||
match self.token {
|
||||
token::OpenDelim(token::Bracket) => self.obsolete(last_span, ObsoleteOwnedVector),
|
||||
_ => self.obsolete(last_span, ObsoleteOwnedType)
|
||||
token::OpenDelim(token::Bracket) => {
|
||||
self.obsolete(last_span, ObsoleteSyntax::OwnedVector)
|
||||
}
|
||||
_ => self.obsolete(last_span, ObsoleteSyntax::OwnedType)
|
||||
}
|
||||
TyTup(vec![self.parse_ty()])
|
||||
} else if self.check(&token::BinOp(token::Star)) {
|
||||
@ -2275,7 +2277,7 @@ impl<'a> Parser<'a> {
|
||||
let span = self.last_span;
|
||||
let _ = self.parse_proc_decl();
|
||||
let _ = self.parse_expr();
|
||||
return self.obsolete_expr(span, ObsoleteProcExpr);
|
||||
return self.obsolete_expr(span, ObsoleteSyntax::ProcExpr);
|
||||
}
|
||||
if self.eat_keyword(keywords::If) {
|
||||
return self.parse_if_expr();
|
||||
@ -2850,9 +2852,9 @@ impl<'a> Parser<'a> {
|
||||
let last_span = self.last_span;
|
||||
match self.token {
|
||||
token::OpenDelim(token::Bracket) => {
|
||||
self.obsolete(last_span, ObsoleteOwnedVector)
|
||||
self.obsolete(last_span, ObsoleteSyntax::OwnedVector)
|
||||
},
|
||||
_ => self.obsolete(last_span, ObsoleteOwnedExpr)
|
||||
_ => self.obsolete(last_span, ObsoleteSyntax::OwnedExpr)
|
||||
}
|
||||
|
||||
let e = self.parse_prefix_expr();
|
||||
@ -3227,7 +3229,7 @@ impl<'a> Parser<'a> {
|
||||
} else {
|
||||
let _ = self.parse_pat();
|
||||
let span = self.span;
|
||||
self.obsolete(span, ObsoleteSubsliceMatch);
|
||||
self.obsolete(span, ObsoleteSyntax::SubsliceMatch);
|
||||
}
|
||||
continue
|
||||
}
|
||||
@ -3343,7 +3345,7 @@ impl<'a> Parser<'a> {
|
||||
pat = PatBox(sub);
|
||||
let last_span = self.last_span;
|
||||
hi = last_span.hi;
|
||||
self.obsolete(last_span, ObsoleteOwnedPattern);
|
||||
self.obsolete(last_span, ObsoleteSyntax::OwnedPattern);
|
||||
return P(ast::Pat {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
node: pat,
|
||||
@ -4090,8 +4092,8 @@ impl<'a> Parser<'a> {
|
||||
// unbound, and it may only be `Sized`. To avoid backtracking and other
|
||||
// complications, we parse an ident, then check for `?`. If we find it,
|
||||
// we use the ident as the unbound, otherwise, we use it as the name of
|
||||
// type param. Even worse, for now, we need to check for `?` before or
|
||||
// after the bound.
|
||||
// type param. Even worse, we need to check for `?` before or after the
|
||||
// bound.
|
||||
let mut span = self.span;
|
||||
let mut ident = self.parse_ident();
|
||||
let mut unbound = None;
|
||||
@ -4100,6 +4102,7 @@ impl<'a> Parser<'a> {
|
||||
unbound = Some(tref);
|
||||
span = self.span;
|
||||
ident = self.parse_ident();
|
||||
self.obsolete(span, ObsoleteSyntax::Sized);
|
||||
}
|
||||
|
||||
let mut bounds = self.parse_colon_then_ty_param_bounds(BoundParsingMode::Modified);
|
||||
@ -4463,7 +4466,7 @@ impl<'a> Parser<'a> {
|
||||
self.bump();
|
||||
drop(self.expect_self_ident());
|
||||
let last_span = self.last_span;
|
||||
self.obsolete(last_span, ObsoleteOwnedSelf)
|
||||
self.obsolete(last_span, ObsoleteSyntax::OwnedSelf)
|
||||
}
|
||||
SelfStatic
|
||||
}
|
||||
@ -4514,7 +4517,7 @@ impl<'a> Parser<'a> {
|
||||
self.bump();
|
||||
drop(self.expect_self_ident());
|
||||
let last_span = self.last_span;
|
||||
self.obsolete(last_span, ObsoleteOwnedSelf);
|
||||
self.obsolete(last_span, ObsoleteSyntax::OwnedSelf);
|
||||
SelfStatic
|
||||
} else {
|
||||
SelfStatic
|
||||
@ -5396,7 +5399,7 @@ impl<'a> Parser<'a> {
|
||||
self.bump();
|
||||
let path = self.parse_str();
|
||||
let span = self.span;
|
||||
self.obsolete(span, ObsoleteExternCrateRenaming);
|
||||
self.obsolete(span, ObsoleteSyntax::ExternCrateRenaming);
|
||||
Some(path)
|
||||
} else if self.eat_keyword(keywords::As) {
|
||||
// skip the ident if there is one
|
||||
@ -6053,7 +6056,7 @@ impl<'a> Parser<'a> {
|
||||
path.push(id);
|
||||
}
|
||||
let span = mk_sp(path_lo, self.span.hi);
|
||||
self.obsolete(span, ObsoleteImportRenaming);
|
||||
self.obsolete(span, ObsoleteSyntax::ImportRenaming);
|
||||
let path = ast::Path {
|
||||
span: span,
|
||||
global: false,
|
||||
|
@ -77,7 +77,7 @@ impl<T: Eq + Hash + Clone + 'static> Interner<T> {
|
||||
(*vect).len()
|
||||
}
|
||||
|
||||
pub fn find<Sized? Q>(&self, val: &Q) -> Option<Name>
|
||||
pub fn find<Q: ?Sized>(&self, val: &Q) -> Option<Name>
|
||||
where Q: BorrowFrom<T> + Eq + Hash {
|
||||
let map = self.map.borrow();
|
||||
match (*map).get(val) {
|
||||
@ -202,7 +202,7 @@ impl StrInterner {
|
||||
self.vect.borrow().len()
|
||||
}
|
||||
|
||||
pub fn find<Sized? Q>(&self, val: &Q) -> Option<Name>
|
||||
pub fn find<Q: ?Sized>(&self, val: &Q) -> Option<Name>
|
||||
where Q: BorrowFrom<RcStr> + Eq + Hash {
|
||||
match (*self.map.borrow()).get(val) {
|
||||
Some(v) => Some(*v),
|
||||
|
@ -9,7 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
trait Get {
|
||||
type Sized? Value;
|
||||
type Value: ?Sized;
|
||||
fn get(&self) -> <Self as Get>::Value;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
// Forbid assignment into a dynamically sized type.
|
||||
|
||||
struct Fat<Sized? T> {
|
||||
struct Fat<T: ?Sized> {
|
||||
f1: int,
|
||||
f2: &'static str,
|
||||
ptr: T
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
// Forbid assignment into a dynamically sized type.
|
||||
|
||||
struct Fat<Sized? T> {
|
||||
struct Fat<T: ?Sized> {
|
||||
f1: int,
|
||||
f2: &'static str,
|
||||
ptr: T
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
// Attempt to change the type as well as unsizing.
|
||||
|
||||
struct Fat<Sized? T> {
|
||||
struct Fat<T: ?Sized> {
|
||||
ptr: T
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
// Attempt to change the mutability as well as unsizing.
|
||||
|
||||
struct Fat<Sized? T> {
|
||||
struct Fat<T: ?Sized> {
|
||||
ptr: T
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
// Attempt to extend the lifetime as well as unsizing.
|
||||
|
||||
struct Fat<Sized? T> {
|
||||
struct Fat<T: ?Sized> {
|
||||
ptr: T
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
// Attempt to coerce from unsized to sized.
|
||||
|
||||
struct Fat<Sized? T> {
|
||||
struct Fat<T: ?Sized> {
|
||||
ptr: T
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ struct S;
|
||||
trait T {}
|
||||
impl T for S {}
|
||||
|
||||
struct Foo<Sized? T> {
|
||||
struct Foo<T: ?Sized> {
|
||||
f: T
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
// because it would require stack allocation of an unsized temporary (*g in the
|
||||
// test).
|
||||
|
||||
struct Fat<Sized? T> {
|
||||
struct Fat<T: ?Sized> {
|
||||
ptr: T
|
||||
}
|
||||
|
||||
|
@ -13,12 +13,12 @@
|
||||
trait Foo {}
|
||||
impl Foo for str {}
|
||||
|
||||
fn test1<Sized? T: Foo>(t: &T) {
|
||||
fn test1<T: ?Sized + Foo>(t: &T) {
|
||||
let u: &Foo = t;
|
||||
//~^ ERROR `core::kinds::Sized` is not implemented for the type `T`
|
||||
}
|
||||
|
||||
fn test2<Sized? T: Foo>(t: &T) {
|
||||
fn test2<T: ?Sized + Foo>(t: &T) {
|
||||
let v: &Foo = t as &Foo;
|
||||
//~^ ERROR `core::kinds::Sized` is not implemented for the type `T`
|
||||
}
|
||||
|
@ -14,11 +14,11 @@
|
||||
|
||||
use std::mem::transmute;
|
||||
|
||||
fn a<T, Sized? U>(x: &[T]) -> &U {
|
||||
fn a<T, U: ?Sized>(x: &[T]) -> &U {
|
||||
unsafe { transmute(x) } //~ ERROR transmute called on types with potentially different sizes
|
||||
}
|
||||
|
||||
fn b<Sized? T, Sized? U>(x: &T) -> &U {
|
||||
fn b<T: ?Sized, U: ?Sized>(x: &T) -> &U {
|
||||
unsafe { transmute(x) } //~ ERROR transmute called on types with potentially different sizes
|
||||
}
|
||||
|
||||
@ -30,11 +30,11 @@ fn d<T, U>(x: &[T]) -> &[U] {
|
||||
unsafe { transmute(x) }
|
||||
}
|
||||
|
||||
fn e<Sized? T, U>(x: &T) -> &U {
|
||||
fn e<T: ?Sized, U>(x: &T) -> &U {
|
||||
unsafe { transmute(x) } //~ ERROR transmute called on types with potentially different sizes
|
||||
}
|
||||
|
||||
fn f<T, Sized? U>(x: &T) -> &U {
|
||||
fn f<T, U: ?Sized>(x: &T) -> &U {
|
||||
unsafe { transmute(x) } //~ ERROR transmute called on types with potentially different sizes
|
||||
}
|
||||
|
||||
|
@ -14,11 +14,11 @@
|
||||
|
||||
use std::mem::transmute;
|
||||
|
||||
struct Foo<Sized? T> {
|
||||
struct Foo<T: ?Sized> {
|
||||
t: Box<T>
|
||||
}
|
||||
|
||||
impl<Sized? T> Foo<T> {
|
||||
impl<T: ?Sized> Foo<T> {
|
||||
fn m(x: &T) -> &int where T : Sized {
|
||||
// OK here, because T : Sized is in scope.
|
||||
unsafe { transmute(x) }
|
||||
|
@ -18,9 +18,9 @@ trait Foo<T,U,V=T> {
|
||||
fn dummy(&self, t: T, u: U, v: V);
|
||||
}
|
||||
|
||||
trait Eq<Sized? X> { }
|
||||
impl<Sized? X> Eq<X> for X { }
|
||||
fn eq<Sized? A,Sized? B>() where A : Eq<B> { }
|
||||
trait Eq<X: ?Sized> { }
|
||||
impl<X: ?Sized> Eq<X> for X { }
|
||||
fn eq<A: ?Sized,B: ?Sized>() where A : Eq<B> { }
|
||||
|
||||
fn test<'a,'b>() {
|
||||
// Parens are equivalent to omitting default in angle.
|
||||
|
@ -20,9 +20,9 @@ trait Foo<T,U> {
|
||||
fn dummy(&self, t: T, u: U);
|
||||
}
|
||||
|
||||
trait Eq<Sized? X> { }
|
||||
impl<Sized? X> Eq<X> for X { }
|
||||
fn eq<Sized? A,Sized? B:Eq<A>>() { }
|
||||
trait Eq<X: ?Sized> { }
|
||||
impl<X: ?Sized> Eq<X> for X { }
|
||||
fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { }
|
||||
|
||||
fn test<'a,'b>() {
|
||||
// No errors expected:
|
||||
|
@ -20,9 +20,9 @@ trait Foo<T,U> {
|
||||
fn dummy(&self, t: T, u: U);
|
||||
}
|
||||
|
||||
trait Eq<Sized? X> { }
|
||||
impl<Sized? X> Eq<X> for X { }
|
||||
fn eq<Sized? A,Sized? B:Eq<A>>() { }
|
||||
trait Eq<X: ?Sized> { }
|
||||
impl<X: ?Sized> Eq<X> for X { }
|
||||
fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { }
|
||||
|
||||
fn main() {
|
||||
eq::< for<'a> Foo<(&'a int,), &'a int>,
|
||||
|
@ -21,9 +21,9 @@ trait Foo<'a,T,U> {
|
||||
fn dummy(&'a self) -> &'a (T,U);
|
||||
}
|
||||
|
||||
trait Eq<Sized? X> { }
|
||||
impl<Sized? X> Eq<X> for X { }
|
||||
fn eq<Sized? A,Sized? B:Eq<A>>() { }
|
||||
trait Eq<X: ?Sized> { }
|
||||
impl<X: ?Sized> Eq<X> for X { }
|
||||
fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { }
|
||||
|
||||
fn same_type<A,B:Eq<A>>(a: A, b: B) { }
|
||||
|
||||
|
@ -9,5 +9,5 @@
|
||||
// except according to those terms.
|
||||
|
||||
fn bar<T: Sized>() { }
|
||||
fn foo<Sized? T>() { bar::<T>() } //~ ERROR the trait `core::kinds::Sized` is not implemented
|
||||
fn foo<T: ?Sized>() { bar::<T>() } //~ ERROR the trait `core::kinds::Sized` is not implemented
|
||||
fn main() { }
|
||||
|
@ -10,18 +10,18 @@
|
||||
|
||||
|
||||
fn is_sized<T:Sized>() { }
|
||||
fn not_sized<Sized? T>() { }
|
||||
fn not_sized<T: ?Sized>() { }
|
||||
|
||||
enum Foo<U> { FooSome(U), FooNone }
|
||||
fn foo1<T>() { not_sized::<Foo<T>>() } // Hunky dory.
|
||||
fn foo2<Sized? T>() { not_sized::<Foo<T>>() }
|
||||
fn foo2<T: ?Sized>() { not_sized::<Foo<T>>() }
|
||||
//~^ ERROR the trait `core::kinds::Sized` is not implemented
|
||||
//
|
||||
// Not OK: `T` is not sized.
|
||||
|
||||
enum Bar<Sized? U> { BarSome(U), BarNone }
|
||||
fn bar1<Sized? T>() { not_sized::<Bar<T>>() }
|
||||
fn bar2<Sized? T>() { is_sized::<Bar<T>>() }
|
||||
enum Bar<U: ?Sized> { BarSome(U), BarNone }
|
||||
fn bar1<T: ?Sized>() { not_sized::<Bar<T>>() }
|
||||
fn bar2<T: ?Sized>() { is_sized::<Bar<T>>() }
|
||||
//~^ ERROR the trait `core::kinds::Sized` is not implemented
|
||||
//
|
||||
// Not OK: `Bar<T>` is not sized, but it should be.
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
struct S5<Y>;
|
||||
|
||||
impl<Sized? X> S5<X> { //~ ERROR not implemented
|
||||
impl<X: ?Sized> S5<X> { //~ ERROR not implemented
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
@ -10,18 +10,18 @@
|
||||
|
||||
|
||||
fn is_sized<T:Sized>() { }
|
||||
fn not_sized<Sized? T>() { }
|
||||
fn not_sized<T: ?Sized>() { }
|
||||
|
||||
struct Foo<T> { data: T }
|
||||
fn foo1<T>() { not_sized::<Foo<T>>() } // Hunky dory.
|
||||
fn foo2<Sized? T>() { not_sized::<Foo<T>>() }
|
||||
fn foo2<T: ?Sized>() { not_sized::<Foo<T>>() }
|
||||
//~^ ERROR the trait `core::kinds::Sized` is not implemented
|
||||
//
|
||||
// Not OK: `T` is not sized.
|
||||
|
||||
struct Bar<Sized? T> { data: T }
|
||||
fn bar1<Sized? T>() { not_sized::<Bar<T>>() }
|
||||
fn bar2<Sized? T>() { is_sized::<Bar<T>>() }
|
||||
struct Bar<T: ?Sized> { data: T }
|
||||
fn bar1<T: ?Sized>() { not_sized::<Bar<T>>() }
|
||||
fn bar2<T: ?Sized>() { is_sized::<Bar<T>>() }
|
||||
//~^ ERROR the trait `core::kinds::Sized` is not implemented
|
||||
//
|
||||
// Not OK: `Bar<T>` is not sized, but it should be.
|
||||
|
@ -11,12 +11,12 @@
|
||||
// Test sized-ness checking in substitution in impls.
|
||||
|
||||
// impl - struct
|
||||
trait T3<Sized? Z> {
|
||||
trait T3<Z: ?Sized> {
|
||||
}
|
||||
|
||||
struct S5<Y>;
|
||||
|
||||
impl<Sized? X> T3<X> for S5<X> { //~ ERROR not implemented
|
||||
impl<X: ?Sized> T3<X> for S5<X> { //~ ERROR not implemented
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
@ -13,8 +13,8 @@
|
||||
// impl - unbounded
|
||||
trait T2<Z> {
|
||||
}
|
||||
struct S4<Sized? Y>;
|
||||
impl<Sized? X> T2<X> for S4<X> {
|
||||
struct S4<Y: ?Sized>;
|
||||
impl<X: ?Sized> T2<X> for S4<X> {
|
||||
//~^ ERROR `core::kinds::Sized` is not implemented for the type `X`
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
|
||||
// Unbounded.
|
||||
fn f1<Sized? X>(x: &X) {
|
||||
fn f1<X: ?Sized>(x: &X) {
|
||||
f2::<X>(x);
|
||||
//~^ ERROR the trait `core::kinds::Sized` is not implemented
|
||||
}
|
||||
@ -20,8 +20,8 @@ fn f2<X>(x: &X) {
|
||||
}
|
||||
|
||||
// Bounded.
|
||||
trait T {}
|
||||
fn f3<Sized? X: T>(x: &X) {
|
||||
trait T for {}
|
||||
fn f3<X: ?Sized + T>(x: &X) {
|
||||
f4::<X>(x);
|
||||
//~^ ERROR the trait `core::kinds::Sized` is not implemented
|
||||
}
|
||||
@ -29,13 +29,13 @@ fn f4<X: T>(x: &X) {
|
||||
}
|
||||
|
||||
// Test with unsized enum.
|
||||
enum E<Sized? X> {
|
||||
enum E<X: ?Sized> {
|
||||
V(X),
|
||||
}
|
||||
|
||||
fn f5<Y>(x: &Y) {}
|
||||
fn f6<Sized? X>(x: &X) {}
|
||||
fn f7<Sized? X>(x1: &E<X>, x2: &E<X>) {
|
||||
fn f6<X: ?Sized>(x: &X) {}
|
||||
fn f7<X: ?Sized>(x1: &E<X>, x2: &E<X>) {
|
||||
f5(x1);
|
||||
//~^ ERROR the trait `core::kinds::Sized` is not implemented
|
||||
f6(x2); // ok
|
||||
@ -43,23 +43,23 @@ fn f7<Sized? X>(x1: &E<X>, x2: &E<X>) {
|
||||
|
||||
|
||||
// Test with unsized struct.
|
||||
struct S<Sized? X> {
|
||||
struct S<X: ?Sized> {
|
||||
x: X,
|
||||
}
|
||||
|
||||
fn f8<Sized? X>(x1: &S<X>, x2: &S<X>) {
|
||||
fn f8<X: ?Sized>(x1: &S<X>, x2: &S<X>) {
|
||||
f5(x1);
|
||||
//~^ ERROR the trait `core::kinds::Sized` is not implemented
|
||||
f6(x2); // ok
|
||||
}
|
||||
|
||||
// Test some tuples.
|
||||
fn f9<Sized? X>(x1: Box<S<X>>, x2: Box<E<X>>) {
|
||||
fn f9<X: ?Sized>(x1: Box<S<X>>, x2: Box<E<X>>) {
|
||||
f5(&(*x1, 34i));
|
||||
//~^ ERROR the trait `core::kinds::Sized` is not implemented
|
||||
}
|
||||
|
||||
fn f10<Sized? X>(x1: Box<S<X>>, x2: Box<E<X>>) {
|
||||
fn f10<X: ?Sized>(x1: Box<S<X>>, x2: Box<E<X>>) {
|
||||
f5(&(32i, *x2));
|
||||
//~^ ERROR the trait `core::kinds::Sized` is not implemented
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
// Test that bounds are sized-compatible.
|
||||
|
||||
trait T : Sized {}
|
||||
fn f<Sized? Y: T>() {
|
||||
fn f<Y: ?Sized + T>() {
|
||||
//~^ERROR incompatible bounds on `Y`, bound `T` does not allow unsized type
|
||||
}
|
||||
|
||||
|
@ -10,11 +10,11 @@
|
||||
|
||||
// Test `Sized?` types not allowed in fields (except the last one).
|
||||
|
||||
struct S1<Sized? X> {
|
||||
struct S1<X: ?Sized> {
|
||||
f1: X, //~ ERROR `core::kinds::Sized` is not implemented
|
||||
f2: int,
|
||||
}
|
||||
struct S2<Sized? X> {
|
||||
struct S2<X: ?Sized> {
|
||||
f: int,
|
||||
g: X, //~ ERROR `core::kinds::Sized` is not implemented
|
||||
h: int,
|
||||
@ -27,10 +27,10 @@ struct S4 {
|
||||
f: str, //~ ERROR `core::kinds::Sized` is not implemented
|
||||
g: uint
|
||||
}
|
||||
enum E<Sized? X> {
|
||||
enum E<X: ?Sized> {
|
||||
V1(X, int), //~ERROR `core::kinds::Sized` is not implemented
|
||||
}
|
||||
enum F<Sized? X> {
|
||||
enum F<X: ?Sized> {
|
||||
V2{f1: X, f: int}, //~ERROR `core::kinds::Sized` is not implemented
|
||||
}
|
||||
|
||||
|
@ -13,30 +13,30 @@
|
||||
|
||||
trait T {}
|
||||
|
||||
fn f1<Sized? X>(x: &X) {
|
||||
fn f1<X: ?Sized>(x: &X) {
|
||||
let _: X; // <-- this is OK, no bindings created, no initializer.
|
||||
let _: (int, (X, int)); // same
|
||||
let y: X; //~ERROR the trait `core::kinds::Sized` is not implemented
|
||||
let y: (int, (X, int)); //~ERROR the trait `core::kinds::Sized` is not implemented
|
||||
}
|
||||
fn f2<Sized? X: T>(x: &X) {
|
||||
fn f2<X: ?Sized + T>(x: &X) {
|
||||
let y: X; //~ERROR the trait `core::kinds::Sized` is not implemented
|
||||
let y: (int, (X, int)); //~ERROR the trait `core::kinds::Sized` is not implemented
|
||||
}
|
||||
|
||||
fn f3<Sized? X>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
|
||||
fn f3<X: ?Sized>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
|
||||
let y: X = *x1; //~ERROR the trait `core::kinds::Sized` is not implemented
|
||||
let y = *x2; //~ERROR the trait `core::kinds::Sized` is not implemented
|
||||
let (y, z) = (*x3, 4i); //~ERROR the trait `core::kinds::Sized` is not implemented
|
||||
}
|
||||
fn f4<Sized? X: T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
|
||||
fn f4<X: ?Sized + T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
|
||||
let y: X = *x1; //~ERROR the trait `core::kinds::Sized` is not implemented
|
||||
let y = *x2; //~ERROR the trait `core::kinds::Sized` is not implemented
|
||||
let (y, z) = (*x3, 4i); //~ERROR the trait `core::kinds::Sized` is not implemented
|
||||
}
|
||||
|
||||
fn g1<Sized? X>(x: X) {} //~ERROR the trait `core::kinds::Sized` is not implemented
|
||||
fn g2<Sized? X: T>(x: X) {} //~ERROR the trait `core::kinds::Sized` is not implemented
|
||||
fn g1<X: ?Sized>(x: X) {} //~ERROR the trait `core::kinds::Sized` is not implemented
|
||||
fn g2<X: ?Sized + T>(x: X) {} //~ERROR the trait `core::kinds::Sized` is not implemented
|
||||
|
||||
pub fn main() {
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ trait T {}
|
||||
// impl - bounded
|
||||
trait T1<Z: T> {
|
||||
}
|
||||
struct S3<Sized? Y>;
|
||||
impl<Sized? X: T> T1<X> for S3<X> {
|
||||
struct S3<Y: ?Sized>;
|
||||
impl<X: ?Sized + T> T1<X> for S3<X> {
|
||||
//~^ ERROR `core::kinds::Sized` is not implemented for the type `X`
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ impl Drop for Foo {
|
||||
trait Trait {}
|
||||
impl Trait for Foo {}
|
||||
|
||||
struct Fat<Sized? T> {
|
||||
struct Fat<T: ?Sized> {
|
||||
f: T
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ impl Drop for Foo {
|
||||
}
|
||||
}
|
||||
|
||||
struct Fat<Sized? T> {
|
||||
struct Fat<T: ?Sized> {
|
||||
f: T
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
use std::ops::Deref;
|
||||
|
||||
pub trait MyEq<Sized? U=Self> {
|
||||
pub trait MyEq<U: ?Sized=Self> {
|
||||
fn eq(&self, u: &U) -> bool;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub trait Borrow<Sized? Borrowed> {
|
||||
pub trait Borrow<Borrowed: ?Sized> {
|
||||
fn borrow(&self) -> &Borrowed;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user