about summary refs log tree commit diff
path: root/src/libsyntax/util
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-06-18 20:12:09 -0700
committerGitHub <noreply@github.com>2016-06-18 20:12:09 -0700
commitb1ae194fa665265cbabdfdd1d1d43fc8bb47362a (patch)
tree13530fe031f9aa00ac4a02ab4f4353b8205b73ff /src/libsyntax/util
parent9a681247379190896b9f56a3fb11c94ee4b83dce (diff)
parentc41cf30e9d0a5ae47e944fd8ee27eda9ce815ee1 (diff)
downloadrust-b1ae194fa665265cbabdfdd1d1d43fc8bb47362a.tar.gz
rust-b1ae194fa665265cbabdfdd1d1d43fc8bb47362a.zip
Auto merge of #34295 - jseyfried:cfg_decoration, r=eddyb
Perform `cfg` attribute processing on decorator-generated items

Fixes https://users.rust-lang.org/t/unused-attribute-warning-for-custom-derive-attribute/6180.
r? @nrc
Diffstat (limited to 'src/libsyntax/util')
-rw-r--r--src/libsyntax/util/small_vector.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libsyntax/util/small_vector.rs b/src/libsyntax/util/small_vector.rs
index 9548805c1f8..893646f121f 100644
--- a/src/libsyntax/util/small_vector.rs
+++ b/src/libsyntax/util/small_vector.rs
@@ -146,6 +146,15 @@ impl<T> SmallVector<T> {
     }
 
     pub fn is_empty(&self) -> bool { self.len() == 0 }
+
+    pub fn map<U, F: FnMut(T) -> U>(self, mut f: F) -> SmallVector<U> {
+        let repr = match self.repr {
+            Zero => Zero,
+            One(t) => One(f(t)),
+            Many(vec) => Many(vec.into_iter().map(f).collect()),
+        };
+        SmallVector { repr: repr }
+    }
 }
 
 impl<T> IntoIterator for SmallVector<T> {