about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/librustc_attr/builtin.rs20
-rw-r--r--src/librustc_mir/transform/qualify_min_const_fn.rs3
-rw-r--r--src/libsyntax/Cargo.toml1
-rw-r--r--src/libsyntax/attr/mod.rs24
4 files changed, 21 insertions, 27 deletions
diff --git a/src/librustc_attr/builtin.rs b/src/librustc_attr/builtin.rs
index f13f19073ea..c944537048f 100644
--- a/src/librustc_attr/builtin.rs
+++ b/src/librustc_attr/builtin.rs
@@ -1,6 +1,6 @@
 //! Parsing and validation of builtin attributes
 
-use super::mark_used;
+use super::{find_by_name, mark_used};
 
 use rustc_errors::{struct_span_err, Applicability, Handler};
 use rustc_feature::{find_gated_cfg, is_builtin_attr_name, Features, GatedCfg};
@@ -1043,3 +1043,21 @@ pub fn find_transparency(
     let fallback = if is_legacy { Transparency::SemiTransparent } else { Transparency::Opaque };
     (transparency.map_or(fallback, |t| t.0), error)
 }
+
+pub fn allow_internal_unstable<'a>(
+    attrs: &[Attribute],
+    diag: &'a rustc_errors::Handler,
+) -> Option<impl Iterator<Item = Symbol> + 'a> {
+    let attr = find_by_name(attrs, sym::allow_internal_unstable)?;
+    let list = attr.meta_item_list().or_else(|| {
+        diag.span_err(attr.span, "allow_internal_unstable expects list of feature names");
+        None
+    })?;
+    Some(list.into_iter().filter_map(move |it| {
+        let name = it.ident().map(|ident| ident.name);
+        if name.is_none() {
+            diag.span_err(it.span(), "`allow_internal_unstable` expects feature names");
+        }
+        name
+    }))
+}
diff --git a/src/librustc_mir/transform/qualify_min_const_fn.rs b/src/librustc_mir/transform/qualify_min_const_fn.rs
index 49921badf33..6a68ccdddff 100644
--- a/src/librustc_mir/transform/qualify_min_const_fn.rs
+++ b/src/librustc_mir/transform/qualify_min_const_fn.rs
@@ -1,11 +1,12 @@
 use rustc::mir::*;
 use rustc::ty::{self, adjustment::PointerCast, Predicate, Ty, TyCtxt};
+use rustc_attr as attr;
 use rustc_hir as hir;
 use rustc_hir::def_id::DefId;
 use rustc_span::symbol::{sym, Symbol};
 use rustc_span::Span;
 use std::borrow::Cow;
-use syntax::{ast, attr};
+use syntax::ast;
 
 type McfResult = Result<(), (Span, Cow<'static, str>)>;
 
diff --git a/src/libsyntax/Cargo.toml b/src/libsyntax/Cargo.toml
index b3e16f740fd..ff03ae3f425 100644
--- a/src/libsyntax/Cargo.toml
+++ b/src/libsyntax/Cargo.toml
@@ -13,7 +13,6 @@ doctest = false
 rustc_serialize = { path = "../libserialize", package = "serialize" }
 log = "0.4"
 scoped-tls = "1.0"
-rustc_errors = { path = "../librustc_errors" }
 rustc_span = { path = "../librustc_span" }
 rustc_data_structures = { path = "../librustc_data_structures" }
 rustc_index = { path = "../librustc_index" }
diff --git a/src/libsyntax/attr/mod.rs b/src/libsyntax/attr/mod.rs
index e4d4017a345..313f5269235 100644
--- a/src/libsyntax/attr/mod.rs
+++ b/src/libsyntax/attr/mod.rs
@@ -406,30 +406,6 @@ pub fn find_by_name(attrs: &[Attribute], name: Symbol) -> Option<&Attribute> {
     attrs.iter().find(|attr| attr.check_name(name))
 }
 
-pub fn allow_internal_unstable<'a>(
-    attrs: &[Attribute],
-    span_diagnostic: &'a rustc_errors::Handler,
-) -> Option<impl Iterator<Item = Symbol> + 'a> {
-    find_by_name(attrs, sym::allow_internal_unstable).and_then(|attr| {
-        attr.meta_item_list()
-            .or_else(|| {
-                span_diagnostic
-                    .span_err(attr.span, "allow_internal_unstable expects list of feature names");
-                None
-            })
-            .map(|features| {
-                features.into_iter().filter_map(move |it| {
-                    let name = it.ident().map(|ident| ident.name);
-                    if name.is_none() {
-                        span_diagnostic
-                            .span_err(it.span(), "`allow_internal_unstable` expects feature names")
-                    }
-                    name
-                })
-            })
-    })
-}
-
 pub fn filter_by_name(attrs: &[Attribute], name: Symbol) -> impl Iterator<Item = &Attribute> {
     attrs.iter().filter(move |attr| attr.check_name(name))
 }