rust/compiler
Matthias Krüger f605174ea7
Rollup merge of #124778 - fmease:fix-diag-msg-parse-meta-item, r=nnethercote
Fix parse error message for meta items

Addresses https://github.com/rust-lang/rust/issues/122796#issuecomment-2010803906, cc [``@]Thomasdezeeuw.``

For attrs inside of a macro like `#[doc(alias = $ident)]` or `#[cfg(feature = $ident)]` where `$ident` is a macro metavariable of fragment kind `ident`, we used to say the following when expanded (with `$ident` ⟼ `ident`):

```
error: expected unsuffixed literal or identifier, found `ident`
  --> weird.rs:6:19
   |
6  |      #[cfg(feature = $ident)]
   |                      ^^^^^^
...
11 | m!(id);
   | ------ in this macro invocation
   |
   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
```

This was incorrect and caused confusion, justifiably so (see #122796).

In this position, we only accept/expect *unsuffixed literals* which consist of numeric & string literals as well as the boolean literals / the keywords / the reserved identifiers `false` & `true` **but not** arbitrary identifiers.

Furthermore, we used to suggest garbage when encountering unexpected non-identifier tokens:

```
error: expected unsuffixed literal, found `-`
  --> weird.rs:16:17
   |
16 | #[cfg(feature = -1)]
   |                 ^
   |
help: surround the identifier with quotation marks to parse it as a string
   |
16 | #[cfg(feature =" "-1)]
   |                + +
```

Now we no longer do.
2024-05-10 16:10:45 +02:00
..
rustc Change SIGPIPE ui from #[unix_sigpipe = "..."] to -Zon-broken-pipe=... 2024-05-02 19:48:29 +02:00
rustc_abi Use generic NonZero. 2024-05-08 21:37:55 +02:00
rustc_arena rename ptr::invalid -> ptr::without_provenance 2024-02-21 20:15:52 +01:00
rustc_ast Add ErrorGuaranteed to Recovered::Yes and use it more. 2024-05-09 20:12:07 +10:00
rustc_ast_ir Remove extern crate rustc_macros from numerous crates. 2024-04-29 10:21:54 +10:00
rustc_ast_lowering Add ErrorGuaranteed to Recovered::Yes and use it more. 2024-05-09 20:12:07 +10:00
rustc_ast_passes Stabilize exclusive_range 2024-05-02 19:42:31 -04:00
rustc_ast_pretty Rollup merge of #123344 - pietroalbini:pa-unused-imports, r=Nilstrieb 2024-05-08 23:33:24 +02:00
rustc_attr Remove extern crate rustc_macros from numerous crates. 2024-04-29 10:21:54 +10:00
rustc_baked_icu_data
rustc_borrowck Auto merge of #124961 - matthiaskrgr:rollup-1jj65p6, r=matthiaskrgr 2024-05-10 06:50:46 +00:00
rustc_builtin_macros Rollup merge of #124919 - nnethercote:Recovered-Yes-ErrorGuaranteed, r=compiler-errors 2024-05-09 19:09:30 +02:00
rustc_codegen_cranelift debuginfo: Stabilize -Z debug-macros, -Z collapse-macro-debuginfo and #[collapse_debuginfo] 2024-04-25 22:14:47 +03:00
rustc_codegen_gcc Simplify use crate::rustc_foo::bar occurrences. 2024-05-08 16:57:31 +10:00
rustc_codegen_llvm Rename Generics::params to Generics::own_params 2024-05-09 20:58:46 -04:00
rustc_codegen_ssa Rollup merge of #124892 - jfgoog:update-cc, r=workingjubilee 2024-05-08 23:33:27 +02:00
rustc_const_eval interpret/miri: better errors on failing offset_from 2024-05-09 13:09:47 +02:00
rustc_data_structures Remove enum_from_u32. 2024-05-09 09:01:59 +10:00
rustc_driver
rustc_driver_impl compiler: upgrade time from 0.3.34 to 0.3.36 2024-05-04 21:18:41 -07:00
rustc_error_codes Stabilize exclusive_range 2024-05-02 19:42:31 -04:00
rustc_error_messages Rename SubdiagnosticMessage as SubdiagMessage. 2024-03-05 12:14:49 +11:00
rustc_errors Remove some low-value use renamings. 2024-05-03 16:03:12 +10:00
rustc_expand Add ErrorGuaranteed to Recovered::Yes and use it more. 2024-05-09 20:12:07 +10:00
rustc_feature Auto merge of #124747 - MasterAwesome:master, r=davidtwco 2024-05-06 00:55:49 +00:00
rustc_fluent_macro Rename SubdiagnosticMessage as SubdiagMessage. 2024-03-05 12:14:49 +11:00
rustc_fs_util Stabilize std::path::absolute 2024-04-24 14:35:02 +00:00
rustc_graphviz Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
rustc_hir Rollup merge of #124919 - nnethercote:Recovered-Yes-ErrorGuaranteed, r=compiler-errors 2024-05-09 19:09:30 +02:00
rustc_hir_analysis Auto merge of #124961 - matthiaskrgr:rollup-1jj65p6, r=matthiaskrgr 2024-05-10 06:50:46 +00:00
rustc_hir_pretty put hir::AnonConst on the hir arena 2024-04-26 12:57:02 +00:00
rustc_hir_typeck Auto merge of #124961 - matthiaskrgr:rollup-1jj65p6, r=matthiaskrgr 2024-05-10 06:50:46 +00:00
rustc_incremental Auto merge of #123441 - saethlin:fixed-len-file-names, r=oli-obk 2024-05-03 17:41:48 +00:00
rustc_index Simplify static_assert_sizes. 2024-04-18 15:36:25 +10:00
rustc_index_macros rustc_index: Add a ZERO constant to index types 2024-04-03 19:06:22 +03:00
rustc_infer Auto merge of #124961 - matthiaskrgr:rollup-1jj65p6, r=matthiaskrgr 2024-05-10 06:50:46 +00:00
rustc_interface Improve check-cfg CLI errors with more structured diagnostics 2024-05-06 07:44:41 +02:00
rustc_lexer Improved the compiler code with clippy 2024-04-24 09:41:44 +02:00
rustc_lint Rollup merge of #124955 - nnethercote:next_ty_var, r=lcnr 2024-05-10 07:30:22 +02:00
rustc_lint_defs Stabilize exclusive_range 2024-05-02 19:42:31 -04:00
rustc_llvm Update cc crate to v1.0.97 2024-05-08 15:06:35 +00:00
rustc_log Construct SourceMap at the same time as SessionGlobals. 2024-04-16 13:02:53 +10:00
rustc_macros Rollup merge of #124287 - 41Leahcim:master, r=fmease 2024-04-25 18:57:56 +02:00
rustc_metadata Rename Generics::params to Generics::own_params 2024-05-09 20:58:46 -04:00
rustc_middle Auto merge of #124961 - matthiaskrgr:rollup-1jj65p6, r=matthiaskrgr 2024-05-10 06:50:46 +00:00
rustc_mir_build Use fewer origins when creating type variables. 2024-05-10 09:47:46 +10:00
rustc_mir_dataflow Inline & delete Ty::new_unit, since it's just a field access 2024-05-02 17:49:23 +02:00
rustc_mir_transform Rollup merge of #124615 - Zalathar:extracted-mappings, r=davidtwco 2024-05-10 16:10:45 +02:00
rustc_monomorphize Rename Generics::params to Generics::own_params 2024-05-09 20:58:46 -04:00
rustc_next_trait_solver Use super_fold in RegionsToStatic visitor 2024-05-06 12:22:15 -04:00
rustc_parse Rollup merge of #124778 - fmease:fix-diag-msg-parse-meta-item, r=nnethercote 2024-05-10 16:10:45 +02:00
rustc_parse_format Simplify static_assert_sizes. 2024-04-18 15:36:25 +10:00
rustc_passes Fix Error Messages for break Inside Coroutines 2024-05-08 17:32:25 -04:00
rustc_pattern_analysis Stabilize exclusive_range 2024-05-02 19:42:31 -04:00
rustc_privacy Rename Generics::params to Generics::own_params 2024-05-09 20:58:46 -04:00
rustc_query_impl Simplify use crate::rustc_foo::bar occurrences. 2024-05-08 16:57:31 +10:00
rustc_query_system Remove some unneeded Cargo.toml dependencies. 2024-05-03 15:33:52 +10:00
rustc_resolve Rollup merge of #123344 - pietroalbini:pa-unused-imports, r=Nilstrieb 2024-05-08 23:33:24 +02:00
rustc_sanitizers Stabilize the size of incr comp object file names 2024-04-22 10:50:07 -04:00
rustc_serialize Step bootstrap cfgs 2024-05-01 22:19:11 -04:00
rustc_session Add rustfmt cfg to well known cfgs list 2024-05-05 14:30:35 +02:00
rustc_smir Rename Generics::params to Generics::own_params 2024-05-09 20:58:46 -04:00
rustc_span Auto merge of #124747 - MasterAwesome:master, r=davidtwco 2024-05-06 00:55:49 +00:00
rustc_symbol_mangling Auto merge of #123441 - saethlin:fixed-len-file-names, r=oli-obk 2024-05-03 17:41:48 +00:00
rustc_target Rollup merge of #124915 - nnethercote:rustc_target-cleanups, r=bjorn3 2024-05-10 07:30:19 +02:00
rustc_trait_selection Auto merge of #124961 - matthiaskrgr:rollup-1jj65p6, r=matthiaskrgr 2024-05-10 06:50:46 +00:00
rustc_traits Use ObligationCtxt in favor of TraitEngine in many places 2024-05-02 22:03:01 -04:00
rustc_transmute Align: add bytes_usize and bits_usize 2024-05-01 15:57:33 +02:00
rustc_ty_utils Rename Generics::params to Generics::own_params 2024-05-09 20:58:46 -04:00
rustc_type_ir Remove extern crate bitflags from a couple of crates. 2024-04-29 18:47:54 +10:00
stable_mir Use generic NonZero. 2024-05-08 21:37:55 +02:00