Skip to content

Commit d98100b

Browse files
committed
Give removal reasons to removed features
1 parent 300b6bb commit d98100b

File tree

2 files changed

+46
-36
lines changed

2 files changed

+46
-36
lines changed

src/libsyntax/feature_gate.rs

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,24 @@ macro_rules! declare_features {
9090
}
9191
};
9292

93-
($((removed, $feature: ident, $ver: expr, $issue: expr, None),)+) => {
93+
($((removed, $feature: ident, $ver: expr, $issue: expr, None, $reason: expr),)+) => {
9494
/// Represents unstable features which have since been removed (it was once Active)
95-
const REMOVED_FEATURES: &'static [(&'static str, &'static str, Option<u32>)] = &[
96-
$((stringify!($feature), $ver, $issue)),+
95+
const REMOVED_FEATURES: &[(&str, &str, Option<u32>, Option<&str>)] = &[
96+
$((stringify!($feature), $ver, $issue, $reason)),+
9797
];
9898
};
9999

100100
($((stable_removed, $feature: ident, $ver: expr, $issue: expr, None),)+) => {
101101
/// Represents stable features which have since been removed (it was once Accepted)
102-
const STABLE_REMOVED_FEATURES: &'static [(&'static str, &'static str, Option<u32>)] = &[
103-
$((stringify!($feature), $ver, $issue)),+
102+
const STABLE_REMOVED_FEATURES: &[(&str, &str, Option<u32>, Option<&str>)] = &[
103+
$((stringify!($feature), $ver, $issue, None)),+
104104
];
105105
};
106106

107107
($((accepted, $feature: ident, $ver: expr, $issue: expr, None),)+) => {
108108
/// Those language feature has since been Accepted (it was once Active)
109-
const ACCEPTED_FEATURES: &'static [(&'static str, &'static str, Option<u32>)] = &[
110-
$((stringify!($feature), $ver, $issue)),+
109+
const ACCEPTED_FEATURES: &[(&str, &str, Option<u32>, Option<&str>)] = &[
110+
$((stringify!($feature), $ver, $issue, None)),+
111111
];
112112
}
113113
}
@@ -460,29 +460,29 @@ declare_features! (
460460
);
461461

462462
declare_features! (
463-
(removed, import_shadowing, "1.0.0", None, None),
464-
(removed, managed_boxes, "1.0.0", None, None),
463+
(removed, import_shadowing, "1.0.0", None, None, None),
464+
(removed, managed_boxes, "1.0.0", None, None, None),
465465
// Allows use of unary negate on unsigned integers, e.g. -e for e: u8
466-
(removed, negate_unsigned, "1.0.0", Some(29645), None),
467-
(removed, reflect, "1.0.0", Some(27749), None),
466+
(removed, negate_unsigned, "1.0.0", Some(29645), None, None),
467+
(removed, reflect, "1.0.0", Some(27749), None, None),
468468
// A way to temporarily opt out of opt in copy. This will *never* be accepted.
469-
(removed, opt_out_copy, "1.0.0", None, None),
470-
(removed, quad_precision_float, "1.0.0", None, None),
471-
(removed, struct_inherit, "1.0.0", None, None),
472-
(removed, test_removed_feature, "1.0.0", None, None),
473-
(removed, visible_private_types, "1.0.0", None, None),
474-
(removed, unsafe_no_drop_flag, "1.0.0", None, None),
469+
(removed, opt_out_copy, "1.0.0", None, None, None),
470+
(removed, quad_precision_float, "1.0.0", None, None, None),
471+
(removed, struct_inherit, "1.0.0", None, None, None),
472+
(removed, test_removed_feature, "1.0.0", None, None, None),
473+
(removed, visible_private_types, "1.0.0", None, None, None),
474+
(removed, unsafe_no_drop_flag, "1.0.0", None, None, None),
475475
// Allows using items which are missing stability attributes
476476
// rustc internal
477-
(removed, unmarked_api, "1.0.0", None, None),
478-
(removed, pushpop_unsafe, "1.2.0", None, None),
479-
(removed, allocator, "1.0.0", None, None),
480-
// Allows the `#[simd]` attribute -- removed in favor of `#[repr(simd)]`
481-
(removed, simd, "1.0.0", Some(27731), None),
482-
// Merged into `slice_patterns`
483-
(removed, advanced_slice_patterns, "1.0.0", Some(23121), None),
484-
// Subsumed by `use`
485-
(removed, macro_reexport, "1.0.0", Some(29638), None),
477+
(removed, unmarked_api, "1.0.0", None, None, None),
478+
(removed, pushpop_unsafe, "1.2.0", None, None, None),
479+
(removed, allocator, "1.0.0", None, None, None),
480+
(removed, simd, "1.0.0", Some(27731), None,
481+
Some("removed in favor of `#[repr(simd)]`")),
482+
(removed, advanced_slice_patterns, "1.0.0", Some(23121), None,
483+
Some("merged into `#![feature(slice_patterns)]`")),
484+
(removed, macro_reexport, "1.0.0", Some(29638), None,
485+
Some("subsumed by `#![feature(use_extern_macros)]` and `pub use`")),
486486
);
487487

488488
declare_features! (
@@ -1200,7 +1200,7 @@ fn find_lang_feature_issue(feature: &str) -> Option<u32> {
12001200
let found = ACCEPTED_FEATURES.iter().chain(REMOVED_FEATURES).chain(STABLE_REMOVED_FEATURES)
12011201
.find(|t| t.0 == feature);
12021202
match found {
1203-
Some(&(_, _, issue)) => issue,
1203+
Some(&(_, _, issue, _)) => issue,
12041204
None => panic!("Feature `{}` is not declared anywhere", feature),
12051205
}
12061206
}
@@ -1814,8 +1814,12 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
18141814

18151815
pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
18161816
crate_edition: Edition) -> Features {
1817-
fn feature_removed(span_handler: &Handler, span: Span) {
1818-
span_err!(span_handler, span, E0557, "feature has been removed");
1817+
fn feature_removed(span_handler: &Handler, span: Span, reason: Option<&str>) {
1818+
let mut err = struct_span_err!(span_handler, span, E0557, "feature has been removed");
1819+
if let Some(reason) = reason {
1820+
err.span_note(span, reason);
1821+
}
1822+
err.emit();
18191823
}
18201824

18211825
let mut features = Features::new();
@@ -1848,19 +1852,19 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
18481852
set(&mut features, mi.span);
18491853
feature_checker.collect(&features, mi.span);
18501854
}
1851-
else if let Some(&(_, _, _)) = REMOVED_FEATURES.iter()
1852-
.find(|& &(n, _, _)| name == n)
1855+
else if let Some(&(.., reason)) = REMOVED_FEATURES.iter()
1856+
.find(|& &(n, ..)| name == n)
18531857
.or_else(|| STABLE_REMOVED_FEATURES.iter()
1854-
.find(|& &(n, _, _)| name == n)) {
1855-
feature_removed(span_handler, mi.span);
1858+
.find(|& &(n, ..)| name == n)) {
1859+
feature_removed(span_handler, mi.span, reason);
18561860
}
1857-
else if let Some(&(_, _, _)) = ACCEPTED_FEATURES.iter()
1858-
.find(|& &(n, _, _)| name == n) {
1861+
else if let Some(&(..)) = ACCEPTED_FEATURES.iter()
1862+
.find(|& &(n, ..)| name == n) {
18591863
features.declared_stable_lang_features.push((name, mi.span));
18601864
} else if let Some(&edition) = ALL_EDITIONS.iter()
18611865
.find(|e| name == e.feature_name()) {
18621866
if edition <= crate_edition {
1863-
feature_removed(span_handler, mi.span);
1867+
feature_removed(span_handler, mi.span, None);
18641868
} else {
18651869
for &(.., f_edition, set) in ACTIVE_FEATURES.iter() {
18661870
if let Some(f_edition) = f_edition {

src/test/ui/macro-reexport-removed.stderr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
error[E0557]: feature has been removed
22
--> $DIR/macro-reexport-removed.rs:13:12
33
|
4+
LL | #![feature(macro_reexport)] //~ ERROR feature has been removed
5+
| ^^^^^^^^^^^^^^
6+
|
7+
note: subsumed by `#![feature(use_extern_macros)]` and `pub use`
8+
--> $DIR/macro-reexport-removed.rs:13:12
9+
|
410
LL | #![feature(macro_reexport)] //~ ERROR feature has been removed
511
| ^^^^^^^^^^^^^^
612

0 commit comments

Comments
 (0)