Add unmarked_api feature (fixes #21884)

This commit is contained in:
Manish Goregaokar 2015-02-04 01:21:26 +05:30
parent 4aa661ab36
commit b64572cefe
2 changed files with 19 additions and 4 deletions

View File

@ -253,10 +253,19 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
None => {
// This is an 'unmarked' API, which should not exist
// in the standard library.
self.tcx.sess.span_err(span, "use of unmarked library feature");
self.tcx.sess.span_note(span, "this is either a bug in the library you are \
using or a bug in the compiler - there is \
no way to use this feature");
if self.tcx.sess.features.borrow().unmarked_api {
self.tcx.sess.span_warn(span, "use of unmarked library feature");
self.tcx.sess.span_note(span, "this is either a bug in the library you are \
using and a bug in the compiler - please \
report it in both places");
} else {
self.tcx.sess.span_err(span, "use of unmarked library feature");
self.tcx.sess.span_note(span, "this is either a bug in the library you are \
using and a bug in the compiler - please \
report it in both places");
self.tcx.sess.span_note(span, "use #![feature(unmarked_api)] in the \
crate attributes to override this");
}
}
}
}

View File

@ -119,6 +119,9 @@ static KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[
// Allows use of #[staged_api]
("staged_api", "1.0.0", Active),
// Allows using items which are missing stability attributes
("unmarked_api", "1.0.0", Active)
];
enum Status {
@ -145,6 +148,7 @@ pub struct Features {
pub quote: bool,
pub old_orphan_check: bool,
pub simd_ffi: bool,
pub unmarked_api: bool,
pub lib_features: Vec<(InternedString, Span)>
}
@ -157,6 +161,7 @@ impl Features {
quote: false,
old_orphan_check: false,
simd_ffi: false,
unmarked_api: false,
lib_features: Vec::new()
}
}
@ -566,6 +571,7 @@ fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::C
quote: cx.has_feature("quote"),
old_orphan_check: cx.has_feature("old_orphan_check"),
simd_ffi: cx.has_feature("simd_ffi"),
unmarked_api: cx.has_feature("unmarked_api"),
lib_features: unknown_features
}
}