Skip to content

Commit

Permalink
Auto merge of #62507 - petrochenkov:macunstab, r=<try>
Browse files Browse the repository at this point in the history
[WIP] Feature gate `(Rustc){En,De}codable` and `bench` for crater run

cc #62048
r? @ghost
  • Loading branch information
bors committed Jul 8, 2019
2 parents 78ca1bd + 935c72a commit 18481b6
Show file tree
Hide file tree
Showing 46 changed files with 48 additions and 2,450 deletions.
6 changes: 6 additions & 0 deletions src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,12 @@ declare_lint! {
via the module system"
}

declare_lint! {
pub CRATER_RUN,
Deny,
"crater run"
}

declare_lint! {
pub MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
Deny,
Expand Down
11 changes: 9 additions & 2 deletions src/librustc_resolve/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,10 +1012,17 @@ impl<'a> Resolver<'a> {

fn check_stability_and_deprecation(&self, ext: &SyntaxExtension, path: &str, span: Span) {
if let Some(stability) = &ext.stability {
if let StabilityLevel::Unstable { reason, issue } = stability.level {
if let StabilityLevel::Unstable { .. } = stability.level {
let feature = stability.feature;
if !self.active_features.contains(&feature) && !span.allows_unstable(feature) {
stability::report_unstable(self.session, feature, reason, issue, span);
if !self.session.opts.debugging_opts.force_unstable_if_unmarked {
self.session.buffer_lint(
lint::builtin::CRATER_RUN,
ast::CRATE_NODE_ID,
span,
&format!("`{}` is unstable", path),
);
}
}
}
if let Some(depr) = &stability.rustc_depr {
Expand Down
21 changes: 11 additions & 10 deletions src/libsyntax_ext/deriving/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use rustc_data_structures::sync::Lrc;
use syntax::ast::{self, MetaItem};
use syntax::attr::Deprecation;
use syntax::attr::Stability;
use syntax::edition::Edition;
use syntax::ext::base::{Annotatable, ExtCtxt, Resolver, MultiItemModifier};
use syntax::ext::base::{SyntaxExtension, SyntaxExtensionKind};
Expand Down Expand Up @@ -61,7 +61,7 @@ impl MultiItemModifier for BuiltinDerive {
}

macro_rules! derive_traits {
($( [$deprecation:expr] $name:ident => $func:path, )+) => {
($( [$stability:expr] $name:ident => $func:path, )+) => {
pub fn is_builtin_trait(name: ast::Name) -> bool {
match name {
$( sym::$name )|+ => true,
Expand All @@ -82,10 +82,7 @@ macro_rules! derive_traits {
resolver.add_builtin(
ast::Ident::with_empty_ctxt(sym::$name),
Lrc::new(SyntaxExtension {
deprecation: $deprecation.map(|msg| Deprecation {
since: Some(Symbol::intern("1.0.0")),
note: Some(Symbol::intern(msg)),
}),
stability: $stability,
allow_internal_unstable: allow_internal_unstable.clone(),
..SyntaxExtension::default(
SyntaxExtensionKind::LegacyDerive(Box::new(BuiltinDerive($func))),
Expand All @@ -105,10 +102,14 @@ derive_traits! {
[None]
Hash => hash::expand_deriving_hash,

[None]
[Some(Stability::unstable(
sym::rustc_private, Some(Symbol::intern("RustcEncodable crater run")), 0
))]
RustcEncodable => encodable::expand_deriving_rustc_encodable,

[None]
[Some(Stability::unstable(
sym::rustc_private, Some(Symbol::intern("RustcDecodable crater run")), 0
))]
RustcDecodable => decodable::expand_deriving_rustc_decodable,

[None]
Expand All @@ -130,9 +131,9 @@ derive_traits! {
Copy => bounds::expand_deriving_copy,

// deprecated
[Some("derive(Encodable) is deprecated in favor of derive(RustcEncodable)")]
[Some(Stability::unstable(sym::rustc_private, Some(Symbol::intern("Encodable crater run")), 0))]
Encodable => encodable::expand_deriving_encodable,
[Some("derive(Decodable) is deprecated in favor of derive(RustcDecodable)")]
[Some(Stability::unstable(sym::rustc_private, Some(Symbol::intern("Decodable crater run")), 0))]
Decodable => decodable::expand_deriving_decodable,
}

Expand Down
13 changes: 10 additions & 3 deletions src/libsyntax_ext/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,16 @@ pub fn register_builtins(resolver: &mut dyn syntax::ext::base::Resolver,
register(sym::test, SyntaxExtension::default(
SyntaxExtensionKind::LegacyAttr(Box::new(test::expand_test)), edition
));
register(sym::bench, SyntaxExtension::default(
SyntaxExtensionKind::LegacyAttr(Box::new(test::expand_bench)), edition
));
register(sym::bench, SyntaxExtension {
stability: Some(Stability::unstable(
sym::test,
Some(Symbol::intern("bench crater run")),
0,
)),
..SyntaxExtension::default(
SyntaxExtensionKind::LegacyAttr(Box::new(test::expand_bench)), edition
)
});

// format_args uses `unstable` things internally.
let allow_internal_unstable = Some([sym::fmt_internals][..].into());
Expand Down
5 changes: 0 additions & 5 deletions src/test/run-make-fulldeps/pretty-expanded/Makefile

This file was deleted.

12 changes: 0 additions & 12 deletions src/test/run-make-fulldeps/pretty-expanded/input.rs

This file was deleted.

12 changes: 0 additions & 12 deletions src/test/ui-fulldeps/deprecated-derive.rs

This file was deleted.

8 changes: 0 additions & 8 deletions src/test/ui-fulldeps/deprecated-derive.stderr

This file was deleted.

10 changes: 9 additions & 1 deletion src/test/ui/feature-gate/issue-43106-gating-of-bench.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
error: `bench` is unstable
--> $DIR/issue-43106-gating-of-bench.rs:15:1
|
LL | #![bench = "4100"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(crater_run)] on by default

error[E0601]: `main` function not found in crate `issue_43106_gating_of_bench`
|
= note: consider adding a `main` function to `$DIR/issue-43106-gating-of-bench.rs`

error: aborting due to previous error
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0601`.
Loading

0 comments on commit 18481b6

Please sign in to comment.