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),
|
||||
additional_bounds: Vec::new(),
|
||||
generics: Bounds::empty(),
|
||||
is_unsafe: false,
|
||||
supports_unions: true,
|
||||
methods: Vec::new(),
|
||||
associated_types: Vec::new(),
|
||||
|
|
|
@ -81,7 +81,6 @@ pub fn expand_deriving_clone(
|
|||
path: path_std!(clone::Clone),
|
||||
additional_bounds: bounds,
|
||||
generics: Bounds::empty(),
|
||||
is_unsafe: false,
|
||||
supports_unions: true,
|
||||
methods: vec![MethodDef {
|
||||
name: sym::clone,
|
||||
|
@ -90,7 +89,6 @@ pub fn expand_deriving_clone(
|
|||
args: Vec::new(),
|
||||
ret_ty: Self_,
|
||||
attributes: attrs,
|
||||
is_unsafe: false,
|
||||
unify_fieldless_variants: false,
|
||||
combine_substructure: substructure,
|
||||
}],
|
||||
|
|
|
@ -27,7 +27,6 @@ pub fn expand_deriving_eq(
|
|||
path: path_std!(cmp::Eq),
|
||||
additional_bounds: Vec::new(),
|
||||
generics: Bounds::empty(),
|
||||
is_unsafe: false,
|
||||
supports_unions: true,
|
||||
methods: vec![MethodDef {
|
||||
name: sym::assert_receiver_is_total_eq,
|
||||
|
@ -36,7 +35,6 @@ pub fn expand_deriving_eq(
|
|||
args: vec![],
|
||||
ret_ty: nil_ty(),
|
||||
attributes: attrs,
|
||||
is_unsafe: false,
|
||||
unify_fieldless_variants: true,
|
||||
combine_substructure: combine_substructure(Box::new(|a, b, c| {
|
||||
cs_total_eq_assert(a, b, c)
|
||||
|
|
|
@ -23,7 +23,6 @@ pub fn expand_deriving_ord(
|
|||
path: path_std!(cmp::Ord),
|
||||
additional_bounds: Vec::new(),
|
||||
generics: Bounds::empty(),
|
||||
is_unsafe: false,
|
||||
supports_unions: false,
|
||||
methods: vec![MethodDef {
|
||||
name: sym::cmp,
|
||||
|
@ -32,7 +31,6 @@ pub fn expand_deriving_ord(
|
|||
args: vec![(borrowed_self(), sym::other)],
|
||||
ret_ty: Literal(path_std!(cmp::Ordering)),
|
||||
attributes: attrs,
|
||||
is_unsafe: false,
|
||||
unify_fieldless_variants: true,
|
||||
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)],
|
||||
ret_ty: Literal(path_local!(bool)),
|
||||
attributes: attrs,
|
||||
is_unsafe: false,
|
||||
unify_fieldless_variants: true,
|
||||
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),
|
||||
additional_bounds: Vec::new(),
|
||||
generics: Bounds::empty(),
|
||||
is_unsafe: false,
|
||||
supports_unions: false,
|
||||
methods,
|
||||
associated_types: Vec::new(),
|
||||
|
|
|
@ -33,7 +33,6 @@ pub fn expand_deriving_partial_ord(
|
|||
args: vec![(borrowed_self(), sym::other)],
|
||||
ret_ty,
|
||||
attributes: attrs,
|
||||
is_unsafe: false,
|
||||
unify_fieldless_variants: true,
|
||||
combine_substructure: combine_substructure(Box::new(|cx, span, substr| {
|
||||
cs_partial_cmp(cx, span, substr)
|
||||
|
@ -46,7 +45,6 @@ pub fn expand_deriving_partial_ord(
|
|||
path: path_std!(cmp::PartialOrd),
|
||||
additional_bounds: vec![],
|
||||
generics: Bounds::empty(),
|
||||
is_unsafe: false,
|
||||
supports_unions: false,
|
||||
methods: vec![partial_cmp_def],
|
||||
associated_types: Vec::new(),
|
||||
|
|
|
@ -25,7 +25,6 @@ pub fn expand_deriving_debug(
|
|||
path: path_std!(fmt::Debug),
|
||||
additional_bounds: Vec::new(),
|
||||
generics: Bounds::empty(),
|
||||
is_unsafe: false,
|
||||
supports_unions: false,
|
||||
methods: vec![MethodDef {
|
||||
name: sym::fmt,
|
||||
|
@ -34,7 +33,6 @@ pub fn expand_deriving_debug(
|
|||
args: vec![(fmtr, sym::f)],
|
||||
ret_ty: Literal(path_std!(fmt::Result)),
|
||||
attributes: Vec::new(),
|
||||
is_unsafe: false,
|
||||
unify_fieldless_variants: false,
|
||||
combine_substructure: combine_substructure(Box::new(|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),
|
||||
additional_bounds: Vec::new(),
|
||||
generics: Bounds::empty(),
|
||||
is_unsafe: false,
|
||||
supports_unions: false,
|
||||
methods: vec![MethodDef {
|
||||
name: sym::decode,
|
||||
|
@ -56,7 +55,6 @@ pub fn expand_deriving_rustc_decodable(
|
|||
PathKind::Std,
|
||||
)),
|
||||
attributes: Vec::new(),
|
||||
is_unsafe: false,
|
||||
unify_fieldless_variants: false,
|
||||
combine_substructure: combine_substructure(Box::new(|a, b, c| {
|
||||
decodable_substructure(a, b, c, krate)
|
||||
|
|
|
@ -30,7 +30,6 @@ pub fn expand_deriving_default(
|
|||
path: Path::new(vec![kw::Default, sym::Default]),
|
||||
additional_bounds: Vec::new(),
|
||||
generics: Bounds::empty(),
|
||||
is_unsafe: false,
|
||||
supports_unions: false,
|
||||
methods: vec![MethodDef {
|
||||
name: kw::Default,
|
||||
|
@ -39,7 +38,6 @@ pub fn expand_deriving_default(
|
|||
args: Vec::new(),
|
||||
ret_ty: Self_,
|
||||
attributes: attrs,
|
||||
is_unsafe: false,
|
||||
unify_fieldless_variants: false,
|
||||
combine_substructure: combine_substructure(Box::new(|cx, trait_span, substr| {
|
||||
match substr.fields {
|
||||
|
|
|
@ -111,7 +111,6 @@ pub fn expand_deriving_rustc_encodable(
|
|||
path: Path::new_(vec![krate, sym::Encodable], None, vec![], PathKind::Global),
|
||||
additional_bounds: Vec::new(),
|
||||
generics: Bounds::empty(),
|
||||
is_unsafe: false,
|
||||
supports_unions: false,
|
||||
methods: vec![MethodDef {
|
||||
name: sym::encode,
|
||||
|
@ -141,7 +140,6 @@ pub fn expand_deriving_rustc_encodable(
|
|||
PathKind::Std,
|
||||
)),
|
||||
attributes: Vec::new(),
|
||||
is_unsafe: false,
|
||||
unify_fieldless_variants: false,
|
||||
combine_substructure: combine_substructure(Box::new(|a, b, c| {
|
||||
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`
|
||||
pub generics: Bounds,
|
||||
|
||||
/// Is it an `unsafe` trait?
|
||||
pub is_unsafe: bool,
|
||||
|
||||
/// Can this trait be derived for unions?
|
||||
pub supports_unions: bool,
|
||||
|
||||
|
@ -240,9 +237,6 @@ pub struct MethodDef<'a> {
|
|||
|
||||
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?
|
||||
pub unify_fieldless_variants: bool,
|
||||
|
||||
|
@ -717,14 +711,12 @@ impl<'a> TraitDef<'a> {
|
|||
let mut a = vec![attr, unused_qual];
|
||||
a.extend(self.attributes.iter().cloned());
|
||||
|
||||
let unsafety = if self.is_unsafe { ast::Unsafe::Yes(self.span) } else { ast::Unsafe::No };
|
||||
|
||||
cx.item(
|
||||
self.span,
|
||||
Ident::empty(),
|
||||
a,
|
||||
ast::ItemKind::Impl(Box::new(ast::Impl {
|
||||
unsafety,
|
||||
unsafety: ast::Unsafe::No,
|
||||
polarity: ast::ImplPolarity::Positive,
|
||||
defaultness: ast::Defaultness::Final,
|
||||
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 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 sig = ast::FnSig {
|
||||
header: ast::FnHeader { unsafety, ext: ast::Extern::None, ..ast::FnHeader::default() },
|
||||
decl: fn_decl,
|
||||
span,
|
||||
};
|
||||
let sig = ast::FnSig { header: ast::FnHeader::default(), decl: fn_decl, span };
|
||||
let defaultness = ast::Defaultness::Final;
|
||||
|
||||
// Create the method.
|
||||
|
|
|
@ -26,7 +26,6 @@ pub fn expand_deriving_hash(
|
|||
path,
|
||||
additional_bounds: Vec::new(),
|
||||
generics: Bounds::empty(),
|
||||
is_unsafe: false,
|
||||
supports_unions: false,
|
||||
methods: vec![MethodDef {
|
||||
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)],
|
||||
ret_ty: nil_ty(),
|
||||
attributes: vec![],
|
||||
is_unsafe: false,
|
||||
unify_fieldless_variants: true,
|
||||
combine_substructure: combine_substructure(Box::new(|a, b, c| {
|
||||
hash_substructure(a, b, c)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue