Commit Graph

23 Commits

Author SHA1 Message Date
Nicholas Nethercote
226edf64fa Improve an error involving attribute values.
Attribute values must be literals. The error you get when that doesn't
hold is pretty bad, e.g.:
```
unexpected expression: 1 + 1
```
You also get the same error if the attribute value is a literal, but an
invalid literal, e.g.:
```
unexpected expression: "foo"suffix
```

This commit does two things.
- Changes the error message to "attribute value must be a literal",
  which gives a better idea of what the problem is and how to fix it. It
  also no longer prints the invalid expression, because the carets below
  highlight it anyway.
- Separates the "not a literal" case from the "invalid literal" case.
  Which means invalid literals now get the specific error at the literal
  level, rather than at the attribute level.
2023-12-12 15:54:25 +11:00
Nilstrieb
41e8d152dc Show number in error message even for one error
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-24 19:15:52 +01:00
Esteban Küber
27919ceba7 Tweak suggestion spans for invalid crate-level inner attribute
CC #89566.
2023-10-26 18:35:09 +00:00
bors
98b4a64a16 Auto merge of #117126 - matthiaskrgr:rollup-8huie8f, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #117081 (fix typos in comments)
 - #117091 (`OptWithInfcx` naming nits, trait bound simplifications)
 - #117092 (Add regression test for #117058)
 - #117093 (Update books)
 - #117105 (remove change-id assertion in bootstrap test)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-24 17:28:45 +00:00
Matthew Jasper
712106b122 Add regression test for #117058 2023-10-24 08:21:52 +00:00
David Tolnay
6a02e20fb5
Update since stability attributes in tests 2023-10-23 13:04:47 -07:00
Gurinder Singh
19574d216a Return ident for ExprField and PatField HIR nodes 2023-09-01 06:36:02 +05:30
Arthur Cohen
bdf4e3de9c check_attrs: Warn when #[macro_export] is used on macros 2.0
The compiler should emit a more specific error when the `#[macro_export]`
attribute is present on a decl macro, instead of silently ignoring it.

This commit adds the required error message in rustc_passes/messages.ftl,
 as well as a note. A new variant is added to the `errors::MacroExport`
enum, specifically for the case where the attribute is added to a macro
2.0.
2023-08-07 21:14:28 +02:00
Lukas Markeffsky
637ea3f746 validate doc(masked) 2023-07-24 18:04:35 +02:00
许杰友 Jieyou Xu (Joe)
08c77a6eb4
Add infrastructure #[rustc_confusables] attribute to allow targeted
"no method" errors on standard library types

The standard library developer can annotate methods on e.g.
`BTreeSet::push` with `#[rustc_confusables("insert")]`. When the user
mistypes `btreeset.push()`, `BTreeSet::insert` will be suggested if
there are no other candidates to suggest.
2023-07-16 19:22:03 +08:00
Obei Sideg
70bbcceaec Add test for #![doc(test(...)] with literal parameter 2023-05-29 22:33:46 +03:00
Michael Goulet
183c7904e9 Add invalid_macro_export_arguments to built-in macro list 2023-04-27 18:33:39 +00:00
clubby789
6a41cfe095 Migrate rustc_passes to translatable diagnostics 2023-04-26 11:40:21 +01:00
Deadbeef
84de04155c add test for invalid places of repr align 2023-04-17 12:42:02 +00:00
Pietro Albini
703ba0ce26
fix ignore-thumbv8m.base 2023-04-03 09:24:07 +02:00
Camille GILLOT
3102722ef4 Skip no_mangle if the item has no name. 2023-03-28 18:05:12 +00:00
clubby789
d845769557 Restrict #[rustc_box] to Box::new calls 2023-03-02 02:42:19 +00:00
blyxyas
e39fe374df Add check for invalid \#[macro_export]\ arguments 2023-02-22 21:53:16 +00:00
Oli Scherer
f95b553eb4 Replace a command line flag with an env var to allow tools to initialize the tracing loggers at their own discretion 2023-02-07 16:33:03 +00:00
bors
3e97763872 Auto merge of #106745 - m-ou-se:format-args-ast, r=oli-obk
Move format_args!() into AST (and expand it during AST lowering)

Implements https://github.com/rust-lang/compiler-team/issues/541

This moves FormatArgs from rustc_builtin_macros to rustc_ast_lowering. For now, the end result is the same. But this allows for future changes to do smarter things with format_args!(). It also allows Clippy to directly access the ast::FormatArgs, making things a lot easier.

This change turns the format args types into lang items. The builtin macro used to refer to them by their path. After this change, the path is no longer relevant, making it easier to make changes in `core`.

This updates clippy to use the new language items, but this doesn't yet make clippy use the ast::FormatArgs structure that's now available. That should be done after this is merged.
2023-01-26 12:44:47 +00:00
Mara Bos
525b0bb77a Bless tests. 2023-01-12 00:25:46 +01:00
Yuki Omoto
4e2a3567bc Add log-backtrace option to show backtraces along with logging 2023-01-12 00:17:48 +09:00
Albert Larsan
cf2dff2b1e
Move /src/test to /tests 2023-01-11 09:32:08 +00:00