Skip to content

Commit 33bf81e

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 d3c212c commit 33bf81e

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
@@ -379,14 +379,20 @@ pub fn compile(
379379
let allow_internal_unstable = attr::find_by_name(&def.attrs, "allow_internal_unstable")
380380
.map_or(Vec::new(), |attr| attr
381381
.meta_item_list()
382-
.unwrap_or_else(|| sess.span_diagnostic.span_bug(
383-
attr.span, "allow_internal_unstable expects list of feature names",
384-
))
385-
.iter()
386-
.map(|it| it.name().unwrap_or_else(|| sess.span_diagnostic.span_bug(
387-
it.span, "allow internal unstable expects feature names",
388-
)))
389-
.collect()
382+
.map(|list| list.iter()
383+
.map(|it| it.name().unwrap_or_else(|| sess.span_diagnostic.span_bug(
384+
it.span, "allow internal unstable expects feature names",
385+
)))
386+
.collect()
387+
)
388+
.unwrap_or_else(|| {
389+
sess.span_diagnostic.span_warn(
390+
attr.span, "allow_internal_unstable expects list of feature names. In the \
391+
future this will become a hard error. Please use `allow_internal_unstable(\
392+
foo, bar)` to only allow the `foo` and `bar` features",
393+
);
394+
vec![Symbol::intern("allow_internal_unstable_backcompat_hack")]
395+
})
390396
);
391397
let allow_internal_unsafe = attr::contains_name(&def.attrs, "allow_internal_unsafe");
392398
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
@@ -1091,7 +1091,8 @@ pub const BUILTIN_ATTRIBUTES: &[(&str, AttributeType, AttributeTemplate, Attribu
10911091
stable",
10921092
cfg_fn!(profiler_runtime))),
10931093

1094-
("allow_internal_unstable", Normal, template!(List: "feat1, feat2"), Gated(Stability::Unstable,
1094+
("allow_internal_unstable", Normal, template!(Word, List: "feat1, feat2"),
1095+
Gated(Stability::Unstable,
10951096
"allow_internal_unstable",
10961097
EXPLAIN_ALLOW_INTERNAL_UNSTABLE,
10971098
cfg_fn!(allow_internal_unstable))),

src/libsyntax_pos/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,10 @@ impl Span {
387387
/// `#[allow_internal_unstable]`).
388388
pub fn allows_unstable(&self, feature: &str) -> bool {
389389
match self.ctxt().outer().expn_info() {
390-
Some(info) => info.allow_internal_unstable.iter().any(|&f| f == feature),
390+
Some(info) => info
391+
.allow_internal_unstable
392+
.iter()
393+
.any(|&f| f == feature || f == "allow_internal_unstable_backcompat_hack"),
391394
None => false,
392395
}
393396
}

0 commit comments

Comments
 (0)