Skip to content

Commit 66e1719

Browse files
committed
Ease the transition to requiring features by just warning if there's no feature list
while we could make this change (it's all unstable after all), there are crates.io crates that use the feature and that the compiler depends upon. We can instead roll out this feature while still supporting the old way.
1 parent a34eb30 commit 66e1719

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

src/libsyntax/ext/tt/macro_rules.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,20 @@ pub fn compile(sess: &ParseSess, features: &Features, def: &ast::Item, edition:
367367
let allow_internal_unstable = attr::find_by_name(&def.attrs, "allow_internal_unstable")
368368
.map_or(Vec::new(), |attr| attr
369369
.meta_item_list()
370-
.unwrap_or_else(|| sess.span_diagnostic.span_bug(
371-
attr.span, "allow_internal_unstable expects list of feature names",
372-
))
373-
.iter()
374-
.map(|it| it.name().unwrap_or_else(|| sess.span_diagnostic.span_bug(
375-
it.span, "allow internal unstable expects feature names",
376-
)))
377-
.collect()
370+
.map(|list| list.iter()
371+
.map(|it| it.name().unwrap_or_else(|| sess.span_diagnostic.span_bug(
372+
it.span, "allow internal unstable expects feature names",
373+
)))
374+
.collect()
375+
)
376+
.unwrap_or_else(|| {
377+
sess.span_diagnostic.span_warn(
378+
attr.span, "allow_internal_unstable expects list of feature names. In the \
379+
future this will become a hard error. Please use `allow_internal_unstable(\
380+
foo, bar)` to only allow the `foo` and `bar` features",
381+
);
382+
vec![Symbol::intern("allow_internal_unstable_backcompat_hack")]
383+
})
378384
);
379385
let allow_internal_unsafe = attr::contains_name(&def.attrs, "allow_internal_unsafe");
380386
let mut local_inner_macros = false;

src/libsyntax/feature_gate.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,8 @@ pub const BUILTIN_ATTRIBUTES: &[(&str, AttributeType, AttributeTemplate, Attribu
10831083
stable",
10841084
cfg_fn!(profiler_runtime))),
10851085

1086-
("allow_internal_unstable", Normal, template!(List: "feat1, feat2"), Gated(Stability::Unstable,
1086+
("allow_internal_unstable", Normal, template!(Word, List: "feat1, feat2"),
1087+
Gated(Stability::Unstable,
10871088
"allow_internal_unstable",
10881089
EXPLAIN_ALLOW_INTERNAL_UNSTABLE,
10891090
cfg_fn!(allow_internal_unstable))),

src/libsyntax_pos/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,10 @@ impl Span {
400400
/// `#[allow_internal_unstable]`).
401401
pub fn allows_unstable(&self, feature: &str) -> bool {
402402
match self.ctxt().outer().expn_info() {
403-
Some(info) => info.allow_internal_unstable.iter().any(|&f| f == feature),
403+
Some(info) => info
404+
.allow_internal_unstable
405+
.iter()
406+
.any(|&f| f == feature || f == "allow_internal_unstable_backcompat_hack"),
404407
None => false,
405408
}
406409
}

0 commit comments

Comments
 (0)