Skip to content

Commit 18481b6

Browse files
committed
Auto merge of #62507 - petrochenkov:macunstab, r=<try>
[WIP] Feature gate `(Rustc){En,De}codable` and `bench` for crater run cc #62048 r? @ghost
2 parents 78ca1bd + 935c72a commit 18481b6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+48
-2450
lines changed

src/librustc/lint/builtin.rs

+6
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,12 @@ declare_lint! {
335335
via the module system"
336336
}
337337

338+
declare_lint! {
339+
pub CRATER_RUN,
340+
Deny,
341+
"crater run"
342+
}
343+
338344
declare_lint! {
339345
pub MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
340346
Deny,

src/librustc_resolve/macros.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1012,10 +1012,17 @@ impl<'a> Resolver<'a> {
10121012

10131013
fn check_stability_and_deprecation(&self, ext: &SyntaxExtension, path: &str, span: Span) {
10141014
if let Some(stability) = &ext.stability {
1015-
if let StabilityLevel::Unstable { reason, issue } = stability.level {
1015+
if let StabilityLevel::Unstable { .. } = stability.level {
10161016
let feature = stability.feature;
10171017
if !self.active_features.contains(&feature) && !span.allows_unstable(feature) {
1018-
stability::report_unstable(self.session, feature, reason, issue, span);
1018+
if !self.session.opts.debugging_opts.force_unstable_if_unmarked {
1019+
self.session.buffer_lint(
1020+
lint::builtin::CRATER_RUN,
1021+
ast::CRATE_NODE_ID,
1022+
span,
1023+
&format!("`{}` is unstable", path),
1024+
);
1025+
}
10191026
}
10201027
}
10211028
if let Some(depr) = &stability.rustc_depr {

src/libsyntax_ext/deriving/mod.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use rustc_data_structures::sync::Lrc;
44
use syntax::ast::{self, MetaItem};
5-
use syntax::attr::Deprecation;
5+
use syntax::attr::Stability;
66
use syntax::edition::Edition;
77
use syntax::ext::base::{Annotatable, ExtCtxt, Resolver, MultiItemModifier};
88
use syntax::ext::base::{SyntaxExtension, SyntaxExtensionKind};
@@ -61,7 +61,7 @@ impl MultiItemModifier for BuiltinDerive {
6161
}
6262

6363
macro_rules! derive_traits {
64-
($( [$deprecation:expr] $name:ident => $func:path, )+) => {
64+
($( [$stability:expr] $name:ident => $func:path, )+) => {
6565
pub fn is_builtin_trait(name: ast::Name) -> bool {
6666
match name {
6767
$( sym::$name )|+ => true,
@@ -82,10 +82,7 @@ macro_rules! derive_traits {
8282
resolver.add_builtin(
8383
ast::Ident::with_empty_ctxt(sym::$name),
8484
Lrc::new(SyntaxExtension {
85-
deprecation: $deprecation.map(|msg| Deprecation {
86-
since: Some(Symbol::intern("1.0.0")),
87-
note: Some(Symbol::intern(msg)),
88-
}),
85+
stability: $stability,
8986
allow_internal_unstable: allow_internal_unstable.clone(),
9087
..SyntaxExtension::default(
9188
SyntaxExtensionKind::LegacyDerive(Box::new(BuiltinDerive($func))),
@@ -105,10 +102,14 @@ derive_traits! {
105102
[None]
106103
Hash => hash::expand_deriving_hash,
107104

108-
[None]
105+
[Some(Stability::unstable(
106+
sym::rustc_private, Some(Symbol::intern("RustcEncodable crater run")), 0
107+
))]
109108
RustcEncodable => encodable::expand_deriving_rustc_encodable,
110109

111-
[None]
110+
[Some(Stability::unstable(
111+
sym::rustc_private, Some(Symbol::intern("RustcDecodable crater run")), 0
112+
))]
112113
RustcDecodable => decodable::expand_deriving_rustc_decodable,
113114

114115
[None]
@@ -130,9 +131,9 @@ derive_traits! {
130131
Copy => bounds::expand_deriving_copy,
131132

132133
// deprecated
133-
[Some("derive(Encodable) is deprecated in favor of derive(RustcEncodable)")]
134+
[Some(Stability::unstable(sym::rustc_private, Some(Symbol::intern("Encodable crater run")), 0))]
134135
Encodable => encodable::expand_deriving_encodable,
135-
[Some("derive(Decodable) is deprecated in favor of derive(RustcDecodable)")]
136+
[Some(Stability::unstable(sym::rustc_private, Some(Symbol::intern("Decodable crater run")), 0))]
136137
Decodable => decodable::expand_deriving_decodable,
137138
}
138139

src/libsyntax_ext/lib.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,16 @@ pub fn register_builtins(resolver: &mut dyn syntax::ext::base::Resolver,
138138
register(sym::test, SyntaxExtension::default(
139139
SyntaxExtensionKind::LegacyAttr(Box::new(test::expand_test)), edition
140140
));
141-
register(sym::bench, SyntaxExtension::default(
142-
SyntaxExtensionKind::LegacyAttr(Box::new(test::expand_bench)), edition
143-
));
141+
register(sym::bench, SyntaxExtension {
142+
stability: Some(Stability::unstable(
143+
sym::test,
144+
Some(Symbol::intern("bench crater run")),
145+
0,
146+
)),
147+
..SyntaxExtension::default(
148+
SyntaxExtensionKind::LegacyAttr(Box::new(test::expand_bench)), edition
149+
)
150+
});
144151

145152
// format_args uses `unstable` things internally.
146153
let allow_internal_unstable = Some([sym::fmt_internals][..].into());

src/test/run-make-fulldeps/pretty-expanded/Makefile

-5
This file was deleted.

src/test/run-make-fulldeps/pretty-expanded/input.rs

-12
This file was deleted.

src/test/ui-fulldeps/deprecated-derive.rs

-12
This file was deleted.

src/test/ui-fulldeps/deprecated-derive.stderr

-8
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
error: `bench` is unstable
2+
--> $DIR/issue-43106-gating-of-bench.rs:15:1
3+
|
4+
LL | #![bench = "4100"]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: #[deny(crater_run)] on by default
8+
19
error[E0601]: `main` function not found in crate `issue_43106_gating_of_bench`
210
|
311
= note: consider adding a `main` function to `$DIR/issue-43106-gating-of-bench.rs`
412

5-
error: aborting due to previous error
13+
error: aborting due to 2 previous errors
614

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

0 commit comments

Comments
 (0)