Auto merge of #131284 - dingxiangfei2009:rename-smart-ptr-to-coerce-referent, r=compiler-errors
Rename macro `SmartPointer` to `CoercePointee` As per resolution #129104 we will rename the macro to better reflect the technical specification of the feature and clarify the communication. - `SmartPointer` is renamed to `CoerceReferent` - `#[pointee]` attribute is renamed to `#[referent]` - `#![feature(derive_smart_pointer)]` gate is renamed to `#![feature(derive_coerce_referent)]`. - Any mention of `SmartPointer` in the file names are renamed accordingly. r? `@compiler-errors` cc `@nikomatsakis` `@Darksonn`
This commit is contained in:
commit
81d6652e74
@ -19,7 +19,7 @@ macro_rules! path {
|
|||||||
($span:expr, $($part:ident)::*) => { vec![$(Ident::new(sym::$part, $span),)*] }
|
($span:expr, $($part:ident)::*) => { vec![$(Ident::new(sym::$part, $span),)*] }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn expand_deriving_smart_ptr(
|
pub(crate) fn expand_deriving_coerce_pointee(
|
||||||
cx: &ExtCtxt<'_>,
|
cx: &ExtCtxt<'_>,
|
||||||
span: Span,
|
span: Span,
|
||||||
_mitem: &MetaItem,
|
_mitem: &MetaItem,
|
||||||
@ -41,7 +41,7 @@ pub(crate) fn expand_deriving_smart_ptr(
|
|||||||
cx.dcx()
|
cx.dcx()
|
||||||
.struct_span_err(
|
.struct_span_err(
|
||||||
span,
|
span,
|
||||||
"`SmartPointer` can only be derived on `struct`s with `#[repr(transparent)]`",
|
"`CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]`",
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
return;
|
return;
|
||||||
@ -54,7 +54,7 @@ pub(crate) fn expand_deriving_smart_ptr(
|
|||||||
cx.dcx()
|
cx.dcx()
|
||||||
.struct_span_err(
|
.struct_span_err(
|
||||||
span,
|
span,
|
||||||
"`SmartPointer` can only be derived on `struct`s with at least one field",
|
"`CoercePointee` can only be derived on `struct`s with at least one field",
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
return;
|
return;
|
||||||
@ -64,7 +64,7 @@ pub(crate) fn expand_deriving_smart_ptr(
|
|||||||
cx.dcx()
|
cx.dcx()
|
||||||
.struct_span_err(
|
.struct_span_err(
|
||||||
span,
|
span,
|
||||||
"`SmartPointer` can only be derived on `struct`s with `#[repr(transparent)]`",
|
"`CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]`",
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
return;
|
return;
|
||||||
@ -94,10 +94,10 @@ pub(crate) fn expand_deriving_smart_ptr(
|
|||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let pointee_param_idx = if type_params.is_empty() {
|
let pointee_param_idx = if type_params.is_empty() {
|
||||||
// `#[derive(SmartPointer)]` requires at least one generic type on the target `struct`
|
// `#[derive(CoercePointee)]` requires at least one generic type on the target `struct`
|
||||||
cx.dcx().struct_span_err(
|
cx.dcx().struct_span_err(
|
||||||
span,
|
span,
|
||||||
"`SmartPointer` can only be derived on `struct`s that are generic over at least one type",
|
"`CoercePointee` can only be derived on `struct`s that are generic over at least one type",
|
||||||
).emit();
|
).emit();
|
||||||
return;
|
return;
|
||||||
} else if type_params.len() == 1 {
|
} else if type_params.len() == 1 {
|
||||||
@ -113,7 +113,7 @@ pub(crate) fn expand_deriving_smart_ptr(
|
|||||||
(None, _) => {
|
(None, _) => {
|
||||||
cx.dcx().struct_span_err(
|
cx.dcx().struct_span_err(
|
||||||
span,
|
span,
|
||||||
"exactly one generic type parameter must be marked as #[pointee] to derive SmartPointer traits",
|
"exactly one generic type parameter must be marked as #[pointee] to derive CoercePointee traits",
|
||||||
).emit();
|
).emit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ pub(crate) fn expand_deriving_smart_ptr(
|
|||||||
cx.dcx()
|
cx.dcx()
|
||||||
.struct_span_err(
|
.struct_span_err(
|
||||||
vec![one, another],
|
vec![one, another],
|
||||||
"only one type parameter can be marked as `#[pointee]` when deriving SmartPointer traits",
|
"only one type parameter can be marked as `#[pointee]` when deriving CoercePointee traits",
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
return;
|
return;
|
||||||
@ -185,7 +185,7 @@ pub(crate) fn expand_deriving_smart_ptr(
|
|||||||
.struct_span_err(
|
.struct_span_err(
|
||||||
pointee_ty_ident.span,
|
pointee_ty_ident.span,
|
||||||
format!(
|
format!(
|
||||||
"`derive(SmartPointer)` requires {} to be marked `?Sized`",
|
"`derive(CoercePointee)` requires {} to be marked `?Sized`",
|
||||||
pointee_ty_ident.name
|
pointee_ty_ident.name
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -195,7 +195,7 @@ pub(crate) fn expand_deriving_smart_ptr(
|
|||||||
let arg = GenericArg::Type(s_ty.clone());
|
let arg = GenericArg::Type(s_ty.clone());
|
||||||
let unsize = cx.path_all(span, true, path!(span, core::marker::Unsize), vec![arg]);
|
let unsize = cx.path_all(span, true, path!(span, core::marker::Unsize), vec![arg]);
|
||||||
pointee.bounds.push(cx.trait_bound(unsize, false));
|
pointee.bounds.push(cx.trait_bound(unsize, false));
|
||||||
// Drop `#[pointee]` attribute since it should not be recognized outside `derive(SmartPointer)`
|
// Drop `#[pointee]` attribute since it should not be recognized outside `derive(CoercePointee)`
|
||||||
pointee.attrs.retain(|attr| !attr.has_name(sym::pointee));
|
pointee.attrs.retain(|attr| !attr.has_name(sym::pointee));
|
||||||
}
|
}
|
||||||
|
|
@ -22,12 +22,12 @@
|
|||||||
|
|
||||||
pub(crate) mod bounds;
|
pub(crate) mod bounds;
|
||||||
pub(crate) mod clone;
|
pub(crate) mod clone;
|
||||||
|
pub(crate) mod coerce_pointee;
|
||||||
pub(crate) mod debug;
|
pub(crate) mod debug;
|
||||||
pub(crate) mod decodable;
|
pub(crate) mod decodable;
|
||||||
pub(crate) mod default;
|
pub(crate) mod default;
|
||||||
pub(crate) mod encodable;
|
pub(crate) mod encodable;
|
||||||
pub(crate) mod hash;
|
pub(crate) mod hash;
|
||||||
pub(crate) mod smart_ptr;
|
|
||||||
|
|
||||||
#[path = "cmp/eq.rs"]
|
#[path = "cmp/eq.rs"]
|
||||||
pub(crate) mod eq;
|
pub(crate) mod eq;
|
||||||
|
@ -133,7 +133,7 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
|
|||||||
PartialOrd: partial_ord::expand_deriving_partial_ord,
|
PartialOrd: partial_ord::expand_deriving_partial_ord,
|
||||||
RustcDecodable: decodable::expand_deriving_rustc_decodable,
|
RustcDecodable: decodable::expand_deriving_rustc_decodable,
|
||||||
RustcEncodable: encodable::expand_deriving_rustc_encodable,
|
RustcEncodable: encodable::expand_deriving_rustc_encodable,
|
||||||
SmartPointer: smart_ptr::expand_deriving_smart_ptr,
|
CoercePointee: coerce_pointee::expand_deriving_coerce_pointee,
|
||||||
}
|
}
|
||||||
|
|
||||||
let client = proc_macro::bridge::client::Client::expand1(proc_macro::quote);
|
let client = proc_macro::bridge::client::Client::expand1(proc_macro::quote);
|
||||||
|
@ -85,6 +85,8 @@ macro_rules! declare_features {
|
|||||||
/// Allows default type parameters to influence type inference.
|
/// Allows default type parameters to influence type inference.
|
||||||
(removed, default_type_parameter_fallback, "1.82.0", Some(27336),
|
(removed, default_type_parameter_fallback, "1.82.0", Some(27336),
|
||||||
Some("never properly implemented; requires significant design work")),
|
Some("never properly implemented; requires significant design work")),
|
||||||
|
/// Allows deriving traits as per `SmartPointer` specification
|
||||||
|
(removed, derive_smart_pointer, "1.79.0", Some(123430), Some("replaced by `CoercePointee`")),
|
||||||
/// Allows using `#[doc(keyword = "...")]`.
|
/// Allows using `#[doc(keyword = "...")]`.
|
||||||
(removed, doc_keyword, "1.28.0", Some(51315),
|
(removed, doc_keyword, "1.28.0", Some(51315),
|
||||||
Some("merged into `#![feature(rustdoc_internals)]`")),
|
Some("merged into `#![feature(rustdoc_internals)]`")),
|
||||||
|
@ -450,8 +450,6 @@ pub fn internal(&self, feature: Symbol) -> bool {
|
|||||||
(unstable, deprecated_suggestion, "1.61.0", Some(94785)),
|
(unstable, deprecated_suggestion, "1.61.0", Some(94785)),
|
||||||
/// Allows deref patterns.
|
/// Allows deref patterns.
|
||||||
(incomplete, deref_patterns, "1.79.0", Some(87121)),
|
(incomplete, deref_patterns, "1.79.0", Some(87121)),
|
||||||
/// Allows deriving `SmartPointer` traits
|
|
||||||
(unstable, derive_smart_pointer, "1.79.0", Some(123430)),
|
|
||||||
/// Controls errors in trait implementations.
|
/// Controls errors in trait implementations.
|
||||||
(unstable, do_not_recommend, "1.67.0", Some(51992)),
|
(unstable, do_not_recommend, "1.67.0", Some(51992)),
|
||||||
/// Tells rustdoc to automatically generate `#[doc(cfg(...))]`.
|
/// Tells rustdoc to automatically generate `#[doc(cfg(...))]`.
|
||||||
|
@ -262,7 +262,7 @@ fn check_attributes(
|
|||||||
| sym::cfg_attr
|
| sym::cfg_attr
|
||||||
// need to be fixed
|
// need to be fixed
|
||||||
| sym::cfi_encoding // FIXME(cfi_encoding)
|
| sym::cfi_encoding // FIXME(cfi_encoding)
|
||||||
| sym::pointee // FIXME(derive_smart_pointer)
|
| sym::pointee // FIXME(derive_coerce_pointee)
|
||||||
| sym::omit_gdb_pretty_printer_section // FIXME(omit_gdb_pretty_printer_section)
|
| sym::omit_gdb_pretty_printer_section // FIXME(omit_gdb_pretty_printer_section)
|
||||||
| sym::used // handled elsewhere to restrict to static items
|
| sym::used // handled elsewhere to restrict to static items
|
||||||
| sym::repr // handled elsewhere to restrict to type decls items
|
| sym::repr // handled elsewhere to restrict to type decls items
|
||||||
|
@ -174,6 +174,7 @@
|
|||||||
Center,
|
Center,
|
||||||
Cleanup,
|
Cleanup,
|
||||||
Clone,
|
Clone,
|
||||||
|
CoercePointee,
|
||||||
CoerceUnsized,
|
CoerceUnsized,
|
||||||
Command,
|
Command,
|
||||||
ConstParamTy,
|
ConstParamTy,
|
||||||
@ -307,7 +308,6 @@
|
|||||||
Sized,
|
Sized,
|
||||||
SliceIndex,
|
SliceIndex,
|
||||||
SliceIter,
|
SliceIter,
|
||||||
SmartPointer,
|
|
||||||
Some,
|
Some,
|
||||||
SpanCtxt,
|
SpanCtxt,
|
||||||
String,
|
String,
|
||||||
@ -732,6 +732,7 @@
|
|||||||
deref_pure,
|
deref_pure,
|
||||||
deref_target,
|
deref_target,
|
||||||
derive,
|
derive,
|
||||||
|
derive_coerce_pointee,
|
||||||
derive_const,
|
derive_const,
|
||||||
derive_default_enum,
|
derive_default_enum,
|
||||||
derive_smart_pointer,
|
derive_smart_pointer,
|
||||||
|
@ -1063,9 +1063,10 @@ pub trait FnPtr: Copy + Clone {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Derive macro generating impls of traits related to smart pointers.
|
/// Derive macro generating impls of traits related to smart pointers.
|
||||||
#[rustc_builtin_macro(SmartPointer, attributes(pointee))]
|
#[rustc_builtin_macro(CoercePointee, attributes(pointee))]
|
||||||
#[allow_internal_unstable(dispatch_from_dyn, coerce_unsized, unsize)]
|
#[allow_internal_unstable(dispatch_from_dyn, coerce_unsized, unsize)]
|
||||||
#[unstable(feature = "derive_smart_pointer", issue = "123430")]
|
#[unstable(feature = "derive_coerce_pointee", issue = "123430")]
|
||||||
pub macro SmartPointer($item:item) {
|
#[cfg(not(bootstrap))]
|
||||||
|
pub macro CoercePointee($item:item) {
|
||||||
/* compiler built-in */
|
/* compiler built-in */
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
extern crate proc_macro;
|
extern crate proc_macro;
|
||||||
|
|
||||||
use proc_macro::{quote, TokenStream};
|
use proc_macro::{TokenStream, quote};
|
||||||
|
|
||||||
#[proc_macro_derive(AnotherMacro, attributes(pointee))]
|
#[proc_macro_derive(AnotherMacro, attributes(pointee))]
|
||||||
pub fn derive(_input: TokenStream) -> TokenStream {
|
pub fn derive(_input: TokenStream) -> TokenStream {
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
//@ aux-build: another-proc-macro.rs
|
//@ aux-build: another-proc-macro.rs
|
||||||
//@ compile-flags: -Zunpretty=expanded
|
//@ compile-flags: -Zunpretty=expanded
|
||||||
|
|
||||||
#![feature(derive_smart_pointer)]
|
#![feature(derive_coerce_pointee)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate another_proc_macro;
|
extern crate another_proc_macro;
|
||||||
|
|
||||||
use another_proc_macro::{pointee, AnotherMacro};
|
use another_proc_macro::{AnotherMacro, pointee};
|
||||||
|
|
||||||
#[derive(core::marker::SmartPointer)]
|
#[derive(core::marker::CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct Ptr<'a, #[pointee] T: ?Sized> {
|
pub struct Ptr<'a, #[pointee] T: ?Sized> {
|
||||||
data: &'a mut T,
|
data: &'a mut T,
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
//@ aux-build: another-proc-macro.rs
|
//@ aux-build: another-proc-macro.rs
|
||||||
//@ compile-flags: -Zunpretty=expanded
|
//@ compile-flags: -Zunpretty=expanded
|
||||||
|
|
||||||
#![feature(derive_smart_pointer)]
|
#![feature(derive_coerce_pointee)]
|
||||||
#[prelude_import]
|
#[prelude_import]
|
||||||
use ::std::prelude::rust_2015::*;
|
use ::std::prelude::rust_2015::*;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
@ -13,7 +13,7 @@ extern crate std;
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate another_proc_macro;
|
extern crate another_proc_macro;
|
||||||
|
|
||||||
use another_proc_macro::{pointee, AnotherMacro};
|
use another_proc_macro::{AnotherMacro, pointee};
|
||||||
|
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct Ptr<'a, #[pointee] T: ?Sized> {
|
pub struct Ptr<'a, #[pointee] T: ?Sized> {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
//@ check-pass
|
//@ check-pass
|
||||||
|
|
||||||
#![feature(derive_smart_pointer)]
|
#![feature(derive_coerce_pointee)]
|
||||||
|
|
||||||
#[derive(core::marker::SmartPointer)]
|
#[derive(core::marker::CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct Ptr<'a, #[pointee] T: OnDrop + ?Sized, X> {
|
pub struct Ptr<'a, #[pointee] T: OnDrop + ?Sized, X> {
|
||||||
data: &'a mut T,
|
data: &'a mut T,
|
||||||
@ -13,7 +13,7 @@ pub trait OnDrop {
|
|||||||
fn on_drop(&mut self);
|
fn on_drop(&mut self);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(core::marker::SmartPointer)]
|
#[derive(core::marker::CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct Ptr2<'a, #[pointee] T: ?Sized, X>
|
pub struct Ptr2<'a, #[pointee] T: ?Sized, X>
|
||||||
where
|
where
|
||||||
@ -25,7 +25,7 @@ pub struct Ptr2<'a, #[pointee] T: ?Sized, X>
|
|||||||
|
|
||||||
pub trait MyTrait<T: ?Sized> {}
|
pub trait MyTrait<T: ?Sized> {}
|
||||||
|
|
||||||
#[derive(core::marker::SmartPointer)]
|
#[derive(core::marker::CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct Ptr3<'a, #[pointee] T: ?Sized, X>
|
pub struct Ptr3<'a, #[pointee] T: ?Sized, X>
|
||||||
where
|
where
|
||||||
@ -35,14 +35,14 @@ pub struct Ptr3<'a, #[pointee] T: ?Sized, X>
|
|||||||
x: core::marker::PhantomData<X>,
|
x: core::marker::PhantomData<X>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(core::marker::SmartPointer)]
|
#[derive(core::marker::CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct Ptr4<'a, #[pointee] T: MyTrait<T> + ?Sized, X> {
|
pub struct Ptr4<'a, #[pointee] T: MyTrait<T> + ?Sized, X> {
|
||||||
data: &'a mut T,
|
data: &'a mut T,
|
||||||
x: core::marker::PhantomData<X>,
|
x: core::marker::PhantomData<X>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(core::marker::SmartPointer)]
|
#[derive(core::marker::CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct Ptr5<'a, #[pointee] T: ?Sized, X>
|
pub struct Ptr5<'a, #[pointee] T: ?Sized, X>
|
||||||
where
|
where
|
||||||
@ -56,7 +56,7 @@ pub struct Ptr5<'a, #[pointee] T: ?Sized, X>
|
|||||||
pub struct Ptr5Companion<T: ?Sized>(core::marker::PhantomData<T>);
|
pub struct Ptr5Companion<T: ?Sized>(core::marker::PhantomData<T>);
|
||||||
pub struct Ptr5Companion2;
|
pub struct Ptr5Companion2;
|
||||||
|
|
||||||
#[derive(core::marker::SmartPointer)]
|
#[derive(core::marker::CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct Ptr6<'a, #[pointee] T: ?Sized, X: MyTrait<T> = (), const PARAM: usize = 0> {
|
pub struct Ptr6<'a, #[pointee] T: ?Sized, X: MyTrait<T> = (), const PARAM: usize = 0> {
|
||||||
data: &'a mut T,
|
data: &'a mut T,
|
||||||
@ -65,7 +65,7 @@ pub struct Ptr6<'a, #[pointee] T: ?Sized, X: MyTrait<T> = (), const PARAM: usize
|
|||||||
|
|
||||||
// a reduced example from https://lore.kernel.org/all/20240402-linked-list-v1-1-b1c59ba7ae3b@google.com/
|
// a reduced example from https://lore.kernel.org/all/20240402-linked-list-v1-1-b1c59ba7ae3b@google.com/
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(core::marker::SmartPointer)]
|
#[derive(core::marker::CoercePointee)]
|
||||||
pub struct ListArc<#[pointee] T, const ID: u64 = 0>
|
pub struct ListArc<#[pointee] T, const ID: u64 = 0>
|
||||||
where
|
where
|
||||||
T: ListArcSafe<ID> + ?Sized,
|
T: ListArcSafe<ID> + ?Sized,
|
@ -1,17 +1,17 @@
|
|||||||
//@ check-pass
|
//@ check-pass
|
||||||
//@ compile-flags: -Zunpretty=expanded
|
//@ compile-flags: -Zunpretty=expanded
|
||||||
#![feature(derive_smart_pointer)]
|
#![feature(derive_coerce_pointee)]
|
||||||
use std::marker::SmartPointer;
|
use std::marker::CoercePointee;
|
||||||
|
|
||||||
pub trait MyTrait<T: ?Sized> {}
|
pub trait MyTrait<T: ?Sized> {}
|
||||||
|
|
||||||
#[derive(SmartPointer)]
|
#[derive(CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
struct MyPointer<'a, #[pointee] T: ?Sized> {
|
struct MyPointer<'a, #[pointee] T: ?Sized> {
|
||||||
ptr: &'a T,
|
ptr: &'a T,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(core::marker::SmartPointer)]
|
#[derive(core::marker::CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct MyPointer2<'a, Y, Z: MyTrait<T>, #[pointee] T: ?Sized + MyTrait<T>, X: MyTrait<T> = ()>
|
pub struct MyPointer2<'a, Y, Z: MyTrait<T>, #[pointee] T: ?Sized + MyTrait<T>, X: MyTrait<T> = ()>
|
||||||
where
|
where
|
||||||
@ -21,7 +21,7 @@ pub struct MyPointer2<'a, Y, Z: MyTrait<T>, #[pointee] T: ?Sized + MyTrait<T>, X
|
|||||||
x: core::marker::PhantomData<X>,
|
x: core::marker::PhantomData<X>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SmartPointer)]
|
#[derive(CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
struct MyPointerWithoutPointee<'a, T: ?Sized> {
|
struct MyPointerWithoutPointee<'a, T: ?Sized> {
|
||||||
ptr: &'a T,
|
ptr: &'a T,
|
@ -2,12 +2,12 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
//@ check-pass
|
//@ check-pass
|
||||||
//@ compile-flags: -Zunpretty=expanded
|
//@ compile-flags: -Zunpretty=expanded
|
||||||
#![feature(derive_smart_pointer)]
|
#![feature(derive_coerce_pointee)]
|
||||||
#[prelude_import]
|
#[prelude_import]
|
||||||
use ::std::prelude::rust_2015::*;
|
use ::std::prelude::rust_2015::*;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate std;
|
extern crate std;
|
||||||
use std::marker::SmartPointer;
|
use std::marker::CoercePointee;
|
||||||
|
|
||||||
pub trait MyTrait<T: ?Sized> {}
|
pub trait MyTrait<T: ?Sized> {}
|
||||||
|
|
@ -1,115 +1,131 @@
|
|||||||
#![feature(derive_smart_pointer, arbitrary_self_types)]
|
#![feature(derive_coerce_pointee, arbitrary_self_types)]
|
||||||
|
|
||||||
extern crate core;
|
extern crate core;
|
||||||
use std::marker::SmartPointer;
|
use std::marker::CoercePointee;
|
||||||
|
|
||||||
#[derive(SmartPointer)]
|
#[derive(CoercePointee)]
|
||||||
//~^ ERROR: `SmartPointer` can only be derived on `struct`s with `#[repr(transparent)]`
|
//~^ ERROR: `CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]`
|
||||||
enum NotStruct<'a, T: ?Sized> {
|
enum NotStruct<'a, T: ?Sized> {
|
||||||
Variant(&'a T),
|
Variant(&'a T),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SmartPointer)]
|
#[derive(CoercePointee)]
|
||||||
//~^ ERROR: `SmartPointer` can only be derived on `struct`s with at least one field
|
//~^ ERROR: `CoercePointee` can only be derived on `struct`s with at least one field
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
struct NoField<'a, #[pointee] T: ?Sized> {}
|
struct NoField<'a, #[pointee] T: ?Sized> {}
|
||||||
//~^ ERROR: lifetime parameter `'a` is never used
|
//~^ ERROR: lifetime parameter `'a` is never used
|
||||||
//~| ERROR: type parameter `T` is never used
|
//~| ERROR: type parameter `T` is never used
|
||||||
|
|
||||||
#[derive(SmartPointer)]
|
#[derive(CoercePointee)]
|
||||||
//~^ ERROR: `SmartPointer` can only be derived on `struct`s with at least one field
|
//~^ ERROR: `CoercePointee` can only be derived on `struct`s with at least one field
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
struct NoFieldUnit<'a, #[pointee] T: ?Sized>();
|
struct NoFieldUnit<'a, #[pointee] T: ?Sized>();
|
||||||
//~^ ERROR: lifetime parameter `'a` is never used
|
//~^ ERROR: lifetime parameter `'a` is never used
|
||||||
//~| ERROR: type parameter `T` is never used
|
//~| ERROR: type parameter `T` is never used
|
||||||
|
|
||||||
#[derive(SmartPointer)]
|
#[derive(CoercePointee)]
|
||||||
//~^ ERROR: `SmartPointer` can only be derived on `struct`s that are generic over at least one type
|
//~^ ERROR: `CoercePointee` can only be derived on `struct`s that are generic over at least one type
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
struct NoGeneric<'a>(&'a u8);
|
struct NoGeneric<'a>(&'a u8);
|
||||||
|
|
||||||
#[derive(SmartPointer)]
|
#[derive(CoercePointee)]
|
||||||
//~^ ERROR: exactly one generic type parameter must be marked as #[pointee] to derive SmartPointer traits
|
//~^ ERROR: exactly one generic type parameter must be marked as #[pointee] to derive CoercePointee traits
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
struct AmbiguousPointee<'a, T1: ?Sized, T2: ?Sized> {
|
struct AmbiguousPointee<'a, T1: ?Sized, T2: ?Sized> {
|
||||||
a: (&'a T1, &'a T2),
|
a: (&'a T1, &'a T2),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SmartPointer)]
|
#[derive(CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
struct TooManyPointees<'a, #[pointee] A: ?Sized, #[pointee] B: ?Sized>((&'a A, &'a B));
|
struct TooManyPointees<'a, #[pointee] A: ?Sized, #[pointee] B: ?Sized>((&'a A, &'a B));
|
||||||
//~^ ERROR: only one type parameter can be marked as `#[pointee]` when deriving SmartPointer traits
|
//~^ ERROR: only one type parameter can be marked as `#[pointee]` when deriving CoercePointee traits
|
||||||
|
|
||||||
#[derive(SmartPointer)]
|
#[derive(CoercePointee)]
|
||||||
//~^ ERROR: `SmartPointer` can only be derived on `struct`s with `#[repr(transparent)]`
|
//~^ ERROR: `CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]`
|
||||||
struct NotTransparent<'a, #[pointee] T: ?Sized> {
|
struct NotTransparent<'a, #[pointee] T: ?Sized> {
|
||||||
ptr: &'a T,
|
ptr: &'a T,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SmartPointer)]
|
#[derive(CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
struct NoMaybeSized<'a, #[pointee] T> {
|
struct NoMaybeSized<'a, #[pointee] T> {
|
||||||
//~^ ERROR: `derive(SmartPointer)` requires T to be marked `?Sized`
|
//~^ ERROR: `derive(CoercePointee)` requires T to be marked `?Sized`
|
||||||
ptr: &'a T,
|
ptr: &'a T,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SmartPointer)]
|
#[derive(CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
struct PointeeOnField<'a, #[pointee] T: ?Sized> {
|
struct PointeeOnField<'a, #[pointee] T: ?Sized> {
|
||||||
#[pointee]
|
#[pointee]
|
||||||
//~^ ERROR: the `#[pointee]` attribute may only be used on generic parameters
|
|
||||||
ptr: &'a T
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(SmartPointer)]
|
|
||||||
#[repr(transparent)]
|
|
||||||
struct PointeeInTypeConstBlock<'a, T: ?Sized = [u32; const { struct UhOh<#[pointee] T>(T); 10 }]> {
|
|
||||||
//~^ ERROR: the `#[pointee]` attribute may only be used on generic parameters
|
//~^ ERROR: the `#[pointee]` attribute may only be used on generic parameters
|
||||||
ptr: &'a T,
|
ptr: &'a T,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SmartPointer)]
|
#[derive(CoercePointee)]
|
||||||
|
#[repr(transparent)]
|
||||||
|
struct PointeeInTypeConstBlock<
|
||||||
|
'a,
|
||||||
|
T: ?Sized = [u32; const {
|
||||||
|
struct UhOh<#[pointee] T>(T);
|
||||||
|
//~^ ERROR: the `#[pointee]` attribute may only be used on generic parameters
|
||||||
|
10
|
||||||
|
}],
|
||||||
|
> {
|
||||||
|
ptr: &'a T,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
struct PointeeInConstConstBlock<
|
struct PointeeInConstConstBlock<
|
||||||
'a,
|
'a,
|
||||||
T: ?Sized,
|
T: ?Sized,
|
||||||
const V: u32 = { struct UhOh<#[pointee] T>(T); 10 }>
|
const V: u32 = {
|
||||||
//~^ ERROR: the `#[pointee]` attribute may only be used on generic parameters
|
struct UhOh<#[pointee] T>(T);
|
||||||
{
|
//~^ ERROR: the `#[pointee]` attribute may only be used on generic parameters
|
||||||
|
10
|
||||||
|
},
|
||||||
|
> {
|
||||||
ptr: &'a T,
|
ptr: &'a T,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SmartPointer)]
|
#[derive(CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
struct PointeeInAnotherTypeConstBlock<'a, #[pointee] T: ?Sized> {
|
struct PointeeInAnotherTypeConstBlock<'a, #[pointee] T: ?Sized> {
|
||||||
ptr: PointeeInConstConstBlock<'a, T, { struct UhOh<#[pointee] T>(T); 0 }>
|
ptr: PointeeInConstConstBlock<
|
||||||
//~^ ERROR: the `#[pointee]` attribute may only be used on generic parameters
|
'a,
|
||||||
|
T,
|
||||||
|
{
|
||||||
|
struct UhOh<#[pointee] T>(T);
|
||||||
|
//~^ ERROR: the `#[pointee]` attribute may only be used on generic parameters
|
||||||
|
0
|
||||||
|
},
|
||||||
|
>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// However, reordering attributes should work nevertheless.
|
// However, reordering attributes should work nevertheless.
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(SmartPointer)]
|
#[derive(CoercePointee)]
|
||||||
struct ThisIsAPossibleSmartPointer<'a, #[pointee] T: ?Sized> {
|
struct ThisIsAPossibleCoercePointee<'a, #[pointee] T: ?Sized> {
|
||||||
ptr: &'a T,
|
ptr: &'a T,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also, these paths to Sized should work
|
// Also, these paths to Sized should work
|
||||||
#[derive(SmartPointer)]
|
#[derive(CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
struct StdSized<'a, #[pointee] T: ?std::marker::Sized> {
|
struct StdSized<'a, #[pointee] T: ?std::marker::Sized> {
|
||||||
ptr: &'a T,
|
ptr: &'a T,
|
||||||
}
|
}
|
||||||
#[derive(SmartPointer)]
|
#[derive(CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
struct CoreSized<'a, #[pointee] T: ?core::marker::Sized> {
|
struct CoreSized<'a, #[pointee] T: ?core::marker::Sized> {
|
||||||
ptr: &'a T,
|
ptr: &'a T,
|
||||||
}
|
}
|
||||||
#[derive(SmartPointer)]
|
#[derive(CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
struct GlobalStdSized<'a, #[pointee] T: ?::std::marker::Sized> {
|
struct GlobalStdSized<'a, #[pointee] T: ?::std::marker::Sized> {
|
||||||
ptr: &'a T,
|
ptr: &'a T,
|
||||||
}
|
}
|
||||||
#[derive(SmartPointer)]
|
#[derive(CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
struct GlobalCoreSized<'a, #[pointee] T: ?::core::marker::Sized> {
|
struct GlobalCoreSized<'a, #[pointee] T: ?::core::marker::Sized> {
|
||||||
ptr: &'a T,
|
ptr: &'a T,
|
119
tests/ui/deriving/deriving-coerce-pointee-neg.stderr
Normal file
119
tests/ui/deriving/deriving-coerce-pointee-neg.stderr
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
error: `CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]`
|
||||||
|
--> $DIR/deriving-coerce-pointee-neg.rs:6:10
|
||||||
|
|
|
||||||
|
LL | #[derive(CoercePointee)]
|
||||||
|
| ^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this error originates in the derive macro `CoercePointee` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
error: `CoercePointee` can only be derived on `struct`s with at least one field
|
||||||
|
--> $DIR/deriving-coerce-pointee-neg.rs:12:10
|
||||||
|
|
|
||||||
|
LL | #[derive(CoercePointee)]
|
||||||
|
| ^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this error originates in the derive macro `CoercePointee` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
error: `CoercePointee` can only be derived on `struct`s with at least one field
|
||||||
|
--> $DIR/deriving-coerce-pointee-neg.rs:19:10
|
||||||
|
|
|
||||||
|
LL | #[derive(CoercePointee)]
|
||||||
|
| ^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this error originates in the derive macro `CoercePointee` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
error: `CoercePointee` can only be derived on `struct`s that are generic over at least one type
|
||||||
|
--> $DIR/deriving-coerce-pointee-neg.rs:26:10
|
||||||
|
|
|
||||||
|
LL | #[derive(CoercePointee)]
|
||||||
|
| ^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this error originates in the derive macro `CoercePointee` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
error: exactly one generic type parameter must be marked as #[pointee] to derive CoercePointee traits
|
||||||
|
--> $DIR/deriving-coerce-pointee-neg.rs:31:10
|
||||||
|
|
|
||||||
|
LL | #[derive(CoercePointee)]
|
||||||
|
| ^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this error originates in the derive macro `CoercePointee` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
error: only one type parameter can be marked as `#[pointee]` when deriving CoercePointee traits
|
||||||
|
--> $DIR/deriving-coerce-pointee-neg.rs:40:39
|
||||||
|
|
|
||||||
|
LL | struct TooManyPointees<'a, #[pointee] A: ?Sized, #[pointee] B: ?Sized>((&'a A, &'a B));
|
||||||
|
| ^ ^
|
||||||
|
|
||||||
|
error: `CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]`
|
||||||
|
--> $DIR/deriving-coerce-pointee-neg.rs:43:10
|
||||||
|
|
|
||||||
|
LL | #[derive(CoercePointee)]
|
||||||
|
| ^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this error originates in the derive macro `CoercePointee` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
error: `derive(CoercePointee)` requires T to be marked `?Sized`
|
||||||
|
--> $DIR/deriving-coerce-pointee-neg.rs:51:36
|
||||||
|
|
|
||||||
|
LL | struct NoMaybeSized<'a, #[pointee] T> {
|
||||||
|
| ^
|
||||||
|
|
||||||
|
error: the `#[pointee]` attribute may only be used on generic parameters
|
||||||
|
--> $DIR/deriving-coerce-pointee-neg.rs:59:5
|
||||||
|
|
|
||||||
|
LL | #[pointee]
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
||||||
|
error: the `#[pointee]` attribute may only be used on generic parameters
|
||||||
|
--> $DIR/deriving-coerce-pointee-neg.rs:69:33
|
||||||
|
|
|
||||||
|
LL | struct UhOh<#[pointee] T>(T);
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
||||||
|
error: the `#[pointee]` attribute may only be used on generic parameters
|
||||||
|
--> $DIR/deriving-coerce-pointee-neg.rs:83:21
|
||||||
|
|
|
||||||
|
LL | struct UhOh<#[pointee] T>(T);
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
||||||
|
error: the `#[pointee]` attribute may only be used on generic parameters
|
||||||
|
--> $DIR/deriving-coerce-pointee-neg.rs:98:25
|
||||||
|
|
|
||||||
|
LL | struct UhOh<#[pointee] T>(T);
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
||||||
|
error[E0392]: lifetime parameter `'a` is never used
|
||||||
|
--> $DIR/deriving-coerce-pointee-neg.rs:15:16
|
||||||
|
|
|
||||||
|
LL | struct NoField<'a, #[pointee] T: ?Sized> {}
|
||||||
|
| ^^ unused lifetime parameter
|
||||||
|
|
|
||||||
|
= help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`
|
||||||
|
|
||||||
|
error[E0392]: type parameter `T` is never used
|
||||||
|
--> $DIR/deriving-coerce-pointee-neg.rs:15:31
|
||||||
|
|
|
||||||
|
LL | struct NoField<'a, #[pointee] T: ?Sized> {}
|
||||||
|
| ^ unused type parameter
|
||||||
|
|
|
||||||
|
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
|
||||||
|
|
||||||
|
error[E0392]: lifetime parameter `'a` is never used
|
||||||
|
--> $DIR/deriving-coerce-pointee-neg.rs:22:20
|
||||||
|
|
|
||||||
|
LL | struct NoFieldUnit<'a, #[pointee] T: ?Sized>();
|
||||||
|
| ^^ unused lifetime parameter
|
||||||
|
|
|
||||||
|
= help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`
|
||||||
|
|
||||||
|
error[E0392]: type parameter `T` is never used
|
||||||
|
--> $DIR/deriving-coerce-pointee-neg.rs:22:35
|
||||||
|
|
|
||||||
|
LL | struct NoFieldUnit<'a, #[pointee] T: ?Sized>();
|
||||||
|
| ^ unused type parameter
|
||||||
|
|
|
||||||
|
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
|
||||||
|
|
||||||
|
error: aborting due to 16 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0392`.
|
@ -1,9 +1,9 @@
|
|||||||
//@ run-pass
|
//@ run-pass
|
||||||
#![feature(derive_smart_pointer, arbitrary_self_types)]
|
#![feature(derive_coerce_pointee, arbitrary_self_types)]
|
||||||
|
|
||||||
use std::marker::SmartPointer;
|
use std::marker::CoercePointee;
|
||||||
|
|
||||||
#[derive(SmartPointer)]
|
#[derive(CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
struct MyPointer<'a, #[pointee] T: ?Sized> {
|
struct MyPointer<'a, #[pointee] T: ?Sized> {
|
||||||
ptr: &'a T,
|
ptr: &'a T,
|
@ -1,119 +0,0 @@
|
|||||||
error: `SmartPointer` can only be derived on `struct`s with `#[repr(transparent)]`
|
|
||||||
--> $DIR/deriving-smart-pointer-neg.rs:6:10
|
|
||||||
|
|
|
||||||
LL | #[derive(SmartPointer)]
|
|
||||||
| ^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= note: this error originates in the derive macro `SmartPointer` (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
||||||
|
|
||||||
error: `SmartPointer` can only be derived on `struct`s with at least one field
|
|
||||||
--> $DIR/deriving-smart-pointer-neg.rs:12:10
|
|
||||||
|
|
|
||||||
LL | #[derive(SmartPointer)]
|
|
||||||
| ^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= note: this error originates in the derive macro `SmartPointer` (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
||||||
|
|
||||||
error: `SmartPointer` can only be derived on `struct`s with at least one field
|
|
||||||
--> $DIR/deriving-smart-pointer-neg.rs:19:10
|
|
||||||
|
|
|
||||||
LL | #[derive(SmartPointer)]
|
|
||||||
| ^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= note: this error originates in the derive macro `SmartPointer` (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
||||||
|
|
||||||
error: `SmartPointer` can only be derived on `struct`s that are generic over at least one type
|
|
||||||
--> $DIR/deriving-smart-pointer-neg.rs:26:10
|
|
||||||
|
|
|
||||||
LL | #[derive(SmartPointer)]
|
|
||||||
| ^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= note: this error originates in the derive macro `SmartPointer` (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
||||||
|
|
||||||
error: exactly one generic type parameter must be marked as #[pointee] to derive SmartPointer traits
|
|
||||||
--> $DIR/deriving-smart-pointer-neg.rs:31:10
|
|
||||||
|
|
|
||||||
LL | #[derive(SmartPointer)]
|
|
||||||
| ^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= note: this error originates in the derive macro `SmartPointer` (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
||||||
|
|
||||||
error: only one type parameter can be marked as `#[pointee]` when deriving SmartPointer traits
|
|
||||||
--> $DIR/deriving-smart-pointer-neg.rs:40:39
|
|
||||||
|
|
|
||||||
LL | struct TooManyPointees<'a, #[pointee] A: ?Sized, #[pointee] B: ?Sized>((&'a A, &'a B));
|
|
||||||
| ^ ^
|
|
||||||
|
|
||||||
error: `SmartPointer` can only be derived on `struct`s with `#[repr(transparent)]`
|
|
||||||
--> $DIR/deriving-smart-pointer-neg.rs:43:10
|
|
||||||
|
|
|
||||||
LL | #[derive(SmartPointer)]
|
|
||||||
| ^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= note: this error originates in the derive macro `SmartPointer` (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
||||||
|
|
||||||
error: `derive(SmartPointer)` requires T to be marked `?Sized`
|
|
||||||
--> $DIR/deriving-smart-pointer-neg.rs:51:36
|
|
||||||
|
|
|
||||||
LL | struct NoMaybeSized<'a, #[pointee] T> {
|
|
||||||
| ^
|
|
||||||
|
|
||||||
error: the `#[pointee]` attribute may only be used on generic parameters
|
|
||||||
--> $DIR/deriving-smart-pointer-neg.rs:59:5
|
|
||||||
|
|
|
||||||
LL | #[pointee]
|
|
||||||
| ^^^^^^^^^^
|
|
||||||
|
|
||||||
error: the `#[pointee]` attribute may only be used on generic parameters
|
|
||||||
--> $DIR/deriving-smart-pointer-neg.rs:66:74
|
|
||||||
|
|
|
||||||
LL | struct PointeeInTypeConstBlock<'a, T: ?Sized = [u32; const { struct UhOh<#[pointee] T>(T); 10 }]> {
|
|
||||||
| ^^^^^^^^^^
|
|
||||||
|
|
||||||
error: the `#[pointee]` attribute may only be used on generic parameters
|
|
||||||
--> $DIR/deriving-smart-pointer-neg.rs:76:34
|
|
||||||
|
|
|
||||||
LL | const V: u32 = { struct UhOh<#[pointee] T>(T); 10 }>
|
|
||||||
| ^^^^^^^^^^
|
|
||||||
|
|
||||||
error: the `#[pointee]` attribute may only be used on generic parameters
|
|
||||||
--> $DIR/deriving-smart-pointer-neg.rs:85:56
|
|
||||||
|
|
|
||||||
LL | ptr: PointeeInConstConstBlock<'a, T, { struct UhOh<#[pointee] T>(T); 0 }>
|
|
||||||
| ^^^^^^^^^^
|
|
||||||
|
|
||||||
error[E0392]: lifetime parameter `'a` is never used
|
|
||||||
--> $DIR/deriving-smart-pointer-neg.rs:15:16
|
|
||||||
|
|
|
||||||
LL | struct NoField<'a, #[pointee] T: ?Sized> {}
|
|
||||||
| ^^ unused lifetime parameter
|
|
||||||
|
|
|
||||||
= help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`
|
|
||||||
|
|
||||||
error[E0392]: type parameter `T` is never used
|
|
||||||
--> $DIR/deriving-smart-pointer-neg.rs:15:31
|
|
||||||
|
|
|
||||||
LL | struct NoField<'a, #[pointee] T: ?Sized> {}
|
|
||||||
| ^ unused type parameter
|
|
||||||
|
|
|
||||||
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
|
|
||||||
|
|
||||||
error[E0392]: lifetime parameter `'a` is never used
|
|
||||||
--> $DIR/deriving-smart-pointer-neg.rs:22:20
|
|
||||||
|
|
|
||||||
LL | struct NoFieldUnit<'a, #[pointee] T: ?Sized>();
|
|
||||||
| ^^ unused lifetime parameter
|
|
||||||
|
|
|
||||||
= help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`
|
|
||||||
|
|
||||||
error[E0392]: type parameter `T` is never used
|
|
||||||
--> $DIR/deriving-smart-pointer-neg.rs:22:35
|
|
||||||
|
|
|
||||||
LL | struct NoFieldUnit<'a, #[pointee] T: ?Sized>();
|
|
||||||
| ^ unused type parameter
|
|
||||||
|
|
|
||||||
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
|
|
||||||
|
|
||||||
error: aborting due to 16 previous errors
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0392`.
|
|
@ -1,5 +1,5 @@
|
|||||||
// This test certify that we can mix attribute macros from Rust and external proc-macros.
|
// This test certify that we can mix attribute macros from Rust and external proc-macros.
|
||||||
// For instance, `#[derive(Default)]` uses `#[default]` and `#[derive(SmartPointer)]` uses
|
// For instance, `#[derive(Default)]` uses `#[default]` and `#[derive(CoercePointee)]` uses
|
||||||
// `#[pointee]`.
|
// `#[pointee]`.
|
||||||
// The scoping rule should allow the use of the said two attributes when external proc-macros
|
// The scoping rule should allow the use of the said two attributes when external proc-macros
|
||||||
// are in scope.
|
// are in scope.
|
||||||
@ -8,7 +8,7 @@
|
|||||||
//@ aux-build: another-proc-macro.rs
|
//@ aux-build: another-proc-macro.rs
|
||||||
//@ compile-flags: -Zunpretty=expanded
|
//@ compile-flags: -Zunpretty=expanded
|
||||||
|
|
||||||
#![feature(derive_smart_pointer)]
|
#![feature(derive_coerce_pointee)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate another_proc_macro;
|
extern crate another_proc_macro;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#![feature(prelude_import)]
|
#![feature(prelude_import)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
// This test certify that we can mix attribute macros from Rust and external proc-macros.
|
// This test certify that we can mix attribute macros from Rust and external proc-macros.
|
||||||
// For instance, `#[derive(Default)]` uses `#[default]` and `#[derive(SmartPointer)]` uses
|
// For instance, `#[derive(Default)]` uses `#[default]` and `#[derive(CoercePointee)]` uses
|
||||||
// `#[pointee]`.
|
// `#[pointee]`.
|
||||||
// The scoping rule should allow the use of the said two attributes when external proc-macros
|
// The scoping rule should allow the use of the said two attributes when external proc-macros
|
||||||
// are in scope.
|
// are in scope.
|
||||||
@ -10,7 +10,7 @@
|
|||||||
//@ aux-build: another-proc-macro.rs
|
//@ aux-build: another-proc-macro.rs
|
||||||
//@ compile-flags: -Zunpretty=expanded
|
//@ compile-flags: -Zunpretty=expanded
|
||||||
|
|
||||||
#![feature(derive_smart_pointer)]
|
#![feature(derive_coerce_pointee)]
|
||||||
#[prelude_import]
|
#[prelude_import]
|
||||||
use ::std::prelude::rust_2015::*;
|
use ::std::prelude::rust_2015::*;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
use std::marker::CoercePointee; //~ ERROR use of unstable library feature 'derive_coerce_pointee'
|
||||||
|
|
||||||
|
#[derive(CoercePointee)] //~ ERROR use of unstable library feature 'derive_coerce_pointee'
|
||||||
|
#[repr(transparent)]
|
||||||
|
struct MyPointer<'a, #[pointee] T: ?Sized> {
|
||||||
|
ptr: &'a T,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
@ -0,0 +1,23 @@
|
|||||||
|
error[E0658]: use of unstable library feature 'derive_coerce_pointee'
|
||||||
|
--> $DIR/feature-gate-derive-coerce-pointee.rs:3:10
|
||||||
|
|
|
||||||
|
LL | #[derive(CoercePointee)]
|
||||||
|
| ^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #123430 <https://github.com/rust-lang/rust/issues/123430> for more information
|
||||||
|
= help: add `#![feature(derive_coerce_pointee)]` to the crate attributes to enable
|
||||||
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
|
error[E0658]: use of unstable library feature 'derive_coerce_pointee'
|
||||||
|
--> $DIR/feature-gate-derive-coerce-pointee.rs:1:5
|
||||||
|
|
|
||||||
|
LL | use std::marker::CoercePointee;
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #123430 <https://github.com/rust-lang/rust/issues/123430> for more information
|
||||||
|
= help: add `#![feature(derive_coerce_pointee)]` to the crate attributes to enable
|
||||||
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0658`.
|
@ -1,9 +0,0 @@
|
|||||||
use std::marker::SmartPointer; //~ ERROR use of unstable library feature 'derive_smart_pointer'
|
|
||||||
|
|
||||||
#[derive(SmartPointer)] //~ ERROR use of unstable library feature 'derive_smart_pointer'
|
|
||||||
#[repr(transparent)]
|
|
||||||
struct MyPointer<'a, #[pointee] T: ?Sized> {
|
|
||||||
ptr: &'a T,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
@ -1,23 +0,0 @@
|
|||||||
error[E0658]: use of unstable library feature 'derive_smart_pointer'
|
|
||||||
--> $DIR/feature-gate-derive-smart-pointer.rs:3:10
|
|
||||||
|
|
|
||||||
LL | #[derive(SmartPointer)]
|
|
||||||
| ^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= note: see issue #123430 <https://github.com/rust-lang/rust/issues/123430> for more information
|
|
||||||
= help: add `#![feature(derive_smart_pointer)]` to the crate attributes to enable
|
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
|
||||||
|
|
||||||
error[E0658]: use of unstable library feature 'derive_smart_pointer'
|
|
||||||
--> $DIR/feature-gate-derive-smart-pointer.rs:1:5
|
|
||||||
|
|
|
||||||
LL | use std::marker::SmartPointer;
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= note: see issue #123430 <https://github.com/rust-lang/rust/issues/123430> for more information
|
|
||||||
= help: add `#![feature(derive_smart_pointer)]` to the crate attributes to enable
|
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0658`.
|
|
Loading…
Reference in New Issue
Block a user