1
Fork 0

rollup merge of #20556: japaric/no-for-sized

Conflicts:
	src/libcollections/slice.rs
	src/libcollections/str.rs
	src/libcore/borrow.rs
	src/libcore/cmp.rs
	src/libcore/ops.rs
	src/libstd/c_str.rs
	src/test/compile-fail/issue-19009.rs
This commit is contained in:
Alex Crichton 2015-01-05 18:47:45 -08:00
commit afbce050ca
43 changed files with 101 additions and 77 deletions

View file

@ -122,6 +122,7 @@ pub type MutItems<'a, T:'a> = IterMut<'a, T>;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// Allocating extension methods for slices. /// Allocating extension methods for slices.
#[stable]
pub trait SliceExt for Sized? { pub trait SliceExt for Sized? {
#[stable] #[stable]
type Item; type Item;
@ -1007,7 +1008,7 @@ impl<T: Ord> OrdSliceExt<T> for [T] {
#[unstable = "U should be an associated type"] #[unstable = "U should be an associated type"]
/// An extension trait for concatenating slices /// An extension trait for concatenating slices
pub trait SliceConcatExt<Sized? T, U> for Sized? { pub trait SliceConcatExt<Sized? T, U> {
/// Flattens a slice of `T` into a single value `U`. /// Flattens a slice of `T` into a single value `U`.
#[stable] #[stable]
fn concat(&self) -> U; fn concat(&self) -> U;

View file

@ -60,7 +60,6 @@ use core::char::CharExt;
use core::clone::Clone; use core::clone::Clone;
use core::iter::AdditiveIterator; use core::iter::AdditiveIterator;
use core::iter::{range, Iterator, IteratorExt}; use core::iter::{range, Iterator, IteratorExt};
use core::kinds::Sized;
use core::ops; use core::ops;
use core::option::Option::{self, Some, None}; use core::option::Option::{self, Some, None};
use core::slice::AsSlice; use core::slice::AsSlice;
@ -409,7 +408,7 @@ Section: Trait implementations
/// Any string that can be represented as a slice. /// Any string that can be represented as a slice.
#[stable] #[stable]
pub trait StrExt for Sized?: ops::Slice<uint, str> { pub trait StrExt: ops::Slice<uint, str> {
/// Escapes each char in `s` with `char::escape_default`. /// Escapes each char in `s` with `char::escape_default`.
#[unstable = "return type may change to be an iterator"] #[unstable = "return type may change to be an iterator"]
fn escape_default(&self) -> String { fn escape_default(&self) -> String {

View file

@ -54,14 +54,14 @@ use self::Cow::*;
/// A trait for borrowing data. /// A trait for borrowing data.
#[old_orphan_check] #[old_orphan_check]
pub trait BorrowFrom<Sized? Owned> for Sized? { pub trait BorrowFrom<Sized? Owned> {
/// Immutably borrow from an owned value. /// Immutably borrow from an owned value.
fn borrow_from(owned: &Owned) -> &Self; fn borrow_from(owned: &Owned) -> &Self;
} }
/// A trait for mutably borrowing data. /// A trait for mutably borrowing data.
#[old_orphan_check] #[old_orphan_check]
pub trait BorrowFromMut<Sized? Owned> for Sized? : BorrowFrom<Owned> { pub trait BorrowFromMut<Sized? Owned> : BorrowFrom<Owned> {
/// Mutably borrow from an owned value. /// Mutably borrow from an owned value.
fn borrow_from_mut(owned: &mut Owned) -> &mut Self; fn borrow_from_mut(owned: &mut Owned) -> &mut Self;
} }
@ -107,7 +107,7 @@ impl<'a, T, Sized? B> IntoCow<'a, T, B> for Cow<'a, T, B> where B: ToOwned<T> {
/// A generalization of Clone to borrowed data. /// A generalization of Clone to borrowed data.
#[old_orphan_check] #[old_orphan_check]
pub trait ToOwned<Owned> for Sized?: BorrowFrom<Owned> { pub trait ToOwned<Owned>: BorrowFrom<Owned> {
/// Create owned data from borrowed data, usually by copying. /// Create owned data from borrowed data, usually by copying.
fn to_owned(&self) -> Owned; fn to_owned(&self) -> Owned;
} }

View file

@ -70,7 +70,7 @@ use option::Option::{self, Some, None};
#[lang="eq"] #[lang="eq"]
#[stable] #[stable]
#[old_orphan_check] #[old_orphan_check]
pub trait PartialEq<Sized? Rhs = Self> for Sized? { pub trait PartialEq<Sized? Rhs = Self> {
/// This method tests for `self` and `other` values to be equal, and is used by `==`. /// This method tests for `self` and `other` values to be equal, and is used by `==`.
#[stable] #[stable]
fn eq(&self, other: &Rhs) -> bool; fn eq(&self, other: &Rhs) -> bool;
@ -91,7 +91,7 @@ pub trait PartialEq<Sized? Rhs = Self> for Sized? {
/// - symmetric: `a == b` implies `b == a`; and /// - symmetric: `a == b` implies `b == a`; and
/// - transitive: `a == b` and `b == c` implies `a == c`. /// - transitive: `a == b` and `b == c` implies `a == c`.
#[stable] #[stable]
pub trait Eq for Sized?: PartialEq<Self> { pub trait Eq: PartialEq<Self> {
// FIXME #13101: this method is used solely by #[deriving] to // FIXME #13101: this method is used solely by #[deriving] to
// assert that every component of a type implements #[deriving] // assert that every component of a type implements #[deriving]
// itself, the current deriving infrastructure means doing this // itself, the current deriving infrastructure means doing this
@ -165,7 +165,7 @@ impl Ordering {
/// - transitive, `a < b` and `b < c` implies `a < c`. The same must hold for /// - transitive, `a < b` and `b < c` implies `a < c`. The same must hold for
/// both `==` and `>`. /// both `==` and `>`.
#[stable] #[stable]
pub trait Ord for Sized?: Eq + PartialOrd<Self> { pub trait Ord: Eq + PartialOrd<Self> {
/// This method returns an ordering between `self` and `other` values. /// This method returns an ordering between `self` and `other` values.
/// ///
/// By convention, `self.cmp(&other)` returns the ordering matching /// By convention, `self.cmp(&other)` returns the ordering matching
@ -225,7 +225,7 @@ impl PartialOrd for Ordering {
/// 5.11). /// 5.11).
#[lang="ord"] #[lang="ord"]
#[stable] #[stable]
pub trait PartialOrd<Sized? Rhs = Self> for Sized?: PartialEq<Rhs> { pub trait PartialOrd<Sized? Rhs = Self>: PartialEq<Rhs> {
/// This method returns an ordering between `self` and `other` values /// This method returns an ordering between `self` and `other` values
/// if one exists. /// if one exists.
#[stable] #[stable]

View file

@ -222,7 +222,7 @@ impl<'a> Show for Arguments<'a> {
/// to this trait. There is not an explicit way of selecting this trait to be /// to this trait. There is not an explicit way of selecting this trait to be
/// used for formatting, it is only if no other format is specified. /// used for formatting, it is only if no other format is specified.
#[unstable = "I/O and core have yet to be reconciled"] #[unstable = "I/O and core have yet to be reconciled"]
pub trait Show for Sized? { pub trait Show {
/// Formats the value using the given formatter. /// Formats the value using the given formatter.
fn fmt(&self, &mut Formatter) -> Result; fn fmt(&self, &mut Formatter) -> Result;
} }
@ -230,49 +230,49 @@ pub trait Show for Sized? {
/// Format trait for the `o` character /// Format trait for the `o` character
#[unstable = "I/O and core have yet to be reconciled"] #[unstable = "I/O and core have yet to be reconciled"]
pub trait Octal for Sized? { pub trait Octal {
/// Formats the value using the given formatter. /// Formats the value using the given formatter.
fn fmt(&self, &mut Formatter) -> Result; fn fmt(&self, &mut Formatter) -> Result;
} }
/// Format trait for the `b` character /// Format trait for the `b` character
#[unstable = "I/O and core have yet to be reconciled"] #[unstable = "I/O and core have yet to be reconciled"]
pub trait Binary for Sized? { pub trait Binary {
/// Formats the value using the given formatter. /// Formats the value using the given formatter.
fn fmt(&self, &mut Formatter) -> Result; fn fmt(&self, &mut Formatter) -> Result;
} }
/// Format trait for the `x` character /// Format trait for the `x` character
#[unstable = "I/O and core have yet to be reconciled"] #[unstable = "I/O and core have yet to be reconciled"]
pub trait LowerHex for Sized? { pub trait LowerHex {
/// Formats the value using the given formatter. /// Formats the value using the given formatter.
fn fmt(&self, &mut Formatter) -> Result; fn fmt(&self, &mut Formatter) -> Result;
} }
/// Format trait for the `X` character /// Format trait for the `X` character
#[unstable = "I/O and core have yet to be reconciled"] #[unstable = "I/O and core have yet to be reconciled"]
pub trait UpperHex for Sized? { pub trait UpperHex {
/// Formats the value using the given formatter. /// Formats the value using the given formatter.
fn fmt(&self, &mut Formatter) -> Result; fn fmt(&self, &mut Formatter) -> Result;
} }
/// Format trait for the `p` character /// Format trait for the `p` character
#[unstable = "I/O and core have yet to be reconciled"] #[unstable = "I/O and core have yet to be reconciled"]
pub trait Pointer for Sized? { pub trait Pointer {
/// Formats the value using the given formatter. /// Formats the value using the given formatter.
fn fmt(&self, &mut Formatter) -> Result; fn fmt(&self, &mut Formatter) -> Result;
} }
/// Format trait for the `e` character /// Format trait for the `e` character
#[unstable = "I/O and core have yet to be reconciled"] #[unstable = "I/O and core have yet to be reconciled"]
pub trait LowerExp for Sized? { pub trait LowerExp {
/// Formats the value using the given formatter. /// Formats the value using the given formatter.
fn fmt(&self, &mut Formatter) -> Result; fn fmt(&self, &mut Formatter) -> Result;
} }
/// Format trait for the `E` character /// Format trait for the `E` character
#[unstable = "I/O and core have yet to be reconciled"] #[unstable = "I/O and core have yet to be reconciled"]
pub trait UpperExp for Sized? { pub trait UpperExp {
/// Formats the value using the given formatter. /// Formats the value using the given formatter.
fn fmt(&self, &mut Formatter) -> Result; fn fmt(&self, &mut Formatter) -> Result;
} }

View file

@ -76,7 +76,7 @@ pub mod sip;
/// A hashable type. The `S` type parameter is an abstract hash state that is /// A hashable type. The `S` type parameter is an abstract hash state that is
/// used by the `Hash` to compute the hash. It defaults to /// used by the `Hash` to compute the hash. It defaults to
/// `std::hash::sip::SipState`. /// `std::hash::sip::SipState`.
pub trait Hash<S = sip::SipState> for Sized? { pub trait Hash<S = sip::SipState> {
/// Computes the hash of a value. /// Computes the hash of a value.
fn hash(&self, state: &mut S); fn hash(&self, state: &mut S);
} }

View file

@ -19,19 +19,19 @@
/// Types able to be transferred across task boundaries. /// Types able to be transferred across task boundaries.
#[lang="send"] #[lang="send"]
pub unsafe trait Send for Sized? : 'static { pub unsafe trait Send : 'static {
// empty. // empty.
} }
/// Types with a constant size known at compile-time. /// Types with a constant size known at compile-time.
#[lang="sized"] #[lang="sized"]
pub trait Sized for Sized? { pub trait Sized {
// Empty. // Empty.
} }
/// Types that can be copied by simply copying bits (i.e. `memcpy`). /// Types that can be copied by simply copying bits (i.e. `memcpy`).
#[lang="copy"] #[lang="copy"]
pub trait Copy for Sized? { pub trait Copy {
// Empty. // Empty.
} }
@ -81,7 +81,7 @@ pub trait Copy for Sized? {
/// reference; not doing this is undefined behaviour (for example, /// reference; not doing this is undefined behaviour (for example,
/// `transmute`-ing from `&T` to `&mut T` is illegal). /// `transmute`-ing from `&T` to `&mut T` is illegal).
#[lang="sync"] #[lang="sync"]
pub unsafe trait Sync for Sized? { pub unsafe trait Sync {
// Empty // Empty
} }

View file

@ -802,7 +802,7 @@ shr_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 }
/// } /// }
/// ``` /// ```
#[lang="index"] #[lang="index"]
pub trait Index<Sized? Index> for Sized? { pub trait Index<Sized? Index> {
type Sized? Output; type Sized? Output;
/// The method for the indexing (`Foo[Bar]`) operation /// The method for the indexing (`Foo[Bar]`) operation
@ -839,7 +839,7 @@ pub trait Index<Sized? Index> for Sized? {
/// } /// }
/// ``` /// ```
#[lang="index_mut"] #[lang="index_mut"]
pub trait IndexMut<Sized? Index> for Sized? { pub trait IndexMut<Sized? Index> {
type Sized? Output; type Sized? Output;
/// The method for the indexing (`Foo[Bar]`) operation /// The method for the indexing (`Foo[Bar]`) operation
@ -884,7 +884,7 @@ pub trait IndexMut<Sized? Index> for Sized? {
/// } /// }
/// ``` /// ```
#[lang="slice"] #[lang="slice"]
pub trait Slice<Sized? Idx, Sized? Result> for Sized? { pub trait Slice<Sized? Idx, Sized? Result> {
/// The method for the slicing operation foo[] /// The method for the slicing operation foo[]
fn as_slice_<'a>(&'a self) -> &'a Result; fn as_slice_<'a>(&'a self) -> &'a Result;
/// The method for the slicing operation foo[from..] /// The method for the slicing operation foo[from..]
@ -933,7 +933,7 @@ pub trait Slice<Sized? Idx, Sized? Result> for Sized? {
/// } /// }
/// ``` /// ```
#[lang="slice_mut"] #[lang="slice_mut"]
pub trait SliceMut<Sized? Idx, Sized? Result> for Sized? { pub trait SliceMut<Sized? Idx, Sized? Result> {
/// The method for the slicing operation foo[] /// The method for the slicing operation foo[]
fn as_mut_slice_<'a>(&'a mut self) -> &'a mut Result; fn as_mut_slice_<'a>(&'a mut self) -> &'a mut Result;
/// The method for the slicing operation foo[from..] /// The method for the slicing operation foo[from..]
@ -1069,7 +1069,7 @@ pub struct RangeTo<Idx> {
/// ``` /// ```
#[lang="deref"] #[lang="deref"]
#[stable] #[stable]
pub trait Deref for Sized? { pub trait Deref {
#[stable] #[stable]
type Sized? Target; type Sized? Target;
@ -1131,7 +1131,7 @@ impl<'a, Sized? T> Deref for &'a mut T {
/// ``` /// ```
#[lang="deref_mut"] #[lang="deref_mut"]
#[stable] #[stable]
pub trait DerefMut for Sized? : Deref { pub trait DerefMut: Deref {
/// The method called to mutably dereference a value /// The method called to mutably dereference a value
#[stable] #[stable]
fn deref_mut<'a>(&'a mut self) -> &'a mut <Self as Deref>::Target; fn deref_mut<'a>(&'a mut self) -> &'a mut <Self as Deref>::Target;
@ -1145,7 +1145,7 @@ impl<'a, Sized? T> DerefMut for &'a mut T {
/// A version of the call operator that takes an immutable receiver. /// A version of the call operator that takes an immutable receiver.
#[lang="fn"] #[lang="fn"]
#[unstable = "uncertain about variadic generics, input versus associated types"] #[unstable = "uncertain about variadic generics, input versus associated types"]
pub trait Fn<Args,Result> for Sized? { pub trait Fn<Args,Result> {
/// This is called when the call operator is used. /// This is called when the call operator is used.
extern "rust-call" fn call(&self, args: Args) -> Result; extern "rust-call" fn call(&self, args: Args) -> Result;
} }
@ -1153,7 +1153,7 @@ pub trait Fn<Args,Result> for Sized? {
/// A version of the call operator that takes a mutable receiver. /// A version of the call operator that takes a mutable receiver.
#[lang="fn_mut"] #[lang="fn_mut"]
#[unstable = "uncertain about variadic generics, input versus associated types"] #[unstable = "uncertain about variadic generics, input versus associated types"]
pub trait FnMut<Args,Result> for Sized? { pub trait FnMut<Args,Result> {
/// This is called when the call operator is used. /// This is called when the call operator is used.
extern "rust-call" fn call_mut(&mut self, args: Args) -> Result; extern "rust-call" fn call_mut(&mut self, args: Args) -> Result;
} }

View file

@ -20,7 +20,6 @@
use kinds::Copy; use kinds::Copy;
use mem; use mem;
use kinds::Sized;
/// The representation of a Rust slice /// The representation of a Rust slice
#[repr(C)] #[repr(C)]
@ -52,7 +51,7 @@ pub struct TraitObject {
/// This trait is meant to map equivalences between raw structs and their /// This trait is meant to map equivalences between raw structs and their
/// corresponding rust values. /// corresponding rust values.
pub trait Repr<T> for Sized? { pub trait Repr<T> {
/// This function "unwraps" a rust value (without consuming it) into its raw /// This function "unwraps" a rust value (without consuming it) into its raw
/// struct representation. This can be used to read/write different values /// struct representation. This can be used to read/write different values
/// for the struct. This is a safe method because by default it does not /// for the struct. This is a safe method because by default it does not

View file

@ -64,7 +64,7 @@ use raw::Slice as RawSlice;
/// Extension methods for slices. /// Extension methods for slices.
#[allow(missing_docs)] // docs in libcollections #[allow(missing_docs)] // docs in libcollections
pub trait SliceExt for Sized? { pub trait SliceExt {
type Item; type Item;
fn slice<'a>(&'a self, start: uint, end: uint) -> &'a [Self::Item]; fn slice<'a>(&'a self, start: uint, end: uint) -> &'a [Self::Item];
@ -614,7 +614,7 @@ impl<T> ops::SliceMut<uint, [T]> for [T] {
/// Data that is viewable as a slice. /// Data that is viewable as a slice.
#[experimental = "will be replaced by slice syntax"] #[experimental = "will be replaced by slice syntax"]
pub trait AsSlice<T> for Sized? { pub trait AsSlice<T> {
/// Work with `self` as a slice. /// Work with `self` as a slice.
fn as_slice<'a>(&'a self) -> &'a [T]; fn as_slice<'a>(&'a self) -> &'a [T];
} }
@ -1355,12 +1355,11 @@ pub unsafe fn from_raw_mut_buf<'a, T>(p: &'a *mut T, len: uint) -> &'a mut [T] {
/// Operations on `[u8]`. /// Operations on `[u8]`.
#[experimental = "needs review"] #[experimental = "needs review"]
pub mod bytes { pub mod bytes {
use kinds::Sized;
use ptr; use ptr;
use slice::SliceExt; use slice::SliceExt;
/// A trait for operations on mutable `[u8]`s. /// A trait for operations on mutable `[u8]`s.
pub trait MutableByteVector for Sized? { pub trait MutableByteVector {
/// Sets all bytes of the receiver to the given value. /// Sets all bytes of the receiver to the given value.
fn set_memory(&mut self, value: u8); fn set_memory(&mut self, value: u8);
} }
@ -1444,7 +1443,7 @@ impl<T: PartialOrd> PartialOrd for [T] {
/// Extension methods for slices containing integers. /// Extension methods for slices containing integers.
#[experimental] #[experimental]
pub trait IntSliceExt<U, S> for Sized? { pub trait IntSliceExt<U, S> {
/// Converts the slice to an immutable slice of unsigned integers with the same width. /// Converts the slice to an immutable slice of unsigned integers with the same width.
fn as_unsigned<'a>(&'a self) -> &'a [U]; fn as_unsigned<'a>(&'a self) -> &'a [U];
/// Converts the slice to an immutable slice of signed integers with the same width. /// Converts the slice to an immutable slice of signed integers with the same width.

View file

@ -1145,7 +1145,7 @@ mod traits {
#[unstable = "Instead of taking this bound generically, this trait will be \ #[unstable = "Instead of taking this bound generically, this trait will be \
replaced with one of slicing syntax, deref coercions, or \ replaced with one of slicing syntax, deref coercions, or \
a more generic conversion trait"] a more generic conversion trait"]
pub trait Str for Sized? { pub trait Str {
/// Work with `self` as a slice. /// Work with `self` as a slice.
fn as_slice<'a>(&'a self) -> &'a str; fn as_slice<'a>(&'a self) -> &'a str;
} }
@ -1186,7 +1186,7 @@ delegate_iter!{pattern forward &'a str in RSplitN<'a, P>}
/// Methods for string slices /// Methods for string slices
#[allow(missing_docs)] #[allow(missing_docs)]
pub trait StrExt for Sized? { pub trait StrExt {
// NB there are no docs here are they're all located on the StrExt trait in // NB there are no docs here are they're all located on the StrExt trait in
// libcollections, not here. // libcollections, not here.

View file

@ -92,8 +92,8 @@ impl<'cx, 'tcx> Elaborator<'cx, 'tcx> {
// Only keep those bounds that we haven't already // Only keep those bounds that we haven't already
// seen. This is necessary to prevent infinite // seen. This is necessary to prevent infinite
// recursion in some cases. One common case is when // recursion in some cases. One common case is when
// people define `trait Sized { }` rather than `trait // people define `trait Sized: Sized { }` rather than `trait
// Sized for Sized? { }`. // Sized { }`.
predicates.retain(|r| self.visited.insert(r.clone())); predicates.retain(|r| self.visited.insert(r.clone()));
self.stack.push(StackEntry { position: 0, self.stack.push(StackEntry { position: 0,

View file

@ -38,7 +38,7 @@ use syntax::{ast, ast_util};
use syntax::owned_slice::OwnedSlice; use syntax::owned_slice::OwnedSlice;
/// Produces a string suitable for debugging output. /// Produces a string suitable for debugging output.
pub trait Repr<'tcx> for Sized? { pub trait Repr<'tcx> {
fn repr(&self, tcx: &ctxt<'tcx>) -> String; fn repr(&self, tcx: &ctxt<'tcx>) -> String;
} }

View file

@ -63,7 +63,7 @@ impl RegClass {
} }
} }
trait ClassList for Sized? { trait ClassList {
fn is_pass_byval(&self) -> bool; fn is_pass_byval(&self) -> bool;
fn is_ret_bysret(&self) -> bool; fn is_ret_bysret(&self) -> bool;
} }

View file

@ -12,7 +12,7 @@ use trans::context::CrateContext;
use trans::type_::Type; use trans::type_::Type;
use llvm::ValueRef; use llvm::ValueRef;
pub trait LlvmRepr for Sized? { pub trait LlvmRepr {
fn llrepr(&self, ccx: &CrateContext) -> String; fn llrepr(&self, ccx: &CrateContext) -> String;
} }

View file

@ -70,7 +70,7 @@ static URLSAFE_CHARS: &'static[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\
0123456789-_"; 0123456789-_";
/// A trait for converting a value to base64 encoding. /// A trait for converting a value to base64 encoding.
pub trait ToBase64 for Sized? { pub trait ToBase64 {
/// Converts the value of `self` to a base64 value following the specified /// Converts the value of `self` to a base64 value following the specified
/// format configuration, returning the owned string. /// format configuration, returning the owned string.
fn to_base64(&self, config: Config) -> String; fn to_base64(&self, config: Config) -> String;
@ -170,7 +170,7 @@ impl ToBase64 for [u8] {
} }
/// A trait for converting from base64 encoded values. /// A trait for converting from base64 encoded values.
pub trait FromBase64 for Sized? { pub trait FromBase64 {
/// Converts the value of `self`, interpreted as base64 encoded data, into /// Converts the value of `self`, interpreted as base64 encoded data, into
/// an owned vector of bytes, returning the vector. /// an owned vector of bytes, returning the vector.
fn from_base64(&self) -> Result<Vec<u8>, FromBase64Error>; fn from_base64(&self) -> Result<Vec<u8>, FromBase64Error>;

View file

@ -18,7 +18,7 @@ use std::fmt;
use std::error; use std::error;
/// A trait for converting a value to hexadecimal encoding /// A trait for converting a value to hexadecimal encoding
pub trait ToHex for Sized? { pub trait ToHex {
/// Converts the value of `self` to a hex value, returning the owned /// Converts the value of `self` to a hex value, returning the owned
/// string. /// string.
fn to_hex(&self) -> String; fn to_hex(&self) -> String;
@ -54,7 +54,7 @@ impl ToHex for [u8] {
} }
/// A trait for converting hexadecimal encoded values /// A trait for converting hexadecimal encoded values
pub trait FromHex for Sized? { pub trait FromHex {
/// Converts the value of `self`, interpreted as hexadecimal encoded data, /// Converts the value of `self`, interpreted as hexadecimal encoded data,
/// into an owned vector of bytes, returning the vector. /// into an owned vector of bytes, returning the vector.
fn from_hex(&self) -> Result<Vec<u8>, FromHexError>; fn from_hex(&self) -> Result<Vec<u8>, FromHexError>;

View file

@ -2302,7 +2302,7 @@ impl ::Decoder for Decoder {
} }
/// A trait for converting values to JSON /// A trait for converting values to JSON
pub trait ToJson for Sized? { pub trait ToJson {
/// Converts the value of `self` to an instance of JSON /// Converts the value of `self` to an instance of JSON
fn to_json(&self) -> Json; fn to_json(&self) -> Json;
} }

View file

@ -190,7 +190,7 @@ pub trait Decoder {
fn error(&mut self, err: &str) -> Self::Error; fn error(&mut self, err: &str) -> Self::Error;
} }
pub trait Encodable for Sized? { pub trait Encodable {
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error>; fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error>;
} }

View file

@ -14,7 +14,6 @@
#![unstable = "unsure about placement and naming"] #![unstable = "unsure about placement and naming"]
use core::kinds::Sized;
use iter::IteratorExt; use iter::IteratorExt;
use ops::FnMut; use ops::FnMut;
use slice::SliceExt; use slice::SliceExt;
@ -38,7 +37,7 @@ pub trait OwnedAsciiExt {
/// Extension methods for ASCII-subset only operations on string slices /// Extension methods for ASCII-subset only operations on string slices
#[experimental = "would prefer to do this in a more general way"] #[experimental = "would prefer to do this in a more general way"]
pub trait AsciiExt<T = Self> for Sized? { pub trait AsciiExt<T = Self> {
/// Check if within the ASCII range. /// Check if within the ASCII range.
fn is_ascii(&self) -> bool; fn is_ascii(&self) -> bool;

View file

@ -786,7 +786,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
} }
/// A trait that represents something bytes-like (e.g. a &[u8] or a &str) /// A trait that represents something bytes-like (e.g. a &[u8] or a &str)
pub trait BytesContainer for Sized? { pub trait BytesContainer {
/// Returns a &[u8] representing the receiver /// Returns a &[u8] representing the receiver
fn container_as_bytes<'a>(&'a self) -> &'a [u8]; fn container_as_bytes<'a>(&'a self) -> &'a [u8];
/// Returns the receiver interpreted as a utf-8 string, if possible /// Returns the receiver interpreted as a utf-8 string, if possible

View file

@ -85,14 +85,14 @@ pub mod rt {
*/ */
// FIXME: Move this trait to pprust and get rid of *_to_str? // FIXME: Move this trait to pprust and get rid of *_to_str?
pub trait ToSource for Sized? { pub trait ToSource {
// Takes a thing and generates a string containing rust code for it. // Takes a thing and generates a string containing rust code for it.
fn to_source(&self) -> String; fn to_source(&self) -> String;
} }
// FIXME (Issue #16472): This should go away after ToToken impls // FIXME (Issue #16472): This should go away after ToToken impls
// are revised to go directly to token-trees. // are revised to go directly to token-trees.
trait ToSourceWithHygiene for Sized? : ToSource { trait ToSourceWithHygiene : ToSource {
// Takes a thing and generates a string containing rust code // Takes a thing and generates a string containing rust code
// for it, encoding Idents as special byte sequences to // for it, encoding Idents as special byte sequences to
// maintain hygiene across serialization and deserialization. // maintain hygiene across serialization and deserialization.

View file

@ -24,6 +24,7 @@ use ptr::P;
/// The specific types of unsupported syntax /// The specific types of unsupported syntax
#[derive(Copy, PartialEq, Eq, Hash)] #[derive(Copy, PartialEq, Eq, Hash)]
pub enum ObsoleteSyntax { pub enum ObsoleteSyntax {
ObsoleteForSized,
ObsoleteOwnedType, ObsoleteOwnedType,
ObsoleteOwnedExpr, ObsoleteOwnedExpr,
ObsoleteOwnedPattern, ObsoleteOwnedPattern,
@ -56,6 +57,11 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
/// Reports an obsolete syntax non-fatal error. /// Reports an obsolete syntax non-fatal error.
fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax) { fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax) {
let (kind_str, desc) = match kind { let (kind_str, desc) = match kind {
ObsoleteForSized => (
"for Sized?",
"no longer required. Traits (and their `Self` type) do not have the `Sized` bound \
by default",
),
ObsoleteProcType => ( ObsoleteProcType => (
"the `proc` type", "the `proc` type",
"use unboxed closures instead", "use unboxed closures instead",

View file

@ -5052,6 +5052,7 @@ impl<'a> Parser<'a> {
// re-jigged shortly in any case, so leaving the hacky version for now. // re-jigged shortly in any case, so leaving the hacky version for now.
if self.eat_keyword(keywords::For) { if self.eat_keyword(keywords::For) {
let span = self.span; let span = self.span;
let mut ate_question = false; let mut ate_question = false;
if self.eat(&token::Question) { if self.eat(&token::Question) {
ate_question = true; ate_question = true;
@ -5069,8 +5070,11 @@ impl<'a> Parser<'a> {
"expected `?Sized` after `for` in trait item"); "expected `?Sized` after `for` in trait item");
return None; return None;
} }
let tref = Parser::trait_ref_from_ident(ident, span); let _tref = Parser::trait_ref_from_ident(ident, span);
Some(tref)
self.obsolete(span, ObsoleteForSized);
None
} else { } else {
None None
} }

View file

@ -39,7 +39,7 @@ fn local_sort<T: Float>(v: &mut [T]) {
} }
/// Trait that provides simple descriptive statistics on a univariate set of numeric samples. /// Trait that provides simple descriptive statistics on a univariate set of numeric samples.
pub trait Stats <T: FloatMath + FromPrimitive> for Sized? { pub trait Stats <T: FloatMath + FromPrimitive> {
/// Sum of the samples. /// Sum of the samples.
/// ///

View file

@ -37,7 +37,7 @@ pub struct Words<'a> {
/// Methods for Unicode string slices /// Methods for Unicode string slices
#[allow(missing_docs)] // docs in libcollections #[allow(missing_docs)] // docs in libcollections
pub trait UnicodeStr for Sized? { pub trait UnicodeStr {
fn graphemes<'a>(&'a self, is_extended: bool) -> Graphemes<'a>; fn graphemes<'a>(&'a self, is_extended: bool) -> Graphemes<'a>;
fn grapheme_indices<'a>(&'a self, is_extended: bool) -> GraphemeIndices<'a>; fn grapheme_indices<'a>(&'a self, is_extended: bool) -> GraphemeIndices<'a>;
fn words<'a>(&'a self) -> Words<'a>; fn words<'a>(&'a self) -> Words<'a>;

View file

@ -12,7 +12,7 @@
#![feature(lang_items)] #![feature(lang_items)]
#[lang="sized"] #[lang="sized"]
pub trait Sized for Sized? {} pub trait Sized {}
#[lang="panic"] #[lang="panic"]
fn panic(_: &(&'static str, &'static str, uint)) -> ! { loop {} } fn panic(_: &(&'static str, &'static str, uint)) -> ! { loop {} }

View file

@ -16,7 +16,7 @@
#![no_std] #![no_std]
#[lang="sized"] #[lang="sized"]
pub trait Sized for Sized? { pub trait Sized {
// Empty. // Empty.
} }

View file

@ -10,7 +10,7 @@
// Test that we cannot create objects from unsized types. // Test that we cannot create objects from unsized types.
trait Foo for Sized? {} trait Foo {}
impl Foo for str {} impl Foo for str {}
fn test1<Sized? T: Foo>(t: &T) { fn test1<Sized? T: Foo>(t: &T) {

View file

@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
pub trait Foo for Sized? { fn foo<T>(&self, ext_thing: &T); } pub trait Foo { fn foo<T>(&self, ext_thing: &T); }
pub trait Bar for Sized?: Foo { } pub trait Bar: Foo { }
impl<T: Foo> Bar for T { } impl<T: Foo> Bar for T { }
pub struct Thing; pub struct Thing;

View file

@ -0,0 +1,17 @@
// 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.
// Test that we generate obsolete syntax errors around usages of `for Sized?`
trait Foo for Sized? {} //~ ERROR obsolete syntax: for Sized?
trait Bar for ?Sized {} //~ ERROR obsolete syntax: for Sized?
fn main() { }

View file

@ -11,7 +11,7 @@
#![feature(lang_items)] #![feature(lang_items)]
#![no_std] // makes debugging this test *a lot* easier (during resolve) #![no_std] // makes debugging this test *a lot* easier (during resolve)
#[lang = "sized"] pub trait Sized for Sized? {} #[lang = "sized"] pub trait Sized {}
#[lang="copy"] pub trait Copy {} #[lang="copy"] pub trait Copy {}
// Test to make sure that private items imported through globs remain private // Test to make sure that private items imported through globs remain private

View file

@ -11,7 +11,7 @@
#![feature(lang_items)] #![feature(lang_items)]
#![no_std] #![no_std]
#[lang="sized"] pub trait Sized for Sized? {} #[lang="sized"] pub trait Sized {}
// error-pattern:requires `start` lang_item // error-pattern:requires `start` lang_item

View file

@ -18,7 +18,7 @@ trait Foo<T,U,V=T> {
fn dummy(&self, t: T, u: U, v: V); fn dummy(&self, t: T, u: U, v: V);
} }
trait Eq<Sized? X> for Sized? { } trait Eq<Sized? X> { }
impl<Sized? X> Eq<X> for X { } impl<Sized? X> Eq<X> for X { }
fn eq<Sized? A,Sized? B>() where A : Eq<B> { } fn eq<Sized? A,Sized? B>() where A : Eq<B> { }

View file

@ -20,7 +20,7 @@ trait Foo<T,U> {
fn dummy(&self, t: T, u: U); fn dummy(&self, t: T, u: U);
} }
trait Eq<Sized? X> for Sized? { } trait Eq<Sized? X> { }
impl<Sized? X> Eq<X> for X { } impl<Sized? X> Eq<X> for X { }
fn eq<Sized? A,Sized? B:Eq<A>>() { } fn eq<Sized? A,Sized? B:Eq<A>>() { }

View file

@ -20,7 +20,7 @@ trait Foo<T,U> {
fn dummy(&self, t: T, u: U); fn dummy(&self, t: T, u: U);
} }
trait Eq<Sized? X> for Sized? { } trait Eq<Sized? X> { }
impl<Sized? X> Eq<X> for X { } impl<Sized? X> Eq<X> for X { }
fn eq<Sized? A,Sized? B:Eq<A>>() { } fn eq<Sized? A,Sized? B:Eq<A>>() { }

View file

@ -21,7 +21,7 @@ trait Foo<'a,T,U> {
fn dummy(&'a self) -> &'a (T,U); fn dummy(&'a self) -> &'a (T,U);
} }
trait Eq<Sized? X> for Sized? { } trait Eq<Sized? X> { }
impl<Sized? X> Eq<X> for X { } impl<Sized? X> Eq<X> for X { }
fn eq<Sized? A,Sized? B:Eq<A>>() { } fn eq<Sized? A,Sized? B:Eq<A>>() { }

View file

@ -20,7 +20,7 @@ fn f2<X>(x: &X) {
} }
// Bounded. // Bounded.
trait T for Sized? {} trait T {}
fn f3<Sized? X: T>(x: &X) { fn f3<Sized? X: T>(x: &X) {
f4::<X>(x); f4::<X>(x);
//~^ ERROR the trait `core::kinds::Sized` is not implemented //~^ ERROR the trait `core::kinds::Sized` is not implemented

View file

@ -11,7 +11,7 @@
// Test `Sized?` local variables. // Test `Sized?` local variables.
trait T for Sized? {} trait T {}
fn f1<Sized? X>(x: &X) { fn f1<Sized? X>(x: &X) {
let _: X; // <-- this is OK, no bindings created, no initializer. let _: X; // <-- this is OK, no bindings created, no initializer.

View file

@ -10,7 +10,7 @@
// Test sized-ness checking in substitution in impls. // Test sized-ness checking in substitution in impls.
trait T for Sized? {} trait T {}
// I would like these to fail eventually. // I would like these to fail eventually.
// impl - bounded // impl - bounded

View file

@ -16,7 +16,7 @@
use std::ops::Deref; use std::ops::Deref;
pub trait MyEq<Sized? U=Self> for Sized? { pub trait MyEq<Sized? U=Self> {
fn eq(&self, u: &U) -> bool; fn eq(&self, u: &U) -> bool;
} }

View file

@ -14,7 +14,7 @@
struct Splits<'a, T, P>; struct Splits<'a, T, P>;
struct SplitsN<I>; struct SplitsN<I>;
trait SliceExt2 for Sized? { trait SliceExt2 {
type Item; type Item;
fn split2<'a, P>(&'a self, pred: P) -> Splits<'a, Self::Item, P> fn split2<'a, P>(&'a self, pred: P) -> Splits<'a, Self::Item, P>

View file

@ -14,7 +14,7 @@
struct Splits<'a, T, P>; struct Splits<'a, T, P>;
struct SplitsN<I>; struct SplitsN<I>;
trait SliceExt2 for Sized? { trait SliceExt2 {
type Item; type Item;
fn split2<'a, P>(&'a self, pred: P) -> Splits<'a, Self::Item, P> fn split2<'a, P>(&'a self, pred: P) -> Splits<'a, Self::Item, P>