Skip to content

Commit 98fd6a5

Browse files
committed
1. move allow_internal_unstable to rustc_attr
2. as a result, drop rustc_errors dep from syntax
1 parent 097d5e1 commit 98fd6a5

File tree

5 files changed

+21
-28
lines changed

5 files changed

+21
-28
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4512,7 +4512,6 @@ version = "0.0.0"
45124512
dependencies = [
45134513
"log",
45144514
"rustc_data_structures",
4515-
"rustc_errors",
45164515
"rustc_index",
45174516
"rustc_lexer",
45184517
"rustc_macros",

src/librustc_attr/builtin.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Parsing and validation of builtin attributes
22
3-
use super::mark_used;
3+
use super::{find_by_name, mark_used};
44

55
use rustc_errors::{struct_span_err, Applicability, Handler};
66
use rustc_feature::{find_gated_cfg, is_builtin_attr_name, Features, GatedCfg};
@@ -1043,3 +1043,21 @@ pub fn find_transparency(
10431043
let fallback = if is_legacy { Transparency::SemiTransparent } else { Transparency::Opaque };
10441044
(transparency.map_or(fallback, |t| t.0), error)
10451045
}
1046+
1047+
pub fn allow_internal_unstable<'a>(
1048+
attrs: &[Attribute],
1049+
diag: &'a rustc_errors::Handler,
1050+
) -> Option<impl Iterator<Item = Symbol> + 'a> {
1051+
let attr = find_by_name(attrs, sym::allow_internal_unstable)?;
1052+
let list = attr.meta_item_list().or_else(|| {
1053+
diag.span_err(attr.span, "allow_internal_unstable expects list of feature names");
1054+
None
1055+
})?;
1056+
Some(list.into_iter().filter_map(move |it| {
1057+
let name = it.ident().map(|ident| ident.name);
1058+
if name.is_none() {
1059+
diag.span_err(it.span(), "`allow_internal_unstable` expects feature names");
1060+
}
1061+
name
1062+
}))
1063+
}

src/librustc_mir/transform/qualify_min_const_fn.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
use rustc::mir::*;
22
use rustc::ty::{self, adjustment::PointerCast, Predicate, Ty, TyCtxt};
3+
use rustc_attr as attr;
34
use rustc_hir as hir;
45
use rustc_hir::def_id::DefId;
56
use rustc_span::symbol::{sym, Symbol};
67
use rustc_span::Span;
78
use std::borrow::Cow;
8-
use syntax::{ast, attr};
9+
use syntax::ast;
910

1011
type McfResult = Result<(), (Span, Cow<'static, str>)>;
1112

src/libsyntax/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ doctest = false
1313
rustc_serialize = { path = "../libserialize", package = "serialize" }
1414
log = "0.4"
1515
scoped-tls = "1.0"
16-
rustc_errors = { path = "../librustc_errors" }
1716
rustc_span = { path = "../librustc_span" }
1817
rustc_data_structures = { path = "../librustc_data_structures" }
1918
rustc_index = { path = "../librustc_index" }

src/libsyntax/attr/mod.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -406,30 +406,6 @@ pub fn find_by_name(attrs: &[Attribute], name: Symbol) -> Option<&Attribute> {
406406
attrs.iter().find(|attr| attr.check_name(name))
407407
}
408408

409-
pub fn allow_internal_unstable<'a>(
410-
attrs: &[Attribute],
411-
span_diagnostic: &'a rustc_errors::Handler,
412-
) -> Option<impl Iterator<Item = Symbol> + 'a> {
413-
find_by_name(attrs, sym::allow_internal_unstable).and_then(|attr| {
414-
attr.meta_item_list()
415-
.or_else(|| {
416-
span_diagnostic
417-
.span_err(attr.span, "allow_internal_unstable expects list of feature names");
418-
None
419-
})
420-
.map(|features| {
421-
features.into_iter().filter_map(move |it| {
422-
let name = it.ident().map(|ident| ident.name);
423-
if name.is_none() {
424-
span_diagnostic
425-
.span_err(it.span(), "`allow_internal_unstable` expects feature names")
426-
}
427-
name
428-
})
429-
})
430-
})
431-
}
432-
433409
pub fn filter_by_name(attrs: &[Attribute], name: Symbol) -> impl Iterator<Item = &Attribute> {
434410
attrs.iter().filter(move |attr| attr.check_name(name))
435411
}

0 commit comments

Comments
 (0)