Remove {Method,Trait}Def::is_unsafe
.
They are always `false`.
This commit is contained in:
parent
d13fa0d21b
commit
1254fe974d
12 changed files with 2 additions and 37 deletions
|
@ -19,7 +19,6 @@ pub fn expand_deriving_copy(
|
||||||
path: path_std!(marker::Copy),
|
path: path_std!(marker::Copy),
|
||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
is_unsafe: false,
|
|
||||||
supports_unions: true,
|
supports_unions: true,
|
||||||
methods: Vec::new(),
|
methods: Vec::new(),
|
||||||
associated_types: Vec::new(),
|
associated_types: Vec::new(),
|
||||||
|
|
|
@ -81,7 +81,6 @@ pub fn expand_deriving_clone(
|
||||||
path: path_std!(clone::Clone),
|
path: path_std!(clone::Clone),
|
||||||
additional_bounds: bounds,
|
additional_bounds: bounds,
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
is_unsafe: false,
|
|
||||||
supports_unions: true,
|
supports_unions: true,
|
||||||
methods: vec![MethodDef {
|
methods: vec![MethodDef {
|
||||||
name: sym::clone,
|
name: sym::clone,
|
||||||
|
@ -90,7 +89,6 @@ pub fn expand_deriving_clone(
|
||||||
args: Vec::new(),
|
args: Vec::new(),
|
||||||
ret_ty: Self_,
|
ret_ty: Self_,
|
||||||
attributes: attrs,
|
attributes: attrs,
|
||||||
is_unsafe: false,
|
|
||||||
unify_fieldless_variants: false,
|
unify_fieldless_variants: false,
|
||||||
combine_substructure: substructure,
|
combine_substructure: substructure,
|
||||||
}],
|
}],
|
||||||
|
|
|
@ -27,7 +27,6 @@ pub fn expand_deriving_eq(
|
||||||
path: path_std!(cmp::Eq),
|
path: path_std!(cmp::Eq),
|
||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
is_unsafe: false,
|
|
||||||
supports_unions: true,
|
supports_unions: true,
|
||||||
methods: vec![MethodDef {
|
methods: vec![MethodDef {
|
||||||
name: sym::assert_receiver_is_total_eq,
|
name: sym::assert_receiver_is_total_eq,
|
||||||
|
@ -36,7 +35,6 @@ pub fn expand_deriving_eq(
|
||||||
args: vec![],
|
args: vec![],
|
||||||
ret_ty: nil_ty(),
|
ret_ty: nil_ty(),
|
||||||
attributes: attrs,
|
attributes: attrs,
|
||||||
is_unsafe: false,
|
|
||||||
unify_fieldless_variants: true,
|
unify_fieldless_variants: true,
|
||||||
combine_substructure: combine_substructure(Box::new(|a, b, c| {
|
combine_substructure: combine_substructure(Box::new(|a, b, c| {
|
||||||
cs_total_eq_assert(a, b, c)
|
cs_total_eq_assert(a, b, c)
|
||||||
|
|
|
@ -23,7 +23,6 @@ pub fn expand_deriving_ord(
|
||||||
path: path_std!(cmp::Ord),
|
path: path_std!(cmp::Ord),
|
||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
is_unsafe: false,
|
|
||||||
supports_unions: false,
|
supports_unions: false,
|
||||||
methods: vec![MethodDef {
|
methods: vec![MethodDef {
|
||||||
name: sym::cmp,
|
name: sym::cmp,
|
||||||
|
@ -32,7 +31,6 @@ pub fn expand_deriving_ord(
|
||||||
args: vec![(borrowed_self(), sym::other)],
|
args: vec![(borrowed_self(), sym::other)],
|
||||||
ret_ty: Literal(path_std!(cmp::Ordering)),
|
ret_ty: Literal(path_std!(cmp::Ordering)),
|
||||||
attributes: attrs,
|
attributes: attrs,
|
||||||
is_unsafe: false,
|
|
||||||
unify_fieldless_variants: true,
|
unify_fieldless_variants: true,
|
||||||
combine_substructure: combine_substructure(Box::new(|a, b, c| cs_cmp(a, b, c))),
|
combine_substructure: combine_substructure(Box::new(|a, b, c| cs_cmp(a, b, c))),
|
||||||
}],
|
}],
|
||||||
|
|
|
@ -73,7 +73,6 @@ pub fn expand_deriving_partial_eq(
|
||||||
args: vec![(borrowed_self(), sym::other)],
|
args: vec![(borrowed_self(), sym::other)],
|
||||||
ret_ty: Literal(path_local!(bool)),
|
ret_ty: Literal(path_local!(bool)),
|
||||||
attributes: attrs,
|
attributes: attrs,
|
||||||
is_unsafe: false,
|
|
||||||
unify_fieldless_variants: true,
|
unify_fieldless_variants: true,
|
||||||
combine_substructure: combine_substructure(Box::new(|a, b, c| $f(a, b, c))),
|
combine_substructure: combine_substructure(Box::new(|a, b, c| $f(a, b, c))),
|
||||||
}
|
}
|
||||||
|
@ -102,7 +101,6 @@ pub fn expand_deriving_partial_eq(
|
||||||
path: path_std!(cmp::PartialEq),
|
path: path_std!(cmp::PartialEq),
|
||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
is_unsafe: false,
|
|
||||||
supports_unions: false,
|
supports_unions: false,
|
||||||
methods,
|
methods,
|
||||||
associated_types: Vec::new(),
|
associated_types: Vec::new(),
|
||||||
|
|
|
@ -33,7 +33,6 @@ pub fn expand_deriving_partial_ord(
|
||||||
args: vec![(borrowed_self(), sym::other)],
|
args: vec![(borrowed_self(), sym::other)],
|
||||||
ret_ty,
|
ret_ty,
|
||||||
attributes: attrs,
|
attributes: attrs,
|
||||||
is_unsafe: false,
|
|
||||||
unify_fieldless_variants: true,
|
unify_fieldless_variants: true,
|
||||||
combine_substructure: combine_substructure(Box::new(|cx, span, substr| {
|
combine_substructure: combine_substructure(Box::new(|cx, span, substr| {
|
||||||
cs_partial_cmp(cx, span, substr)
|
cs_partial_cmp(cx, span, substr)
|
||||||
|
@ -46,7 +45,6 @@ pub fn expand_deriving_partial_ord(
|
||||||
path: path_std!(cmp::PartialOrd),
|
path: path_std!(cmp::PartialOrd),
|
||||||
additional_bounds: vec![],
|
additional_bounds: vec![],
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
is_unsafe: false,
|
|
||||||
supports_unions: false,
|
supports_unions: false,
|
||||||
methods: vec![partial_cmp_def],
|
methods: vec![partial_cmp_def],
|
||||||
associated_types: Vec::new(),
|
associated_types: Vec::new(),
|
||||||
|
|
|
@ -25,7 +25,6 @@ pub fn expand_deriving_debug(
|
||||||
path: path_std!(fmt::Debug),
|
path: path_std!(fmt::Debug),
|
||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
is_unsafe: false,
|
|
||||||
supports_unions: false,
|
supports_unions: false,
|
||||||
methods: vec![MethodDef {
|
methods: vec![MethodDef {
|
||||||
name: sym::fmt,
|
name: sym::fmt,
|
||||||
|
@ -34,7 +33,6 @@ pub fn expand_deriving_debug(
|
||||||
args: vec![(fmtr, sym::f)],
|
args: vec![(fmtr, sym::f)],
|
||||||
ret_ty: Literal(path_std!(fmt::Result)),
|
ret_ty: Literal(path_std!(fmt::Result)),
|
||||||
attributes: Vec::new(),
|
attributes: Vec::new(),
|
||||||
is_unsafe: false,
|
|
||||||
unify_fieldless_variants: false,
|
unify_fieldless_variants: false,
|
||||||
combine_substructure: combine_substructure(Box::new(|a, b, c| {
|
combine_substructure: combine_substructure(Box::new(|a, b, c| {
|
||||||
show_substructure(a, b, c)
|
show_substructure(a, b, c)
|
||||||
|
|
|
@ -26,7 +26,6 @@ pub fn expand_deriving_rustc_decodable(
|
||||||
path: Path::new_(vec![krate, sym::Decodable], None, vec![], PathKind::Global),
|
path: Path::new_(vec![krate, sym::Decodable], None, vec![], PathKind::Global),
|
||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
is_unsafe: false,
|
|
||||||
supports_unions: false,
|
supports_unions: false,
|
||||||
methods: vec![MethodDef {
|
methods: vec![MethodDef {
|
||||||
name: sym::decode,
|
name: sym::decode,
|
||||||
|
@ -56,7 +55,6 @@ pub fn expand_deriving_rustc_decodable(
|
||||||
PathKind::Std,
|
PathKind::Std,
|
||||||
)),
|
)),
|
||||||
attributes: Vec::new(),
|
attributes: Vec::new(),
|
||||||
is_unsafe: false,
|
|
||||||
unify_fieldless_variants: false,
|
unify_fieldless_variants: false,
|
||||||
combine_substructure: combine_substructure(Box::new(|a, b, c| {
|
combine_substructure: combine_substructure(Box::new(|a, b, c| {
|
||||||
decodable_substructure(a, b, c, krate)
|
decodable_substructure(a, b, c, krate)
|
||||||
|
|
|
@ -30,7 +30,6 @@ pub fn expand_deriving_default(
|
||||||
path: Path::new(vec![kw::Default, sym::Default]),
|
path: Path::new(vec![kw::Default, sym::Default]),
|
||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
is_unsafe: false,
|
|
||||||
supports_unions: false,
|
supports_unions: false,
|
||||||
methods: vec![MethodDef {
|
methods: vec![MethodDef {
|
||||||
name: kw::Default,
|
name: kw::Default,
|
||||||
|
@ -39,7 +38,6 @@ pub fn expand_deriving_default(
|
||||||
args: Vec::new(),
|
args: Vec::new(),
|
||||||
ret_ty: Self_,
|
ret_ty: Self_,
|
||||||
attributes: attrs,
|
attributes: attrs,
|
||||||
is_unsafe: false,
|
|
||||||
unify_fieldless_variants: false,
|
unify_fieldless_variants: false,
|
||||||
combine_substructure: combine_substructure(Box::new(|cx, trait_span, substr| {
|
combine_substructure: combine_substructure(Box::new(|cx, trait_span, substr| {
|
||||||
match substr.fields {
|
match substr.fields {
|
||||||
|
|
|
@ -111,7 +111,6 @@ pub fn expand_deriving_rustc_encodable(
|
||||||
path: Path::new_(vec![krate, sym::Encodable], None, vec![], PathKind::Global),
|
path: Path::new_(vec![krate, sym::Encodable], None, vec![], PathKind::Global),
|
||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
is_unsafe: false,
|
|
||||||
supports_unions: false,
|
supports_unions: false,
|
||||||
methods: vec![MethodDef {
|
methods: vec![MethodDef {
|
||||||
name: sym::encode,
|
name: sym::encode,
|
||||||
|
@ -141,7 +140,6 @@ pub fn expand_deriving_rustc_encodable(
|
||||||
PathKind::Std,
|
PathKind::Std,
|
||||||
)),
|
)),
|
||||||
attributes: Vec::new(),
|
attributes: Vec::new(),
|
||||||
is_unsafe: false,
|
|
||||||
unify_fieldless_variants: false,
|
unify_fieldless_variants: false,
|
||||||
combine_substructure: combine_substructure(Box::new(|a, b, c| {
|
combine_substructure: combine_substructure(Box::new(|a, b, c| {
|
||||||
encodable_substructure(a, b, c, krate)
|
encodable_substructure(a, b, c, krate)
|
||||||
|
|
|
@ -210,9 +210,6 @@ pub struct TraitDef<'a> {
|
||||||
/// Any extra lifetimes and/or bounds, e.g., `D: serialize::Decoder`
|
/// Any extra lifetimes and/or bounds, e.g., `D: serialize::Decoder`
|
||||||
pub generics: Bounds,
|
pub generics: Bounds,
|
||||||
|
|
||||||
/// Is it an `unsafe` trait?
|
|
||||||
pub is_unsafe: bool,
|
|
||||||
|
|
||||||
/// Can this trait be derived for unions?
|
/// Can this trait be derived for unions?
|
||||||
pub supports_unions: bool,
|
pub supports_unions: bool,
|
||||||
|
|
||||||
|
@ -240,9 +237,6 @@ pub struct MethodDef<'a> {
|
||||||
|
|
||||||
pub attributes: Vec<ast::Attribute>,
|
pub attributes: Vec<ast::Attribute>,
|
||||||
|
|
||||||
// Is it an `unsafe fn`?
|
|
||||||
pub is_unsafe: bool,
|
|
||||||
|
|
||||||
/// Can we combine fieldless variants for enums into a single match arm?
|
/// Can we combine fieldless variants for enums into a single match arm?
|
||||||
pub unify_fieldless_variants: bool,
|
pub unify_fieldless_variants: bool,
|
||||||
|
|
||||||
|
@ -717,14 +711,12 @@ impl<'a> TraitDef<'a> {
|
||||||
let mut a = vec![attr, unused_qual];
|
let mut a = vec![attr, unused_qual];
|
||||||
a.extend(self.attributes.iter().cloned());
|
a.extend(self.attributes.iter().cloned());
|
||||||
|
|
||||||
let unsafety = if self.is_unsafe { ast::Unsafe::Yes(self.span) } else { ast::Unsafe::No };
|
|
||||||
|
|
||||||
cx.item(
|
cx.item(
|
||||||
self.span,
|
self.span,
|
||||||
Ident::empty(),
|
Ident::empty(),
|
||||||
a,
|
a,
|
||||||
ast::ItemKind::Impl(Box::new(ast::Impl {
|
ast::ItemKind::Impl(Box::new(ast::Impl {
|
||||||
unsafety,
|
unsafety: ast::Unsafe::No,
|
||||||
polarity: ast::ImplPolarity::Positive,
|
polarity: ast::ImplPolarity::Positive,
|
||||||
defaultness: ast::Defaultness::Final,
|
defaultness: ast::Defaultness::Final,
|
||||||
constness: ast::Const::No,
|
constness: ast::Const::No,
|
||||||
|
@ -939,15 +931,9 @@ impl<'a> MethodDef<'a> {
|
||||||
let fn_decl = cx.fn_decl(args, ast::FnRetTy::Ty(ret_type));
|
let fn_decl = cx.fn_decl(args, ast::FnRetTy::Ty(ret_type));
|
||||||
let body_block = cx.block_expr(body);
|
let body_block = cx.block_expr(body);
|
||||||
|
|
||||||
let unsafety = if self.is_unsafe { ast::Unsafe::Yes(span) } else { ast::Unsafe::No };
|
|
||||||
|
|
||||||
let trait_lo_sp = span.shrink_to_lo();
|
let trait_lo_sp = span.shrink_to_lo();
|
||||||
|
|
||||||
let sig = ast::FnSig {
|
let sig = ast::FnSig { header: ast::FnHeader::default(), decl: fn_decl, span };
|
||||||
header: ast::FnHeader { unsafety, ext: ast::Extern::None, ..ast::FnHeader::default() },
|
|
||||||
decl: fn_decl,
|
|
||||||
span,
|
|
||||||
};
|
|
||||||
let defaultness = ast::Defaultness::Final;
|
let defaultness = ast::Defaultness::Final;
|
||||||
|
|
||||||
// Create the method.
|
// Create the method.
|
||||||
|
|
|
@ -26,7 +26,6 @@ pub fn expand_deriving_hash(
|
||||||
path,
|
path,
|
||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
is_unsafe: false,
|
|
||||||
supports_unions: false,
|
supports_unions: false,
|
||||||
methods: vec![MethodDef {
|
methods: vec![MethodDef {
|
||||||
name: sym::hash,
|
name: sym::hash,
|
||||||
|
@ -35,7 +34,6 @@ pub fn expand_deriving_hash(
|
||||||
args: vec![(Ptr(Box::new(Literal(arg)), Borrowed(None, Mutability::Mut)), sym::state)],
|
args: vec![(Ptr(Box::new(Literal(arg)), Borrowed(None, Mutability::Mut)), sym::state)],
|
||||||
ret_ty: nil_ty(),
|
ret_ty: nil_ty(),
|
||||||
attributes: vec![],
|
attributes: vec![],
|
||||||
is_unsafe: false,
|
|
||||||
unify_fieldless_variants: true,
|
unify_fieldless_variants: true,
|
||||||
combine_substructure: combine_substructure(Box::new(|a, b, c| {
|
combine_substructure: combine_substructure(Box::new(|a, b, c| {
|
||||||
hash_substructure(a, b, c)
|
hash_substructure(a, b, c)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue