rust/compiler
bors 58d2bad9f7 Auto merge of #78837 - petrochenkov:keyvalexpr, r=davidtwco
Accept arbitrary expressions in key-value attributes at parse time

Continuation of https://github.com/rust-lang/rust/pull/77271.

We now support arbitrary expressions in values of key-value attributes at parse time.
```
#[my_attr = EXPR]
```
Previously only unsuffixed literals and interpolated expressions (`$expr`) were accepted.

There are two immediate motivational cases for this:
- External doc strings (`#[doc = include_str!("my_doc.md")]`, eliminating the need in https://github.com/rust-lang/rust/issues/44732) and expanding macros in this position in general. Currently such macro expansions are supported in this position in interpolated `$expr`s (the `#[doc = $doc]` idiom).
- Paths (`#[namespace = foo::bar] extern "C++" { ... }`) like proposed in https://github.com/rust-lang/rust/pull/76734.

If the attribute in question survives expansion, then the value is still restricted to unsuffixed literals by a semantic check.
This restriction doesn't prevent the use cases listed above, so this PR keeps it in place for now.

Closes https://github.com/rust-lang/rust/issues/52607.
Previous attempt - https://github.com/rust-lang/rust/pull/67121.
Some more detailed write up on internals - https://internals.rust-lang.org/t/macro-expansion-points-in-attributes/11455.
Tracking issue - https://github.com/rust-lang/rust/issues/78835.
2020-12-10 00:42:22 +00:00
..
rustc
rustc_apfloat
rustc_arena Use specialization to avoid copying 2020-11-20 21:02:09 +01:00
rustc_ast Accept arbitrary expressions in key-value attributes at parse time 2020-12-09 21:37:32 +03:00
rustc_ast_lowering Retain assembly operands span when lowering AST to HIR 2020-12-06 20:48:08 +01:00
rustc_ast_passes Accept arbitrary expressions in key-value attributes at parse time 2020-12-09 21:37:32 +03:00
rustc_ast_pretty Rollup merge of #79016 - fanzier:underscore-expressions, r=petrochenkov 2020-11-15 13:39:48 +01:00
rustc_attr Created NestedMetaItem::name_value_literal_span method 2020-12-01 16:26:51 +01:00
rustc_builtin_macros Properly handle attributes on statements 2020-11-26 17:08:35 -05:00
rustc_codegen_cranelift Auto merge of #77611 - oli-obk:atomic_miri_leakage, r=nagisa 2020-12-09 19:53:23 +00:00
rustc_codegen_llvm Fixes to Rust coverage 2020-12-07 17:56:19 -08:00
rustc_codegen_ssa Auto merge of #77611 - oli-obk:atomic_miri_leakage, r=nagisa 2020-12-09 19:53:23 +00:00
rustc_data_structures Rename optin_builtin_traits to auto_traits 2020-11-23 14:14:06 -08:00
rustc_driver Fix unknown-crate when using self-profile with rustdoc 2020-12-01 12:54:03 -05:00
rustc_error_codes smarter E0390 2020-12-06 20:30:07 +00:00
rustc_errors Rollup merge of #74293 - GuillaumeGomez:rustdoc-test-compiler-output-color, r=jyn514 2020-11-17 16:13:46 +01:00
rustc_expand Rollup merge of #79678 - jyn514:THE-PAPERCLIP-COMETH, r=varkor 2020-12-04 03:30:39 +01:00
rustc_feature Accept arbitrary expressions in key-value attributes at parse time 2020-12-09 21:37:32 +03:00
rustc_fs_util
rustc_graphviz
rustc_hir Retain assembly operands span when lowering AST to HIR 2020-12-06 20:48:08 +01:00
rustc_hir_pretty Retain assembly operands span when lowering AST to HIR 2020-12-06 20:48:08 +01:00
rustc_incremental Auto merge of #74967 - Aaron1011:feature/incr-def-path-table, r=pnkfelix 2020-12-01 14:30:02 +00:00
rustc_index Stabilise then 2020-11-22 13:45:14 +00:00
rustc_infer simplify if let Some(_) = x to if x.is_some() (clippy::redundant_pattern_matching) 2020-12-08 20:27:49 +01:00
rustc_interface Auto merge of #79586 - jyn514:crate-name, r=davidtwco 2020-12-03 12:14:29 +00:00
rustc_lexer Fix some clippy lints 2020-12-03 17:08:19 -05:00
rustc_lint don't create owned values for comparison (clippy::cmp_owned) 2020-12-08 20:27:48 +01:00
rustc_lint_defs Validate naked functions definitions 2020-12-07 00:00:00 +00:00
rustc_llvm Auto merge of #78684 - devsnek:inline-asm-wasm, r=Amanieu 2020-12-01 20:23:06 +00:00
rustc_macros Only create OnDiskCache in incremental compilation mode 2020-11-19 15:50:55 -05:00
rustc_metadata Account for gaps in def path table during decoding 2020-12-08 13:02:53 -05:00
rustc_middle Auto merge of #79721 - Aaron1011:fix/reuse-def-path-hash, r=wesleywiser 2020-12-09 13:54:07 +00:00
rustc_mir Rollup merge of #79818 - richkadel:llvm-coverage-counters-2.1.0, r=tmandry 2020-12-09 13:38:27 -08:00
rustc_mir_build Also generate StorageDead in constants 2020-12-09 10:59:10 +00:00
rustc_parse Accept arbitrary expressions in key-value attributes at parse time 2020-12-09 21:37:32 +03:00
rustc_parse_format
rustc_passes Rollup merge of #79844 - tmiasko:rwu-table-mod, r=lcnr 2020-12-09 13:38:34 -08:00
rustc_plugin_impl Store ForeignItem in a side table. 2020-11-26 21:29:27 +01:00
rustc_privacy Remove ForeignMod struct. 2020-11-26 21:32:27 +01:00
rustc_query_system Properly re-use def path hash in incremental mode 2020-12-04 22:16:40 -05:00
rustc_resolve Tweak diagnostics on shadowing lifetimes/labels 2020-12-02 11:39:42 +09:00
rustc_save_analysis Remove ForeignMod struct. 2020-11-26 21:32:27 +01:00
rustc_serialize Fix some clippy lints 2020-12-03 17:08:19 -05:00
rustc_session Combination of commits 2020-12-03 09:50:10 -08:00
rustc_span Accept arbitrary expressions in key-value attributes at parse time 2020-12-09 21:37:32 +03:00
rustc_symbol_mangling Store ForeignItem in a side table. 2020-11-26 21:29:27 +01:00
rustc_target Auto merge of #78684 - devsnek:inline-asm-wasm, r=Amanieu 2020-12-01 20:23:06 +00:00
rustc_trait_selection remove redundant clones 2020-12-05 12:59:54 +01:00
rustc_traits Don't run resolve_vars_if_possible in normalize_erasing_regions 2020-11-18 12:25:36 -05:00
rustc_ty_utils Be cautious of calling upvar_tys before mir 2020-11-29 19:20:28 -05:00
rustc_typeck Rollup merge of #79824 - LingMan:no_replace, r=lcnr 2020-12-09 13:38:31 -08:00