diff options
| author | Michael Layzell <michael@thelayzells.com> | 2015-08-29 14:50:05 -0400 |
|---|---|---|
| committer | Michael Layzell <michael@thelayzells.com> | 2015-08-29 14:50:05 -0400 |
| commit | 38d450fad2d8f60041fe72462015fc5b09acccae (patch) | |
| tree | ce4c83c8237dc93ec4d8ab94e15ce544d3042c3e /src/libsyntax/ext/deriving/generic | |
| parent | 3f002a4c6ed2bb694407842b5447dba34799b931 (diff) | |
| download | rust-38d450fad2d8f60041fe72462015fc5b09acccae.tar.gz rust-38d450fad2d8f60041fe72462015fc5b09acccae.zip | |
Allow #[derive()] to generate unsafe trait impls
Diffstat (limited to 'src/libsyntax/ext/deriving/generic')
| -rw-r--r-- | src/libsyntax/ext/deriving/generic/mod.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index 3196380ec6c..9fc2745cf92 100644 --- a/src/libsyntax/ext/deriving/generic/mod.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs @@ -229,6 +229,9 @@ pub struct TraitDef<'a> { /// Any extra lifetimes and/or bounds, e.g. `D: serialize::Decoder` pub generics: LifetimeBounds<'a>, + /// Is it an `unsafe` trait? + pub is_unsafe: bool, + pub methods: Vec<MethodDef<'a>>, pub associated_types: Vec<(ast::Ident, Ty<'a>)>, @@ -625,11 +628,18 @@ impl<'a> TraitDef<'a> { InternedString::new("unused_qualifications"))])); let mut a = vec![attr, unused_qual]; a.extend(self.attributes.iter().cloned()); + + let unsafety = if self.is_unsafe { + ast::Unsafety::Unsafe + } else { + ast::Unsafety::Normal + }; + cx.item( self.span, ident, a, - ast::ItemImpl(ast::Unsafety::Normal, + ast::ItemImpl(unsafety, ast::ImplPolarity::Positive, trait_generics, opt_trait_ref, |
