Skip to content

Commit 6a6f419

Browse files
committed
1. move allow_internal_unstable to rustc_attr
2. as a result, drop rustc_errors dep from syntax
1 parent 6164f5c commit 6a6f419

File tree

5 files changed

+20
-28
lines changed

5 files changed

+20
-28
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4525,7 +4525,6 @@ version = "0.0.0"
45254525
dependencies = [
45264526
"log",
45274527
"rustc_data_structures",
4528-
"rustc_errors",
45294528
"rustc_index",
45304529
"rustc_lexer",
45314530
"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_error_codes::*;
66
use rustc_errors::{struct_span_err, Applicability, Handler};
@@ -1031,3 +1031,21 @@ pub fn find_transparency(
10311031
let fallback = if is_legacy { Transparency::SemiTransparent } else { Transparency::Opaque };
10321032
(transparency.map_or(fallback, |t| t.0), error)
10331033
}
1034+
1035+
pub fn allow_internal_unstable<'a>(
1036+
attrs: &[Attribute],
1037+
diag: &'a rustc_errors::Handler,
1038+
) -> Option<impl Iterator<Item = Symbol> + 'a> {
1039+
let attr = find_by_name(attrs, sym::allow_internal_unstable)?;
1040+
let list = attr.meta_item_list().or_else(|| {
1041+
diag.span_err(attr.span, "allow_internal_unstable expects list of feature names");
1042+
None
1043+
})?;
1044+
Some(list.into_iter().filter_map(move |it| {
1045+
let name = it.ident().map(|ident| ident.name);
1046+
if name.is_none() {
1047+
diag.span_err(it.span(), "`allow_internal_unstable` expects feature names");
1048+
}
1049+
name
1050+
}))
1051+
}

src/librustc_mir/transform/qualify_min_const_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
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::attr;
99

1010
type McfResult = Result<(), (Span, Cow<'static, str>)>;
1111

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)