Skip to content

Commit 31310f5

Browse files
committed
Allow tracking issues for lang features.
This is similar to the libs version, which allow an `issue` field in the `#[unstable]` attribute. cc #28244
1 parent 62c45f4 commit 31310f5

File tree

12 files changed

+145
-110
lines changed

12 files changed

+145
-110
lines changed

src/etc/featureck.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,24 @@
4747
is_feature_line = True
4848

4949
if is_feature_line:
50-
line = line.replace("(", "").replace("),", "").replace(")", "")
50+
# turn ` ("foo", "1.0.0", Some(10), Active)` into
51+
# `"foo", "1.0.0", Some(10), Active`
52+
line = line.strip(' ,()')
5153
parts = line.split(",")
52-
if len(parts) != 3:
54+
if len(parts) != 4:
5355
print("error: unexpected number of components in line: " + original_line)
5456
sys.exit(1)
5557
feature_name = parts[0].strip().replace('"', "")
5658
since = parts[1].strip().replace('"', "")
57-
status = parts[2].strip()
59+
issue = parts[2].strip()
60+
status = parts[3].strip()
5861
assert len(feature_name) > 0
5962
assert len(since) > 0
63+
assert len(issue) > 0
6064
assert len(status) > 0
6165

6266
language_feature_names += [feature_name]
63-
language_features += [(feature_name, since, status)]
67+
language_features += [(feature_name, since, issue, status)]
6468

6569
assert len(language_features) > 0
6670

@@ -158,7 +162,7 @@
158162
status = "unstable"
159163
stable_since = None
160164

161-
if f[2] == "Accepted":
165+
if f[3] == "Accepted":
162166
status = "stable"
163167
if status == "stable":
164168
stable_since = f[1]

src/librustc/middle/check_static_recursion.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use util::nodemap::NodeMap;
1818

1919
use syntax::{ast};
2020
use syntax::codemap::Span;
21-
use syntax::feature_gate::emit_feature_err;
21+
use syntax::feature_gate::{GateIssue, emit_feature_err};
2222
use rustc_front::visit::Visitor;
2323
use rustc_front::visit;
2424
use rustc_front::hir;
@@ -143,7 +143,7 @@ impl<'a, 'ast: 'a> CheckItemRecursionVisitor<'a, 'ast> {
143143
if !self.sess.features.borrow().static_recursion {
144144
emit_feature_err(&self.sess.parse_sess.span_diagnostic,
145145
"static_recursion",
146-
*self.root_span, "recursive static");
146+
*self.root_span, GateIssue::Language, "recursive static");
147147
}
148148
} else {
149149
span_err!(self.sess, *self.root_span, E0265, "recursive constant");

src/librustc/middle/stability.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use syntax::parse::token::InternedString;
2222
use syntax::codemap::{Span, DUMMY_SP};
2323
use syntax::ast;
2424
use syntax::ast::NodeId;
25-
use syntax::feature_gate::emit_feature_err;
25+
use syntax::feature_gate::{GateIssue, emit_feature_err};
2626
use util::nodemap::{DefIdMap, FnvHashSet, FnvHashMap};
2727

2828
use rustc_front::hir;
@@ -294,18 +294,14 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
294294
self.used_features.insert(feature.clone(), attr::Unstable);
295295

296296
if !self.active_features.contains(feature) {
297-
let mut msg = match *reason {
297+
let msg = match *reason {
298298
Some(ref r) => format!("use of unstable library feature '{}': {}",
299299
&feature, &r),
300300
None => format!("use of unstable library feature '{}'", &feature)
301301
};
302-
if let Some(n) = issue {
303-
use std::fmt::Write;
304-
write!(&mut msg, " (see issue #{})", n).unwrap();
305-
}
306302

307303
emit_feature_err(&self.tcx.sess.parse_sess.span_diagnostic,
308-
&feature, span, &msg);
304+
&feature, span, GateIssue::Library(issue), &msg);
309305
}
310306
}
311307
Some(&Stability { level, ref feature, .. }) => {

src/librustc_typeck/astconv.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ use util::nodemap::FnvHashSet;
7070
use std::slice;
7171
use syntax::{abi, ast};
7272
use syntax::codemap::{Span, Pos};
73-
use syntax::feature_gate::emit_feature_err;
73+
use syntax::feature_gate::{GateIssue, emit_feature_err};
7474
use syntax::parse::token;
7575

7676
use rustc_front::print::pprust;
@@ -797,7 +797,7 @@ fn create_substs_for_ast_trait_ref<'a,'tcx>(this: &AstConv<'tcx>,
797797
// only with `Fn()` etc.
798798
if !this.tcx().sess.features.borrow().unboxed_closures && trait_def.paren_sugar {
799799
emit_feature_err(&this.tcx().sess.parse_sess.span_diagnostic,
800-
"unboxed_closures", span,
800+
"unboxed_closures", span, GateIssue::Language,
801801
"\
802802
the precise format of `Fn`-family traits' type parameters is \
803803
subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead");
@@ -810,7 +810,7 @@ fn create_substs_for_ast_trait_ref<'a,'tcx>(this: &AstConv<'tcx>,
810810
// only with `Fn()` etc.
811811
if !this.tcx().sess.features.borrow().unboxed_closures && !trait_def.paren_sugar {
812812
emit_feature_err(&this.tcx().sess.parse_sess.span_diagnostic,
813-
"unboxed_closures", span,
813+
"unboxed_closures", span, GateIssue::Language,
814814
"\
815815
parenthetical notation is only stable when used with `Fn`-family traits");
816816
}

src/libsyntax/ext/asm.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
5151
-> Box<base::MacResult+'cx> {
5252
if !cx.ecfg.enable_asm() {
5353
feature_gate::emit_feature_err(
54-
&cx.parse_sess.span_diagnostic, "asm", sp, feature_gate::EXPLAIN_ASM);
54+
&cx.parse_sess.span_diagnostic, "asm", sp,
55+
feature_gate::GateIssue::Language,
56+
feature_gate::EXPLAIN_ASM);
5557
return DummyResult::expr(sp);
5658
}
5759

src/libsyntax/ext/concat_idents.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub fn expand_syntax_ext<'cx>(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]
2323
feature_gate::emit_feature_err(&cx.parse_sess.span_diagnostic,
2424
"concat_idents",
2525
sp,
26+
feature_gate::GateIssue::Language,
2627
feature_gate::EXPLAIN_CONCAT_IDENTS);
2728
return base::DummyResult::expr(sp);
2829
}

src/libsyntax/ext/deriving/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ fn expand_derive(cx: &mut ExtCtxt,
105105
feature_gate::emit_feature_err(&cx.parse_sess.span_diagnostic,
106106
"custom_derive",
107107
titem.span,
108+
feature_gate::GateIssue::Language,
108109
feature_gate::EXPLAIN_CUSTOM_DERIVE);
109110
continue;
110111
}

src/libsyntax/ext/expand.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,7 @@ pub fn expand_item_mac(it: P<ast::Item>,
778778
&fld.cx.parse_sess.span_diagnostic,
779779
"allow_internal_unstable",
780780
it.span,
781+
feature_gate::GateIssue::Language,
781782
feature_gate::EXPLAIN_ALLOW_INTERNAL_UNSTABLE)
782783
}
783784

@@ -1469,7 +1470,8 @@ pub fn expand_type(t: P<ast::Ty>, fld: &mut MacroExpander) -> P<ast::Ty> {
14691470
&fld.cx.parse_sess.span_diagnostic,
14701471
"type_macros",
14711472
t.span,
1472-
"type macros are experimental (see issue: #27336)");
1473+
feature_gate::GateIssue::Language,
1474+
"type macros are experimental");
14731475

14741476
DummyResult::raw_ty(t.span)
14751477
}

src/libsyntax/ext/log_syntax.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut base::ExtCtxt,
2222
feature_gate::emit_feature_err(&cx.parse_sess.span_diagnostic,
2323
"log_syntax",
2424
sp,
25+
feature_gate::GateIssue::Language,
2526
feature_gate::EXPLAIN_LOG_SYNTAX);
2627
return base::DummyResult::any(sp);
2728
}

src/libsyntax/ext/trace_macros.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub fn expand_trace_macros(cx: &mut ExtCtxt,
2424
feature_gate::emit_feature_err(&cx.parse_sess.span_diagnostic,
2525
"trace_macros",
2626
sp,
27+
feature_gate::GateIssue::Language,
2728
feature_gate::EXPLAIN_TRACE_MACROS);
2829
return base::DummyResult::any(sp);
2930
}

0 commit comments

Comments
 (0)