Auto merge of #38958 - sanxiyn:rollup, r=sanxiyn
Rollup of 11 pull requests - Successful merges: #38606, #38607, #38623, #38664, #38799, #38816, #38836, #38839, #38841, #38849, #38874 - Failed merges: #38845
This commit is contained in:
commit
7bffede97c
30 changed files with 346 additions and 49 deletions
|
@ -316,7 +316,6 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
|
|||
"codegen-units");
|
||||
suite("check-incremental", "src/test/incremental", "incremental",
|
||||
"incremental");
|
||||
suite("check-ui", "src/test/ui", "ui", "ui");
|
||||
}
|
||||
|
||||
if build.config.build.contains("msvc") {
|
||||
|
@ -363,6 +362,7 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
|
|||
});
|
||||
};
|
||||
|
||||
suite("check-ui", "src/test/ui", "ui", "ui");
|
||||
suite("check-rpass-full", "src/test/run-pass-fulldeps",
|
||||
"run-pass", "run-pass-fulldeps");
|
||||
suite("check-rfail-full", "src/test/run-fail-fulldeps",
|
||||
|
@ -1374,7 +1374,6 @@ mod tests {
|
|||
|
||||
assert!(plan.iter().any(|s| s.name.contains("-ui")));
|
||||
assert!(plan.iter().any(|s| s.name.contains("cfail")));
|
||||
assert!(plan.iter().any(|s| s.name.contains("cfail")));
|
||||
assert!(plan.iter().any(|s| s.name.contains("cfail-full")));
|
||||
assert!(plan.iter().any(|s| s.name.contains("codegen-units")));
|
||||
assert!(plan.iter().any(|s| s.name.contains("debuginfo")));
|
||||
|
@ -1407,8 +1406,7 @@ mod tests {
|
|||
assert!(plan.iter().all(|s| s.host == "A"));
|
||||
assert!(plan.iter().all(|s| s.target == "C"));
|
||||
|
||||
assert!(plan.iter().any(|s| s.name.contains("-ui")));
|
||||
assert!(plan.iter().any(|s| s.name.contains("cfail")));
|
||||
assert!(!plan.iter().any(|s| s.name.contains("-ui")));
|
||||
assert!(plan.iter().any(|s| s.name.contains("cfail")));
|
||||
assert!(!plan.iter().any(|s| s.name.contains("cfail-full")));
|
||||
assert!(plan.iter().any(|s| s.name.contains("codegen-units")));
|
||||
|
|
|
@ -17,6 +17,7 @@ Coercion is allowed between the following types:
|
|||
* `&T` to `*const T`
|
||||
* `&mut T` to `*mut T`
|
||||
* Unsizing: `T` to `U` if `T` implements `CoerceUnsized<U>`
|
||||
* Deref coercion: Expression `&x` of type `&T` to `&*x` of type `&U` if `T` derefs to `U` (i.e. `T: Deref<Target=U>`)
|
||||
|
||||
`CoerceUnsized<Pointer<U>> for Pointer<T> where T: Unsize<U>` is implemented
|
||||
for all pointer types (including smart pointers like Box and Rc). Unsize is
|
||||
|
@ -27,8 +28,9 @@ only implemented automatically, and enables the following transformations:
|
|||
* `Foo<..., T, ...>` => `Foo<..., U, ...>` where:
|
||||
* `T: Unsize<U>`
|
||||
* `Foo` is a struct
|
||||
* Only the last field of `Foo` has type `T`
|
||||
* Only the last field of `Foo` has type involving `T`
|
||||
* `T` is not part of the type of any other fields
|
||||
* `Bar<T>: Unsize<Bar<U>>`, if the last field of `Foo` has type `Bar<T>`
|
||||
|
||||
Coercions occur at a *coercion site*. Any location that is explicitly typed
|
||||
will cause a coercion to its type. If inference is necessary, the coercion will
|
||||
|
|
|
@ -708,7 +708,7 @@ impl<T: ?Sized> Arc<T> {
|
|||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<T: ?Sized> Drop for Arc<T> {
|
||||
unsafe impl<#[may_dangle] T: ?Sized> Drop for Arc<T> {
|
||||
/// Drops the `Arc`.
|
||||
///
|
||||
/// This will decrement the strong reference count. If the strong reference
|
||||
|
@ -736,7 +736,6 @@ impl<T: ?Sized> Drop for Arc<T> {
|
|||
/// drop(foo); // Doesn't print anything
|
||||
/// drop(foo2); // Prints "dropped!"
|
||||
/// ```
|
||||
#[unsafe_destructor_blind_to_params]
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
// Because `fetch_sub` is already atomic, we do not need to synchronize
|
||||
|
|
|
@ -79,9 +79,10 @@
|
|||
#![feature(const_fn)]
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(custom_attribute)]
|
||||
#![feature(dropck_parametricity)]
|
||||
#![feature(dropck_eyepatch)]
|
||||
#![cfg_attr(not(test), feature(exact_size_is_empty))]
|
||||
#![feature(fundamental)]
|
||||
#![feature(generic_param_attrs)]
|
||||
#![feature(lang_items)]
|
||||
#![feature(needs_allocator)]
|
||||
#![feature(optin_builtin_traits)]
|
||||
|
|
|
@ -539,8 +539,7 @@ impl<T> RawVec<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> Drop for RawVec<T> {
|
||||
#[unsafe_destructor_blind_to_params]
|
||||
unsafe impl<#[may_dangle] T> Drop for RawVec<T> {
|
||||
/// Frees the memory owned by the RawVec *without* trying to Drop its contents.
|
||||
fn drop(&mut self) {
|
||||
let elem_size = mem::size_of::<T>();
|
||||
|
|
|
@ -644,7 +644,7 @@ impl<T: ?Sized> Deref for Rc<T> {
|
|||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<T: ?Sized> Drop for Rc<T> {
|
||||
unsafe impl<#[may_dangle] T: ?Sized> Drop for Rc<T> {
|
||||
/// Drops the `Rc`.
|
||||
///
|
||||
/// This will decrement the strong reference count. If the strong reference
|
||||
|
@ -672,7 +672,6 @@ impl<T: ?Sized> Drop for Rc<T> {
|
|||
/// drop(foo); // Doesn't print anything
|
||||
/// drop(foo2); // Prints "dropped!"
|
||||
/// ```
|
||||
#[unsafe_destructor_blind_to_params]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
let ptr = *self.ptr;
|
||||
|
|
|
@ -30,10 +30,10 @@
|
|||
|
||||
#![feature(alloc)]
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(dropck_eyepatch)]
|
||||
#![feature(heap_api)]
|
||||
#![feature(heap_api)]
|
||||
#![feature(generic_param_attrs)]
|
||||
#![feature(staged_api)]
|
||||
#![feature(dropck_parametricity)]
|
||||
#![cfg_attr(test, feature(test))]
|
||||
|
||||
#![allow(deprecated)]
|
||||
|
@ -258,8 +258,7 @@ impl<T> TypedArena<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> Drop for TypedArena<T> {
|
||||
#[unsafe_destructor_blind_to_params]
|
||||
unsafe impl<#[may_dangle] T> Drop for TypedArena<T> {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
// Determine how much was filled.
|
||||
|
|
|
@ -137,8 +137,7 @@ pub struct BTreeMap<K, V> {
|
|||
}
|
||||
|
||||
#[stable(feature = "btree_drop", since = "1.7.0")]
|
||||
impl<K, V> Drop for BTreeMap<K, V> {
|
||||
#[unsafe_destructor_blind_to_params]
|
||||
unsafe impl<#[may_dangle] K, #[may_dangle] V> Drop for BTreeMap<K, V> {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
for _ in ptr::read(self).into_iter() {
|
||||
|
|
|
@ -35,10 +35,11 @@
|
|||
#![feature(box_syntax)]
|
||||
#![cfg_attr(not(test), feature(char_escape_debug))]
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(dropck_parametricity)]
|
||||
#![feature(dropck_eyepatch)]
|
||||
#![feature(exact_size_is_empty)]
|
||||
#![feature(fmt_internals)]
|
||||
#![feature(fused)]
|
||||
#![feature(generic_param_attrs)]
|
||||
#![feature(heap_api)]
|
||||
#![feature(inclusive_range)]
|
||||
#![feature(lang_items)]
|
||||
|
|
|
@ -726,8 +726,7 @@ impl<T> LinkedList<T> {
|
|||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<T> Drop for LinkedList<T> {
|
||||
#[unsafe_destructor_blind_to_params]
|
||||
unsafe impl<#[may_dangle] T> Drop for LinkedList<T> {
|
||||
fn drop(&mut self) {
|
||||
while let Some(_) = self.pop_front_node() {}
|
||||
}
|
||||
|
|
|
@ -370,7 +370,8 @@ impl<T> Vec<T> {
|
|||
/// * `capacity` needs to be the capacity that the pointer was allocated with.
|
||||
///
|
||||
/// Violating these may cause problems like corrupting the allocator's
|
||||
/// internal datastructures.
|
||||
/// internal datastructures. For example it is **not** safe
|
||||
/// to build a `Vec<u8>` from a pointer to a C `char` array and a `size_t`.
|
||||
///
|
||||
/// The ownership of `ptr` is effectively transferred to the
|
||||
/// `Vec<T>` which may then deallocate, reallocate or change the
|
||||
|
@ -1786,8 +1787,7 @@ impl<T: Ord> Ord for Vec<T> {
|
|||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<T> Drop for Vec<T> {
|
||||
#[unsafe_destructor_blind_to_params]
|
||||
unsafe impl<#[may_dangle] T> Drop for Vec<T> {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
// use drop for [T]
|
||||
|
@ -2056,8 +2056,7 @@ impl<T: Clone> Clone for IntoIter<T> {
|
|||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<T> Drop for IntoIter<T> {
|
||||
#[unsafe_destructor_blind_to_params]
|
||||
unsafe impl<#[may_dangle] T> Drop for IntoIter<T> {
|
||||
fn drop(&mut self) {
|
||||
// destroy the remaining elements
|
||||
for _x in self.by_ref() {}
|
||||
|
|
|
@ -69,8 +69,7 @@ impl<T: Clone> Clone for VecDeque<T> {
|
|||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<T> Drop for VecDeque<T> {
|
||||
#[unsafe_destructor_blind_to_params]
|
||||
unsafe impl<#[may_dangle] T> Drop for VecDeque<T> {
|
||||
fn drop(&mut self) {
|
||||
let (front, back) = self.as_mut_slices();
|
||||
unsafe {
|
||||
|
|
|
@ -192,14 +192,12 @@ fn main() {
|
|||
|
||||
if !target.contains("ios") {
|
||||
sources.extend(&["absvti2.c",
|
||||
"addtf3.c",
|
||||
"addvti3.c",
|
||||
"ashlti3.c",
|
||||
"ashrti3.c",
|
||||
"clzti2.c",
|
||||
"cmpti2.c",
|
||||
"ctzti2.c",
|
||||
"divtf3.c",
|
||||
"divti3.c",
|
||||
"ffsti2.c",
|
||||
"fixdfti.c",
|
||||
|
@ -216,17 +214,13 @@ fn main() {
|
|||
"floatuntixf.c",
|
||||
"lshrti3.c",
|
||||
"modti3.c",
|
||||
"multf3.c",
|
||||
"multi3.c",
|
||||
"mulvti3.c",
|
||||
"negti2.c",
|
||||
"negvti2.c",
|
||||
"parityti2.c",
|
||||
"popcountti2.c",
|
||||
"powitf2.c",
|
||||
"subtf3.c",
|
||||
"subvti3.c",
|
||||
"trampoline_setup.c",
|
||||
"ucmpti2.c",
|
||||
"udivmodti4.c",
|
||||
"udivti3.c",
|
||||
|
|
|
@ -100,13 +100,26 @@ pub trait Sized {
|
|||
///
|
||||
/// All implementations of `Unsize` are provided automatically by the compiler.
|
||||
///
|
||||
/// `Unsize` is implemented for:
|
||||
///
|
||||
/// - `[T; N]` is `Unsize<[T]>`
|
||||
/// - `T` is `Unsize<Trait>` when `T: Trait`
|
||||
/// - `Foo<..., T, ...>` is `Unsize<Foo<..., U, ...>>` if:
|
||||
/// - `T: Unsize<U>`
|
||||
/// - Foo is a struct
|
||||
/// - Only the last field of `Foo` has a type involving `T`
|
||||
/// - `T` is not part of the type of any other fields
|
||||
/// - `Bar<T>: Unsize<Bar<U>>`, if the last field of `Foo` has type `Bar<T>`
|
||||
///
|
||||
/// `Unsize` is used along with [`ops::CoerceUnsized`][coerceunsized] to allow
|
||||
/// "user-defined" containers such as [`rc::Rc`][rc] to contain dynamically-sized
|
||||
/// types. See the [DST coercion RFC][RFC982] for more details.
|
||||
/// types. See the [DST coercion RFC][RFC982] and [the nomicon entry on coercion][nomicon-coerce]
|
||||
/// for more details.
|
||||
///
|
||||
/// [coerceunsized]: ../ops/trait.CoerceUnsized.html
|
||||
/// [rc]: ../../std/rc/struct.Rc.html
|
||||
/// [RFC982]: https://github.com/rust-lang/rfcs/blob/master/text/0982-dst-coercion.md
|
||||
|
||||
#[unstable(feature = "unsize", issue = "27732")]
|
||||
#[lang="unsize"]
|
||||
pub trait Unsize<T: ?Sized> {
|
||||
|
|
|
@ -2710,6 +2710,35 @@ mod impls {
|
|||
|
||||
/// Trait that indicates that this is a pointer or a wrapper for one,
|
||||
/// where unsizing can be performed on the pointee.
|
||||
///
|
||||
/// See the [DST coercion RfC][dst-coerce] and [the nomicon entry on coercion][nomicon-coerce]
|
||||
/// for more details.
|
||||
///
|
||||
/// For builtin pointer types, pointers to `T` will coerce to pointers to `U` if `T: Unsize<U>`
|
||||
/// by converting from a thin pointer to a fat pointer.
|
||||
///
|
||||
/// For custom types, the coercion here works by coercing `Foo<T>` to `Foo<U>`
|
||||
/// provided an impl of `CoerceUnsized<Foo<U>> for Foo<T>` exists.
|
||||
/// Such an impl can only be written if `Foo<T>` has only a single non-phantomdata
|
||||
/// field involving `T`. If the type of that field is `Bar<T>`, an implementation
|
||||
/// of `CoerceUnsized<Bar<U>> for Bar<T>` must exist. The coercion will work by
|
||||
/// by coercing the `Bar<T>` field into `Bar<U>` and filling in the rest of the fields
|
||||
/// from `Foo<T>` to create a `Foo<U>`. This will effectively drill down to a pointer
|
||||
/// field and coerce that.
|
||||
///
|
||||
/// Generally, for smart pointers you will implement
|
||||
/// `CoerceUnsized<Ptr<U>> for Ptr<T> where T: Unsize<U>, U: ?Sized`, with an
|
||||
/// optional `?Sized` bound on `T` itself. For wrapper types that directly embed `T`
|
||||
/// like `Cell<T>` and `RefCell<T>`, you
|
||||
/// can directly implement `CoerceUnsized<Wrap<U>> for Wrap<T> where T: CoerceUnsized<U>`.
|
||||
/// This will let coercions of types like `Cell<Box<T>>` work.
|
||||
///
|
||||
/// [`Unsize`][unsize] is used to mark types which can be coerced to DSTs if behind
|
||||
/// pointers. It is implemented automatically by the compiler.
|
||||
///
|
||||
/// [dst-coerce]: https://github.com/rust-lang/rfcs/blob/master/text/0982-dst-coercion.md
|
||||
/// [unsize]: ../marker/trait.Unsize.html
|
||||
/// [nomicon-coerce]: ../../nomicon/coercions.html
|
||||
#[unstable(feature = "coerce_unsized", issue = "27732")]
|
||||
#[lang="coerce_unsized"]
|
||||
pub trait CoerceUnsized<T> {
|
||||
|
|
|
@ -1175,7 +1175,7 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
|
|||
assumed.", "[KIND=]NAME"),
|
||||
opt::multi_s("", "crate-type", "Comma separated list of types of crates
|
||||
for the compiler to emit",
|
||||
"[bin|lib|rlib|dylib|cdylib|staticlib]"),
|
||||
"[bin|lib|rlib|dylib|cdylib|staticlib|proc-macro]"),
|
||||
opt::opt_s("", "crate-name", "Specify the name of the crate being built",
|
||||
"NAME"),
|
||||
opt::multi_s("", "emit", "Comma separated list of types of output for \
|
||||
|
|
|
@ -1061,8 +1061,7 @@ impl<K: Clone, V: Clone> Clone for RawTable<K, V> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<K, V> Drop for RawTable<K, V> {
|
||||
#[unsafe_destructor_blind_to_params]
|
||||
unsafe impl<#[may_dangle] K, #[may_dangle] V> Drop for RawTable<K, V> {
|
||||
fn drop(&mut self) {
|
||||
if self.capacity == 0 {
|
||||
return;
|
||||
|
|
|
@ -259,6 +259,15 @@ impl OsStr {
|
|||
/// Yields a `&str` slice if the `OsStr` is valid Unicode.
|
||||
///
|
||||
/// This conversion may entail doing a check for UTF-8 validity.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::ffi::OsStr;
|
||||
///
|
||||
/// let os_str = OsStr::new("foo");
|
||||
/// assert_eq!(os_str.to_str(), Some("foo"));
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn to_str(&self) -> Option<&str> {
|
||||
self.inner.to_str()
|
||||
|
@ -267,6 +276,20 @@ impl OsStr {
|
|||
/// Converts an `OsStr` to a `Cow<str>`.
|
||||
///
|
||||
/// Any non-Unicode sequences are replaced with U+FFFD REPLACEMENT CHARACTER.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Calling `to_string_lossy` on an `OsStr` with valid unicode:
|
||||
///
|
||||
/// ```
|
||||
/// use std::ffi::OsStr;
|
||||
///
|
||||
/// let os_str = OsStr::new("foo");
|
||||
/// assert_eq!(os_str.to_string_lossy(), "foo");
|
||||
/// ```
|
||||
///
|
||||
/// Had `os_str` contained invalid unicode, the `to_string_lossy` call might
|
||||
/// have returned `"fo<66>"`.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn to_string_lossy(&self) -> Cow<str> {
|
||||
self.inner.to_string_lossy()
|
||||
|
|
|
@ -250,13 +250,14 @@
|
|||
#![feature(const_fn)]
|
||||
#![feature(core_float)]
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(dropck_parametricity)]
|
||||
#![feature(dropck_eyepatch)]
|
||||
#![feature(exact_size_is_empty)]
|
||||
#![feature(float_extras)]
|
||||
#![feature(float_from_str_radix)]
|
||||
#![feature(fn_traits)]
|
||||
#![feature(fnbox)]
|
||||
#![feature(fused)]
|
||||
#![feature(generic_param_attrs)]
|
||||
#![feature(hashmap_hasher)]
|
||||
#![feature(heap_api)]
|
||||
#![feature(inclusive_range)]
|
||||
|
|
|
@ -52,7 +52,7 @@ pub struct TcpStream(net_imp::TcpStream);
|
|||
/// // ...
|
||||
/// }
|
||||
///
|
||||
/// // accept connections and process them, spawning a new thread for each one
|
||||
/// // accept connections and process them serially
|
||||
/// for stream in listener.incoming() {
|
||||
/// match stream {
|
||||
/// Ok(stream) => {
|
||||
|
|
|
@ -1428,8 +1428,8 @@ impl Path {
|
|||
/// ```
|
||||
/// use std::path::Path;
|
||||
///
|
||||
/// let path_str = Path::new("foo.txt").to_str();
|
||||
/// assert_eq!(path_str, Some("foo.txt"));
|
||||
/// let path = Path::new("foo.txt");
|
||||
/// assert_eq!(path.to_str(), Some("foo.txt"));
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn to_str(&self) -> Option<&str> {
|
||||
|
@ -1444,12 +1444,17 @@ impl Path {
|
|||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Calling `to_string_lossy` on a `Path` with valid unicode:
|
||||
///
|
||||
/// ```
|
||||
/// use std::path::Path;
|
||||
///
|
||||
/// let path_str = Path::new("foo.txt").to_string_lossy();
|
||||
/// assert_eq!(path_str, "foo.txt");
|
||||
/// let path = Path::new("foo.txt");
|
||||
/// assert_eq!(path.to_string_lossy(), "foo.txt");
|
||||
/// ```
|
||||
///
|
||||
/// Had `os_str` contained invalid unicode, the `to_string_lossy` call might
|
||||
/// have returned `"fo<66>.txt"`.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn to_string_lossy(&self) -> Cow<str> {
|
||||
self.inner.to_string_lossy()
|
||||
|
|
|
@ -502,7 +502,7 @@ mod prim_str { }
|
|||
/// [`Hash`]: hash/trait.Hash.html
|
||||
///
|
||||
/// Due to a temporary restriction in Rust's type system, these traits are only
|
||||
/// implemented on tuples of arity 32 or less. In the future, this may change.
|
||||
/// implemented on tuples of arity 12 or less. In the future, this may change.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
|
@ -280,8 +280,7 @@ impl<T: ?Sized> Mutex<T> {
|
|||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<T: ?Sized> Drop for Mutex<T> {
|
||||
#[unsafe_destructor_blind_to_params]
|
||||
unsafe impl<#[may_dangle] T: ?Sized> Drop for Mutex<T> {
|
||||
fn drop(&mut self) {
|
||||
// This is actually safe b/c we know that there is no further usage of
|
||||
// this mutex (it's up to the user to arrange for a mutex to get
|
||||
|
|
|
@ -310,8 +310,7 @@ impl<T: ?Sized> RwLock<T> {
|
|||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<T: ?Sized> Drop for RwLock<T> {
|
||||
#[unsafe_destructor_blind_to_params]
|
||||
unsafe impl<#[may_dangle] T: ?Sized> Drop for RwLock<T> {
|
||||
fn drop(&mut self) {
|
||||
// IMPORTANT: This code needs to be kept in sync with `RwLock::into_inner`.
|
||||
unsafe { self.inner.destroy() }
|
||||
|
|
|
@ -402,3 +402,155 @@ impl ChangeArgumentTypeTrait for Foo {
|
|||
fn method_name(&self, _x: char) { }
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct Bar<T>(T);
|
||||
|
||||
// Add Type Parameter To Impl --------------------------------------------------
|
||||
trait AddTypeParameterToImpl<T> {
|
||||
fn id(t: T) -> T;
|
||||
}
|
||||
|
||||
#[cfg(cfail1)]
|
||||
impl AddTypeParameterToImpl<u32> for Bar<u32> {
|
||||
fn id(t: u32) -> u32 { t }
|
||||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_dirty(label="Hir", cfg="cfail2")]
|
||||
#[rustc_clean(label="Hir", cfg="cfail3")]
|
||||
#[rustc_metadata_dirty(cfg="cfail2")]
|
||||
#[rustc_metadata_clean(cfg="cfail3")]
|
||||
impl<T> AddTypeParameterToImpl<T> for Bar<T> {
|
||||
#[rustc_dirty(label="Hir", cfg="cfail2")]
|
||||
#[rustc_clean(label="Hir", cfg="cfail3")]
|
||||
#[rustc_metadata_dirty(cfg="cfail2")]
|
||||
#[rustc_metadata_clean(cfg="cfail3")]
|
||||
fn id(t: T) -> T { t }
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Change Self Type of Impl ----------------------------------------------------
|
||||
trait ChangeSelfTypeOfImpl {
|
||||
fn id(self) -> Self;
|
||||
}
|
||||
|
||||
#[cfg(cfail1)]
|
||||
impl ChangeSelfTypeOfImpl for u32 {
|
||||
fn id(self) -> Self { self }
|
||||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_dirty(label="Hir", cfg="cfail2")]
|
||||
#[rustc_clean(label="Hir", cfg="cfail3")]
|
||||
#[rustc_metadata_dirty(cfg="cfail2")]
|
||||
#[rustc_metadata_clean(cfg="cfail3")]
|
||||
impl ChangeSelfTypeOfImpl for u64 {
|
||||
#[rustc_dirty(label="Hir", cfg="cfail2")]
|
||||
#[rustc_clean(label="Hir", cfg="cfail3")]
|
||||
#[rustc_metadata_dirty(cfg="cfail2")]
|
||||
#[rustc_metadata_clean(cfg="cfail3")]
|
||||
fn id(self) -> Self { self }
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Add Lifetime Bound to Impl --------------------------------------------------
|
||||
trait AddLifetimeBoundToImplParameter {
|
||||
fn id(self) -> Self;
|
||||
}
|
||||
|
||||
#[cfg(cfail1)]
|
||||
impl<T> AddLifetimeBoundToImplParameter for T {
|
||||
fn id(self) -> Self { self }
|
||||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_dirty(label="Hir", cfg="cfail2")]
|
||||
#[rustc_clean(label="Hir", cfg="cfail3")]
|
||||
#[rustc_metadata_dirty(cfg="cfail2")]
|
||||
#[rustc_metadata_clean(cfg="cfail3")]
|
||||
impl<T: 'static> AddLifetimeBoundToImplParameter for T {
|
||||
#[rustc_dirty(label="Hir", cfg="cfail2")]
|
||||
#[rustc_clean(label="Hir", cfg="cfail3")]
|
||||
#[rustc_metadata_dirty(cfg="cfail2")]
|
||||
#[rustc_metadata_clean(cfg="cfail3")]
|
||||
fn id(self) -> Self { self }
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Add Trait Bound to Impl Parameter -------------------------------------------
|
||||
trait AddTraitBoundToImplParameter {
|
||||
fn id(self) -> Self;
|
||||
}
|
||||
|
||||
#[cfg(cfail1)]
|
||||
impl<T> AddTraitBoundToImplParameter for T {
|
||||
fn id(self) -> Self { self }
|
||||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_dirty(label="Hir", cfg="cfail2")]
|
||||
#[rustc_clean(label="Hir", cfg="cfail3")]
|
||||
#[rustc_metadata_dirty(cfg="cfail2")]
|
||||
#[rustc_metadata_clean(cfg="cfail3")]
|
||||
impl<T: Clone> AddTraitBoundToImplParameter for T {
|
||||
#[rustc_dirty(label="Hir", cfg="cfail2")]
|
||||
#[rustc_clean(label="Hir", cfg="cfail3")]
|
||||
#[rustc_metadata_dirty(cfg="cfail2")]
|
||||
#[rustc_metadata_clean(cfg="cfail3")]
|
||||
fn id(self) -> Self { self }
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Add #[no_mangle] to Method --------------------------------------------------
|
||||
trait AddNoMangleToMethod {
|
||||
fn add_no_mangle_to_method(&self) { }
|
||||
}
|
||||
|
||||
#[cfg(cfail1)]
|
||||
impl AddNoMangleToMethod for Foo {
|
||||
fn add_no_mangle_to_method(&self) { }
|
||||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(label="Hir", cfg="cfail2")]
|
||||
#[rustc_clean(label="Hir", cfg="cfail3")]
|
||||
#[rustc_metadata_clean(cfg="cfail2")]
|
||||
#[rustc_metadata_clean(cfg="cfail3")]
|
||||
impl AddNoMangleToMethod for Foo {
|
||||
#[rustc_dirty(label="Hir", cfg="cfail2")]
|
||||
#[rustc_clean(label="Hir", cfg="cfail3")]
|
||||
#[rustc_metadata_dirty(cfg="cfail2")]
|
||||
#[rustc_metadata_clean(cfg="cfail3")]
|
||||
#[no_mangle]
|
||||
fn add_no_mangle_to_method(&self) { }
|
||||
}
|
||||
|
||||
|
||||
// Make Method #[inline] -------------------------------------------------------
|
||||
trait MakeMethodInline {
|
||||
fn make_method_inline(&self) -> u8 { 0 }
|
||||
}
|
||||
|
||||
#[cfg(cfail1)]
|
||||
impl MakeMethodInline for Foo {
|
||||
fn make_method_inline(&self) -> u8 { 0 }
|
||||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(label="Hir", cfg="cfail2")]
|
||||
#[rustc_clean(label="Hir", cfg="cfail3")]
|
||||
#[rustc_metadata_clean(cfg="cfail2")]
|
||||
#[rustc_metadata_clean(cfg="cfail3")]
|
||||
impl MakeMethodInline for Foo {
|
||||
#[rustc_dirty(label="Hir", cfg="cfail2")]
|
||||
#[rustc_clean(label="Hir", cfg="cfail3")]
|
||||
#[rustc_metadata_dirty(cfg="cfail2")]
|
||||
#[rustc_metadata_clean(cfg="cfail3")]
|
||||
#[inline]
|
||||
fn make_method_inline(&self) -> u8 { 0 }
|
||||
}
|
||||
|
|
28
src/test/ui/custom-derive/auxiliary/plugin.rs
Normal file
28
src/test/ui/custom-derive/auxiliary/plugin.rs
Normal file
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2016 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.
|
||||
|
||||
// no-prefer-dynamic
|
||||
|
||||
#![crate_type = "proc-macro"]
|
||||
#![feature(proc_macro, proc_macro_lib)]
|
||||
|
||||
extern crate proc_macro;
|
||||
|
||||
use proc_macro::TokenStream;
|
||||
|
||||
#[proc_macro_derive(Foo)]
|
||||
pub fn derive_foo(input: TokenStream) -> TokenStream {
|
||||
input
|
||||
}
|
||||
|
||||
#[proc_macro_derive(Bar)]
|
||||
pub fn derive_bar(input: TokenStream) -> TokenStream {
|
||||
panic!("lolnope");
|
||||
}
|
23
src/test/ui/custom-derive/issue-36935.rs
Normal file
23
src/test/ui/custom-derive/issue-36935.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2016 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.
|
||||
|
||||
// aux-build:plugin.rs
|
||||
|
||||
#![feature(proc_macro)]
|
||||
|
||||
#[macro_use] extern crate plugin;
|
||||
|
||||
#[derive(Foo, Bar)]
|
||||
struct Baz {
|
||||
a: i32,
|
||||
b: i32,
|
||||
}
|
||||
|
||||
fn main() {}
|
8
src/test/ui/custom-derive/issue-36935.stderr
Normal file
8
src/test/ui/custom-derive/issue-36935.stderr
Normal file
|
@ -0,0 +1,8 @@
|
|||
error: custom derive attribute panicked
|
||||
--> $DIR/issue-36935.rs:17:15
|
||||
|
|
||||
17 | #[derive(Foo, Bar)]
|
||||
| ^^^
|
||||
|
|
||||
= help: message: lolnope
|
||||
|
19
src/test/ui/span/issue-27522.rs
Normal file
19
src/test/ui/span/issue-27522.rs
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Copyright 2016 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.
|
||||
|
||||
// Point at correct span for self type
|
||||
|
||||
struct SomeType {}
|
||||
|
||||
trait Foo {
|
||||
fn handler(self: &SomeType);
|
||||
}
|
||||
|
||||
fn main() {}
|
11
src/test/ui/span/issue-27522.stderr
Normal file
11
src/test/ui/span/issue-27522.stderr
Normal file
|
@ -0,0 +1,11 @@
|
|||
error[E0308]: mismatched method receiver
|
||||
--> $DIR/issue-27522.rs:16:22
|
||||
|
|
||||
16 | fn handler(self: &SomeType);
|
||||
| ^^^^^^^^^ expected Self, found struct `SomeType`
|
||||
|
|
||||
= note: expected type `&Self`
|
||||
= note: found type `&SomeType`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
Loading…
Add table
Reference in a new issue