Skip to content

Commit b64572c

Browse files
committed
Add unmarked_api feature (fixes #21884)
1 parent 4aa661a commit b64572c

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/librustc/middle/stability.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,19 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
253253
None => {
254254
// This is an 'unmarked' API, which should not exist
255255
// in the standard library.
256-
self.tcx.sess.span_err(span, "use of unmarked library feature");
257-
self.tcx.sess.span_note(span, "this is either a bug in the library you are \
258-
using or a bug in the compiler - there is \
259-
no way to use this feature");
256+
if self.tcx.sess.features.borrow().unmarked_api {
257+
self.tcx.sess.span_warn(span, "use of unmarked library feature");
258+
self.tcx.sess.span_note(span, "this is either a bug in the library you are \
259+
using and a bug in the compiler - please \
260+
report it in both places");
261+
} else {
262+
self.tcx.sess.span_err(span, "use of unmarked library feature");
263+
self.tcx.sess.span_note(span, "this is either a bug in the library you are \
264+
using and a bug in the compiler - please \
265+
report it in both places");
266+
self.tcx.sess.span_note(span, "use #![feature(unmarked_api)] in the \
267+
crate attributes to override this");
268+
}
260269
}
261270
}
262271
}

src/libsyntax/feature_gate.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ static KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[
119119

120120
// Allows use of #[staged_api]
121121
("staged_api", "1.0.0", Active),
122+
123+
// Allows using items which are missing stability attributes
124+
("unmarked_api", "1.0.0", Active)
122125
];
123126

124127
enum Status {
@@ -145,6 +148,7 @@ pub struct Features {
145148
pub quote: bool,
146149
pub old_orphan_check: bool,
147150
pub simd_ffi: bool,
151+
pub unmarked_api: bool,
148152
pub lib_features: Vec<(InternedString, Span)>
149153
}
150154

@@ -157,6 +161,7 @@ impl Features {
157161
quote: false,
158162
old_orphan_check: false,
159163
simd_ffi: false,
164+
unmarked_api: false,
160165
lib_features: Vec::new()
161166
}
162167
}
@@ -566,6 +571,7 @@ fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::C
566571
quote: cx.has_feature("quote"),
567572
old_orphan_check: cx.has_feature("old_orphan_check"),
568573
simd_ffi: cx.has_feature("simd_ffi"),
574+
unmarked_api: cx.has_feature("unmarked_api"),
569575
lib_features: unknown_features
570576
}
571577
}

0 commit comments

Comments
 (0)