Skip to content

Commit 9fc0257

Browse files
committed
By changing some attributes to only_local, reducing encoding attributes in the crate metadate.
Thank you. This is part of changing attributes to only_local. I hope get your opinion whether I should split into multiple PRs, or submit in one. According to [try to not rely on attributes from extern crates](rust-lang/compiler-team#505) and lcnr's guidance.
1 parent 026b3b8 commit 9fc0257

File tree

1 file changed

+50
-21
lines changed

1 file changed

+50
-21
lines changed

compiler/rustc_feature/src/builtin_attrs.rs

+50-21
Original file line numberDiff line numberDiff line change
@@ -274,29 +274,42 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
274274
// ==========================================================================
275275

276276
// Conditional compilation:
277-
ungated!(cfg, Normal, template!(List: "predicate"), DuplicatesOk),
278-
ungated!(cfg_attr, Normal, template!(List: "predicate, attr1, attr2, ..."), DuplicatesOk),
277+
ungated!(cfg, Normal, template!(List: "predicate"), DuplicatesOk, @only_local: true),
278+
ungated!(
279+
cfg_attr, Normal, template!(List: "predicate, attr1, attr2, ..."), DuplicatesOk,
280+
@only_local: true,
281+
),
279282

280283
// Testing:
281-
ungated!(ignore, Normal, template!(Word, NameValueStr: "reason"), WarnFollowing),
284+
ungated!(
285+
ignore, Normal, template!(Word, NameValueStr: "reason"), WarnFollowing,
286+
@only_local: true,
287+
),
282288
ungated!(
283289
should_panic, Normal,
284290
template!(Word, List: r#"expected = "reason""#, NameValueStr: "reason"), FutureWarnFollowing,
291+
@only_local: true,
285292
),
286293
// FIXME(Centril): This can be used on stable but shouldn't.
287-
ungated!(reexport_test_harness_main, CrateLevel, template!(NameValueStr: "name"), ErrorFollowing),
294+
ungated!(
295+
reexport_test_harness_main, CrateLevel, template!(NameValueStr: "name"), ErrorFollowing,
296+
@only_local: true,
297+
),
288298

289299
// Macros:
290-
ungated!(automatically_derived, Normal, template!(Word), WarnFollowing),
291-
ungated!(macro_use, Normal, template!(Word, List: "name1, name2, ..."), WarnFollowingWordOnly),
292-
ungated!(macro_escape, Normal, template!(Word), WarnFollowing), // Deprecated synonym for `macro_use`.
300+
ungated!(automatically_derived, Normal, template!(Word), WarnFollowing, @only_local: true),
301+
ungated!(
302+
macro_use, Normal, template!(Word, List: "name1, name2, ..."), WarnFollowingWordOnly,
303+
@only_local: true,
304+
),
305+
ungated!(macro_escape, Normal, template!(Word), WarnFollowing, @only_local: true), // Deprecated synonym for `macro_use`.
293306
ungated!(macro_export, Normal, template!(Word, List: "local_inner_macros"), WarnFollowing),
294-
ungated!(proc_macro, Normal, template!(Word), ErrorFollowing),
307+
ungated!(proc_macro, Normal, template!(Word), ErrorFollowing, @only_local: true),
295308
ungated!(
296-
proc_macro_derive, Normal,
297-
template!(List: "TraitName, /*opt*/ attributes(name1, name2, ...)"), ErrorFollowing,
309+
proc_macro_derive, Normal, template!(List: "TraitName, /*opt*/ attributes(name1, name2, ...)"),
310+
ErrorFollowing, @only_local: true,
298311
),
299-
ungated!(proc_macro_attribute, Normal, template!(Word), ErrorFollowing),
312+
ungated!(proc_macro_attribute, Normal, template!(Word), ErrorFollowing, @only_local: true),
300313

301314
// Lints:
302315
ungated!(
@@ -309,7 +322,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
309322
),
310323
gated!(
311324
expect, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#), DuplicatesOk,
312-
lint_reasons, experimental!(expect)
325+
@only_local: true, lint_reasons, experimental!(expect)
313326
),
314327
ungated!(
315328
forbid, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#),
@@ -335,32 +348,48 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
335348
),
336349

337350
// Crate properties:
338-
ungated!(crate_name, CrateLevel, template!(NameValueStr: "name"), FutureWarnFollowing),
339-
ungated!(crate_type, CrateLevel, template!(NameValueStr: "bin|lib|..."), DuplicatesOk),
351+
ungated!(
352+
crate_name, CrateLevel, template!(NameValueStr: "name"), FutureWarnFollowing,
353+
@only_local: true,
354+
),
355+
ungated!(
356+
crate_type, CrateLevel, template!(NameValueStr: "bin|lib|..."), DuplicatesOk,
357+
@only_local: true,
358+
),
340359
// crate_id is deprecated
341-
ungated!(crate_id, CrateLevel, template!(NameValueStr: "ignored"), FutureWarnFollowing),
360+
ungated!(
361+
crate_id, CrateLevel, template!(NameValueStr: "ignored"), FutureWarnFollowing,
362+
@only_local: true,
363+
),
342364

343365
// ABI, linking, symbols, and FFI
344366
ungated!(
345367
link, Normal,
346368
template!(List: r#"name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...", /*opt*/ import_name_type = "decorated|noprefix|undecorated""#),
347369
DuplicatesOk,
370+
@only_local: true,
348371
),
349372
ungated!(link_name, Normal, template!(NameValueStr: "name"), FutureWarnPreceding),
350-
ungated!(no_link, Normal, template!(Word), WarnFollowing),
373+
ungated!(no_link, Normal, template!(Word), WarnFollowing, @only_local: true),
351374
ungated!(repr, Normal, template!(List: "C"), DuplicatesOk, @only_local: true),
352-
ungated!(export_name, Normal, template!(NameValueStr: "name"), FutureWarnPreceding),
353-
ungated!(link_section, Normal, template!(NameValueStr: "name"), FutureWarnPreceding),
375+
ungated!(export_name, Normal, template!(NameValueStr: "name"), FutureWarnPreceding, @only_local: true),
376+
ungated!(link_section, Normal, template!(NameValueStr: "name"), FutureWarnPreceding, @only_local: true),
354377
ungated!(no_mangle, Normal, template!(Word), WarnFollowing, @only_local: true),
355378
ungated!(used, Normal, template!(Word, List: "compiler|linker"), WarnFollowing, @only_local: true),
356379
ungated!(link_ordinal, Normal, template!(List: "ordinal"), ErrorPreceding),
357380

358381
// Limits:
359-
ungated!(recursion_limit, CrateLevel, template!(NameValueStr: "N"), FutureWarnFollowing),
360-
ungated!(type_length_limit, CrateLevel, template!(NameValueStr: "N"), FutureWarnFollowing),
382+
ungated!(
383+
recursion_limit, CrateLevel, template!(NameValueStr: "N"), FutureWarnFollowing,
384+
@only_local: true
385+
),
386+
ungated!(
387+
type_length_limit, CrateLevel, template!(NameValueStr: "N"), FutureWarnFollowing,
388+
@only_local: true
389+
),
361390
gated!(
362391
move_size_limit, CrateLevel, template!(NameValueStr: "N"), ErrorFollowing,
363-
large_assignments, experimental!(move_size_limit)
392+
@only_local: true, large_assignments, experimental!(move_size_limit)
364393
),
365394

366395
// Entry point:

0 commit comments

Comments
 (0)