rust/compiler
Matthias Krüger 84c28041b4
Rollup merge of #93753 - jeremyBanks:main-conflict, r=petrochenkov
Complete removal of #[main] attribute from compiler

resolves #93786

---

The `#[main]` attribute was mostly removed from the language in #84217, but not completely. It is still recognized as a builtin attribute by the compiler, but it has no effect. However, this no-op attribute is no longer gated by `#[feature(main)]` (which no longer exists), so it's possible to include it in code *on stable* without any errors, which seems unintentional. For example, the following code is accepted ([playground link](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&code=%23%5Bmain%5D%0Afn%20main()%20%7B%0A%20%20%20%20println!(%22hello%20world%22)%3B%0A%7D%0A)).

```rust
#[main]
fn main() {
    println!("hello world");
}
```

Aside from that oddity, the existence of this attribute causes code like the following to fail ([playground link](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&code=use%20tokio%3A%3Amain%3B%0A%0A%23%5Bmain%5D%0Afn%20main()%20%7B%0A%20%20%20%20println!(%22hello%20world%22)%3B%0A%7D%0A)). According https://github.com/rust-lang/rust/pull/84062#issuecomment-825038275, the removal of `#[main]` was expected to eliminate this conflict (previously reported as #62127).

```rust
use tokio::main;

#[main]
fn main() {
    println!("hello world");
}
```

```
error[E0659]: `main` is ambiguous
 --> src/main.rs:3:3
  |
3 | #[main]
  |   ^^^^ ambiguous name
  |
  = note: ambiguous because of a name conflict with a builtin attribute
  = note: `main` could refer to a built-in attribute
```

[This error message can be confusing](https://stackoverflow.com/q/71024443/1114), as the mostly-removed `#[main]` attribute is not mentioned in any documentation.

Since the current availability of `#[main]` on stable seems unintentional, and to needlessly block use of the `main` identifier in the attribute namespace, this PR finishes removing the `#[main]` attribute as described in https://github.com/rust-lang/rust/issues/29634#issuecomment-274951753 by deleting it from `builtin_attrs.rs`, and adds two test cases to ensure that the attribute is no longer accepted and no longer conflicts with other attributes imported as `main`.
2022-02-09 23:29:57 +01:00
..
rustc remove unused jemallocator crate 2022-01-28 16:56:05 +01:00
rustc_apfloat Stabilize iter::zip. 2021-12-14 18:50:31 -04:00
rustc_arena Remove unused dep from rustc_arena 2022-02-02 17:37:14 +01:00
rustc_ast Add test for block doc comments horizontal trim 2022-02-07 17:07:53 +01:00
rustc_ast_lowering Rollup merge of #93746 - cjgillot:nodefii, r=nikomatsakis 2022-02-09 14:12:22 +09:00
rustc_ast_passes Auto merge of #93561 - Amanieu:more-unwind-abi, r=nagisa 2022-02-08 03:20:05 +00:00
rustc_ast_pretty Change struct expr pretty printing to match rustfmt style 2022-02-03 10:59:35 -08:00
rustc_attr More let_else adoptions 2022-02-02 17:11:01 +01:00
rustc_borrowck Improve opaque type higher-ranked region error message under NLL 2022-02-08 12:35:42 -05:00
rustc_builtin_macros Rollup merge of #91950 - estebank:point-at-type-of-non-allocator, r=matthewjasper 2022-02-08 16:40:45 +01:00
rustc_codegen_cranelift Use an indexmap to avoid sorting LocalDefIds 2022-01-22 22:34:16 -06:00
rustc_codegen_gcc #[used(linker)] attribute (https://github.com/dtolnay/linkme/issues/41) 2022-02-06 20:23:23 +01:00
rustc_codegen_llvm Rollup merge of #93503 - michaelwoerister:fix-vtable-holder-debuginfo-regression, r=wesleywiser 2022-02-09 23:29:56 +01:00
rustc_codegen_ssa Rollup merge of #93503 - michaelwoerister:fix-vtable-holder-debuginfo-regression, r=wesleywiser 2022-02-09 23:29:56 +01:00
rustc_const_eval Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakis 2022-02-07 23:40:26 +00:00
rustc_data_structures Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakis 2022-02-07 23:40:26 +00:00
rustc_driver Store rlink data in opaque binary format on disk 2022-02-05 15:17:54 -05:00
rustc_error_codes Rollup merge of #91939 - GKFX:feature-91866, r=cjgillot 2022-02-06 04:13:29 +01:00
rustc_errors add a rustc::query_stability lint 2022-02-01 10:15:59 +01:00
rustc_expand add a rustc::query_stability lint 2022-02-01 10:15:59 +01:00
rustc_feature Rollup merge of #93753 - jeremyBanks:main-conflict, r=petrochenkov 2022-02-09 23:29:57 +01:00
rustc_fs_util
rustc_graphviz eplace usages of vec![].into_iter with [].into_iter 2022-01-09 14:09:25 +11:00
rustc_hir Rollup merge of #93746 - cjgillot:nodefii, r=nikomatsakis 2022-02-09 14:12:22 +09:00
rustc_hir_pretty Rollup merge of #93746 - cjgillot:nodefii, r=nikomatsakis 2022-02-09 14:12:22 +09:00
rustc_incremental add a rustc::query_stability lint 2022-02-01 10:15:59 +01:00
rustc_index implement lint for suspicious auto trait impls 2022-02-01 09:55:19 +01:00
rustc_infer Auto merge of #92306 - Aaron1011:opaque-type-op, r=oli-obk 2022-02-09 09:41:48 +00:00
rustc_interface Auto merge of #93724 - Mark-Simulacrum:drop-query-stats, r=michaelwoerister 2022-02-09 15:53:10 +00:00
rustc_lexer
rustc_lint Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakis 2022-02-07 23:40:26 +00:00
rustc_lint_defs implement lint for suspicious auto trait impls 2022-02-01 09:55:19 +01:00
rustc_llvm Windows: Disable LLVM crash dialog boxes. 2022-01-27 16:53:17 -08:00
rustc_log Make rustc_log doc test runnable 2022-01-03 22:31:56 -08:00
rustc_macros Make Decodable and Decoder infallible. 2022-01-22 10:38:31 +11:00
rustc_metadata Auto merge of #93561 - Amanieu:more-unwind-abi, r=nagisa 2022-02-08 03:20:05 +00:00
rustc_middle Rollup merge of #91504 - cynecx:used_retain, r=nikic 2022-02-09 23:29:56 +01:00
rustc_mir_build Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakis 2022-02-07 23:40:26 +00:00
rustc_mir_dataflow rustc_mir_dataflow: use iter::once instead of Some().into_iter 2022-02-03 13:52:26 -07:00
rustc_mir_transform Rollup merge of #90132 - joshtriplett:stabilize-instrument-coverage, r=wesleywiser 2022-02-04 18:42:13 +01:00
rustc_monomorphize add a rustc::query_stability lint 2022-02-01 10:15:59 +01:00
rustc_parse clippy::perf fixes 2022-02-03 21:45:51 +01:00
rustc_parse_format
rustc_passes Rollup merge of #91504 - cynecx:used_retain, r=nikic 2022-02-09 23:29:56 +01:00
rustc_plugin_impl
rustc_privacy add a rustc::query_stability lint 2022-02-01 10:15:59 +01:00
rustc_query_impl Auto merge of #93741 - Mark-Simulacrum:global-job-id, r=cjgillot 2022-02-09 18:54:30 +00:00
rustc_query_system Auto merge of #93741 - Mark-Simulacrum:global-job-id, r=cjgillot 2022-02-09 18:54:30 +00:00
rustc_resolve resolve lifetimes for const generic defaults 2022-02-05 01:30:14 -08:00
rustc_save_analysis More let_else adoptions 2022-02-02 17:11:01 +01:00
rustc_serialize Drop json::from_reader 2022-02-05 15:07:10 -05:00
rustc_session Auto merge of #93724 - Mark-Simulacrum:drop-query-stats, r=michaelwoerister 2022-02-09 15:53:10 +00:00
rustc_span Rollup merge of #91504 - cynecx:used_retain, r=nikic 2022-02-09 23:29:56 +01:00
rustc_symbol_mangling add a rustc::query_stability lint 2022-02-01 10:15:59 +01:00
rustc_target Auto merge of #93561 - Amanieu:more-unwind-abi, r=nagisa 2022-02-08 03:20:05 +00:00
rustc_trait_selection Allow substitutions in rustc_on_unimplemented predicate 2022-02-09 09:35:42 -08:00
rustc_traits Lazily resolve type-alias-impl-trait defining uses 2022-02-02 15:40:11 +00:00
rustc_ty_utils remove TyS::same_type 2022-02-01 11:21:26 +01:00
rustc_type_ir Remove some unused arguments and update a comment 2022-02-02 15:40:12 +00:00
rustc_typeck Rollup merge of #91504 - cynecx:used_retain, r=nikic 2022-02-09 23:29:56 +01:00