rust/compiler
Matthias Krüger da158c04c4
Rollup merge of #83744 - bjorn3:deprecate_cfg_attr_crate_type_name, r=Mark-Simulacrum
Deprecate crate_type and crate_name nested inside #![cfg_attr]

This implements the proposal in https://github.com/rust-lang/rust/pull/83676#issuecomment-811213956, with a future compatibility lint imposed on usage of crate_type/crate_name inside cfg's.

This is a compromise between removing `#![crate_type]` and `#![crate_name]` completely and keeping them as a whole, which requires somewhat of a hack in rustc and is impossible to support by gcc-rust. By only removing `#![crate_type]` and `#![crate_name]` nested inside `#![cfg_attr]` it becomes possible to parse them before a big chunk of the compiler has started.

Replaces https://github.com/rust-lang/rust/pull/83676

```rust
#![crate_type = "lib"] // remains working
#![cfg_attr(foo, crate_type = "bin")] // will stop working
```

# Rationale

As it currently is it is possible to try to access the stable crate id before it is actually set, which will panic. The fact that the Session contains mutable state beyond debugging things also doesn't completely sit well with me. Especially once parallel rustc becomes the default.

I think there is currently also a cyclic dependency where you need to set the stable crate id to be able to load crates, but you need to load crates to expand proc macro attributes that may define #![crate_name] or #![crate_type]. Currently crate level proc macro attributes are unstable or completely unsupported (can't remember which), so this is not a problem, but it may become an issue in the future.

Finally if we want to add incremental compilation to macro expansion or even parsing, we need the StableCrateId to be created together with the Session or even earlier as incremental compilation determines the incremental compilation session dir based on the StableCrateId.
2021-12-08 11:08:55 +01:00
..
rustc
rustc_apfloat
rustc_arena Add some comments. 2021-11-19 07:52:59 +11:00
rustc_ast Add initial AST and MIR support for unwinding from inline assembly 2021-12-03 23:51:46 +01:00
rustc_ast_lowering Use IntoIterator for array impl everywhere. 2021-12-04 19:40:33 +01:00
rustc_ast_passes Rollup merge of #91208 - estebank:eq-constraint, r=cjgillot 2021-11-27 11:46:44 +01:00
rustc_ast_pretty Rollup merge of #91562 - dtolnay:asyncspace, r=Mark-Simulacrum 2021-12-07 11:05:06 +01:00
rustc_attr re-format with new rustfmt 2021-11-30 13:08:41 -05:00
rustc_borrowck Auto merge of #88439 - cynecx:unwind_asm, r=Amanieu 2021-12-04 05:59:16 +00:00
rustc_builtin_macros Rollup merge of #90519 - estebank:issue-84003, r=petrochenkov 2021-12-04 10:42:20 +01:00
rustc_codegen_cranelift Use IntoIterator for array impl everywhere. 2021-12-04 19:40:33 +01:00
rustc_codegen_gcc Implement inline asm! for AVR platform 2021-12-06 01:02:49 -05:00
rustc_codegen_llvm Implement inline asm! for AVR platform 2021-12-06 01:02:49 -05:00
rustc_codegen_ssa LLVM codgen support for unwinding inline assembly 2021-12-03 23:51:49 +01:00
rustc_const_eval Auto merge of #91475 - ecstatic-morse:mir-pass-manager3, r=oli-obk 2021-12-05 03:41:18 +00:00
rustc_data_structures Annotate comments onto the LT algorithm 2021-12-06 20:30:15 -05:00
rustc_driver add rustc option for using LLVM stack smash protection 2021-11-22 20:06:22 +01:00
rustc_error_codes Clarify and tidy up explanation of E0038 2021-11-30 09:25:17 -08:00
rustc_errors Rollup merge of #91394 - Mark-Simulacrum:bump-stage0, r=pietroalbini 2021-12-02 15:52:03 +01:00
rustc_expand Future compatibility warning on cfg_attr on crate_type and crate_name 2021-12-07 11:47:21 -05:00
rustc_feature add unwind_asm feature gate for may_unwind option 2021-12-03 23:51:49 +01:00
rustc_fs_util
rustc_graphviz
rustc_hir Use IntoIterator for array impl everywhere. 2021-12-04 19:40:33 +01:00
rustc_hir_pretty Delete duplicated helpers from HIR printer 2021-12-05 12:45:51 -08:00
rustc_incremental Add -Zassert-incr-state to assert state of incremental cache 2021-11-12 13:41:46 -06:00
rustc_index Auto merge of #90491 - Mark-Simulacrum:push-pred-faster, r=matthewjasper 2021-11-24 15:51:46 +00:00
rustc_infer Rollup merge of #91493 - oli-obk:cleanup, r=michaelwoerister 2021-12-07 11:05:00 +01:00
rustc_interface Stabilize -Z emit-future-incompat as --json future-incompat 2021-12-04 14:34:20 -05:00
rustc_lexer Auto merge of #91393 - Julian-Wollersberger:lexer_optimization, r=petrochenkov 2021-12-03 13:20:14 +00:00
rustc_lint Use let_else in some more places in rustc_lint 2021-12-03 03:51:47 +01:00
rustc_lint_defs Future compatibility warning on cfg_attr on crate_type and crate_name 2021-12-07 11:47:21 -05:00
rustc_llvm Auto merge of #91284 - t6:freebsd-riscv64, r=Amanieu 2021-12-06 03:51:05 +00:00
rustc_macros Rename TypeFolderFallible to FallibleTypeFolder 2021-12-02 16:14:18 +00:00
rustc_metadata Improve suggestion for extern crate self error message 2021-12-01 21:59:54 +00:00
rustc_middle Auto merge of #91279 - scottmcm:small-refactor, r=nagisa 2021-12-06 13:04:18 +00:00
rustc_mir_build Add initial AST and MIR support for unwinding from inline assembly 2021-12-03 23:51:46 +01:00
rustc_mir_dataflow Auto merge of #91475 - ecstatic-morse:mir-pass-manager3, r=oli-obk 2021-12-05 03:41:18 +00:00
rustc_mir_transform Auto merge of #91279 - scottmcm:small-refactor, r=nagisa 2021-12-06 13:04:18 +00:00
rustc_monomorphize
rustc_parse Rollup merge of #90022 - hkmatsumoto:self-upper-as-generic-parameter, r=jackh726 2021-12-05 00:37:56 +01:00
rustc_parse_format
rustc_passes Update invalid crate attributes, add help message 2021-12-03 18:38:32 +00:00
rustc_plugin_impl
rustc_privacy Take a LocalDefId in expect_*item. 2021-11-28 21:09:45 +01:00
rustc_query_impl
rustc_query_system std: Stabilize the thread_local_const_init feature 2021-11-29 07:23:46 -08:00
rustc_resolve Annotate derived spans and move span suggestion code 2021-12-03 18:41:40 +00:00
rustc_save_analysis
rustc_serialize avoid string validation in rustc_serialize, check a marker byte instead 2021-12-06 18:43:01 +01:00
rustc_session Auto merge of #91555 - matthiaskrgr:rollup-pq0iaq7, r=matthiaskrgr 2021-12-05 15:33:44 +00:00
rustc_span Auto merge of #91224 - couchand:2021-11/avr-asm, r=Amanieu 2021-12-07 14:23:01 +00:00
rustc_symbol_mangling
rustc_target Auto merge of #91224 - couchand:2021-11/avr-asm, r=Amanieu 2021-12-07 14:23:01 +00:00
rustc_trait_selection Auto merge of #91555 - matthiaskrgr:rollup-pq0iaq7, r=matthiaskrgr 2021-12-05 15:33:44 +00:00
rustc_traits Reduce boilerplate around infallible folders 2021-12-02 16:14:16 +00:00
rustc_ty_utils Revert "Auto merge of #91354 - fee1-dead:const_env, r=spastorino" 2021-12-03 10:11:21 -03:00
rustc_type_ir
rustc_typeck Rollup merge of #91503 - estebank:call-fn-span, r=michaelwoerister 2021-12-07 11:05:03 +01:00