about summary refs log tree commit diff
path: root/compiler/rustc_macros/src
AgeCommit message (Collapse)AuthorLines
2022-09-09Simplify the implementation of `rustc_queries`Joshua Nelson-35/+18
2022-09-09Make the `storage` query modifier less generalJoshua Nelson-12/+8
In practice, it was only ever used with `ArenaCacheSelector`. Change it to a single boolean `arena_cache` rather than allowing queries to specify an arbitrary type.
2022-09-06Get rid of the emitted `rustc_query_names` and `rustc_cached_queries` macroJoshua Nelson-22/+7
We can avoid these by adding slightly more information to `rustc_query_append` instead.
2022-09-06Support doc-comments in `define_dep_nodes`Joshua Nelson-2/+6
2022-09-06Further simplify the macros generated by `rustc_queries`Joshua Nelson-13/+9
- Add a new `rustc_query_names` macro. This allows a much simpler syntax for the matchers in the macros passed to it as a callback. - Convert `define_dep_nodes` and `alloc_once` to use `rustc_query_names`. This is possible because they only use the names (despite the quite complicated matchers in `define_dep_nodes`, none of the other arguments are used). - Get rid of `rustc_dep_node_append`.
2022-09-05UPDATE - into_diagnostic to take a Handler instead of a ParseSessJhonny Bill Mena-1/+1
Suggested by the team in this Zulip Topic https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20SessionDiagnostic.20on.20Handler Handler already has almost all the capabilities of ParseSess when it comes to diagnostic emission, in this migration we only needed to add the ability to access source_map from the emitter in order to get a Snippet and the start_point. Not sure if this is the best way to address this gap
2022-09-01Allow deriving multiple subdiagnostics using one SessionSubdiagnosticXiretza-96/+120
This reimplements ac638c1, which had to be reverted in the previous commit because it contains a rebase accident that itself reverted significant unrelated changes to SessionSubdiagnostic.
2022-09-01Revert parts of "use derive proc macro to impl SessionDiagnostic"Xiretza-249/+445
This reverts parts of commit ac638c1f5fca36484506415319ab254ad522a692. During rebase, this commit accidentally reverted unrelated changes to the subdiagnostic derive (those allowing multipart_suggestions to be derived). This commit reverts all changes to the subdiagnostic code made in ac638c1f5fc, the next commit will reintroduce the actually intended changes.
2022-08-31Rollup merge of #101165 - ldm0:drain_to_iter, r=cjgillotMatthias Krüger-1/+1
Use more `into_iter` rather than `drain(..)` Clearer semantic.
2022-08-31use derive proc macro to impl SessionDiagnosticYuanheng Li-445/+249
fixes `SessionSubdiagnostic` to accept multiple attributes emitting list of fluent message remains unresolved
2022-08-30Rework SessionSubdiagnostic derive to support multipart_suggestionXiretza-219/+394
2022-08-30SessionSubdiagnostic: make `#[applicability]` optionalXiretza-8/+4
2022-08-30Use span_suggestion_with_style in SessionSubdiagnostic deriveXiretza-39/+65
2022-08-30Use more `into_iter` rather than `drain(..)`Donough Liu-1/+1
2022-08-29Rollup merge of #100959 - ↵Matthias Krüger-19/+22
LuisCardosoOliveira:translation-rename-attr-warning, r=davidtwco translations: rename warn_ to warning ## Description This MR renames the the macro `warn_` to `warning`. To give a little bit of context, as [explained](https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20diag.20translation/near/295074146) by ```````@davidtwco``````` in the Zulip channel, `warn_` was named like that because the keyword `warn` is a built-in attribute and at the time this macro was created the word `warning` was also taken. However, it is no longer the case and we can rename `warn_` to `warning`.
2022-08-27Auto merge of #100946 - jyn514:query-system-3, r=cjgillotbors-11/+11
Simplify the arguments to macros generated by the `rustc_queries` proc macro Very small cleanup. Based on https://github.com/rust-lang/rust/pull/100436 which modifies some of the same code. r? `@cjgillot`
2022-08-25Auto merge of #100748 - SparrowLii:query_depth, r=cjgillotbors-1/+12
add `depth_limit` in `QueryVTable` to avoid entering a new tcx in `layout_of` Fixes #49735 Updates #48685 The `layout_of` query needs to check whether it overflows the depth limit, and the current implementation needs to create a new `ImplicitCtxt` inside `layout_of`. However, `start_query` will already create a new `ImplicitCtxt`, so we can check the depth limit in `start_query`. We can tell whether we need to check the depth limit simply by whether the return value of `to_debug_str` of the query is `layout_of`. But I think adding the `depth_limit` field in `QueryVTable` may be more elegant and more scalable.
2022-08-25Auto merge of #100436 - jyn514:macro-query-system, r=cjgillotbors-3/+1
try and simplify some things in the query system
2022-08-24translations: rename warn_ to warningLuis Cardoso-19/+22
The macro warn_ was named like that because it the keyword warn is a built-in attribute and at the time this macro was created the word 'warning' was also taken. However it is no longer the case and we can rename warn_ to warning.
2022-08-24Auto merge of #100803 - klensy:do-not-encode-preinterned-symbols, r=bjorn3bors-1/+1
Symbols: do not write string values of preinterned symbols into compiled artifacts r? `@bjorn3` Followup for #98851 https://github.com/rust-lang/rust/pull/98851#issuecomment-1215606291
2022-08-24Remove the `$tcx:tt` parameter from `rustc_query_description`Joshua Nelson-5/+5
It's unnecessary.
2022-08-24Simplify the syntax for macros generated by `rustc_queries`Joshua Nelson-6/+6
- Disallow multiple macros callbacks in the same invocation. In practice, this was never used. - Remove the `[]` brackets around the macro name - Require an `ident`, not an arbitrary `tt`
2022-08-23Remove `$tcx` metavariable from `rustc_query_append`Joshua Nelson-3/+1
It's not actually necessary and it makes the code harder to read.
2022-08-24add `depth_limit` in `QueryVTable`SparrowLii-1/+12
2022-08-23Auto merge of #100675 - Xiretza:fluent-mandate-crate-prefix, r=davidtwcobors-9/+21
fluent: mandate slug names to be prefixed by crate name This is currently only convention, but not actively checked for. Additionally, improve error messages to highlight the path of the offending fluent file rather than the identifier preceding it. This will conflict with #100671, so I'll leave it as draft until that's merged.
2022-08-23Rollup merge of #100857 - camsteffen:query-parse-refactor, r=davidtwcoDylan DPC-260/+125
Refactor query modifier parsing Reduce redundancy and improve error spans.
2022-08-22fluent: point to path containing error instead of module nameXiretza-5/+5
Example error before: error: name `generic_does_not_live_long_enough` does not start with the crate name --> compiler/rustc_error_messages/src/lib.rs:33:17 | 33 | borrowck => "../locales/en-US/borrowck.ftl", | ^^^^^^^^ | = help: prepend `borrowck_` to the slug name: `borrowck_generic_does_not_live_long_enough` after: error: name `generic_does_not_live_long_enough` does not start with the crate name --> compiler/rustc_error_messages/src/lib.rs:33:17 | 33 | borrowck => "../locales/en-US/borrowck.ftl", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: prepend `borrowck_` to the slug name: `borrowck_generic_does_not_live_long_enough`
2022-08-22fluent: mandate slug names to be prefixed by crate nameXiretza-5/+17
2022-08-21Refactor query modifier parsingCameron Steffen-260/+125
2022-08-22Fix `build_format` not unescaping braces properlyfinalchild-27/+32
Co-authored-by: RanolP <public.ranolp@gmail.com>
2022-08-21Replace #[lint/warning/error] with #[diag]Xiretza-23/+6
2022-08-21Disallow #[primary_span] on LintDiagnosticsXiretza-4/+13
2022-08-21Make derived SessionDiagnostics generic on diagnostic levelXiretza-105/+60
Deriving SessionDiagnostic on a type no longer forces that diagnostic to be one of warning, error, or fatal. The level is instead decided when the struct is passed to the respective Handler::emit_*() method.
2022-08-20symbols: add `is_preinterned` fn to check if symbol was preinterned in compilerklensy-1/+1
2022-08-18Add diagnostic translation lints to crates that don't emit them5225225-0/+2
2022-08-12Change fluent_messages macro to expect _ slugs instead of - slugsest31-5/+27
For the most part, the macro actually worked with _ slugs, but the prefix_something -> prefix::something conversion was not implemented. We don't want to accept - slugs for consistency reasons. We thus error if a name is found with - inside. This ensures a consistent style.
2022-08-12Update rustdoc to new slug styleest31-13/+13
2022-07-20clippy::perf fixesMatthias Krüger-4/+4
2022-07-15macros: support adding warnings to diagsDavid Wood-22/+48
Both diagnostic and subdiagnostic derives were missing the ability to add warnings to diagnostics - this is made more difficult by the `warn` attribute already existing, so this name being unavailable for the derives to use. `#[warn_]` is used instead, which requires special-casing so that `{span_,}warn` is called instead of `{span_,}warn_`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-15macros: support `MultiSpan` in diag derivesDavid Wood-59/+88
Add support for `MultiSpan` with any of the attributes that work on a `Span` - requires that diagnostic logic generated for these attributes are emitted in the by-move block rather than the by-ref block that they would normally have been generated in. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-08Use dashes instead of underscores in fluent namesMichael Goulet-2/+6
2022-07-06Rollup merge of #98884 - davidtwco:translation-on-lints-derive, r=oli-obkDylan DPC-628/+812
macros: `LintDiagnostic` derive - Move `LintDiagnosticBuilder` into `rustc_errors` so that a diagnostic derive can refer to it. - Introduce a `DecorateLint` trait, which is equivalent to `SessionDiagnostic` or `AddToDiagnostic` but for lints. Necessary without making more changes to the lint infrastructure as `DecorateLint` takes a `LintDiagnosticBuilder` and re-uses all of the existing logic for determining what type of diagnostic a lint should be emitted as (e.g. error/warning). - Various refactorings of the diagnostic derive machinery (extracting `build_field_mapping` helper and moving `sess` field out of the `DiagnosticDeriveBuilder`). - Introduce a `LintDiagnostic` derive macro that works almost exactly like the `SessionDiagnostic` derive macro except that it derives a `DecorateLint` implementation instead. A new derive is necessary for this because `SessionDiagnostic` is intended for when the generated code creates the diagnostic. `AddToDiagnostic` could have been used but it would have required more changes to the lint machinery. ~~At time of opening this pull request, ignore all of the commits from #98624, it's just the last few commits that are new.~~ r? `@oli-obk`
2022-07-05Add #[derive(TypeVisitable)]Alan Egerton-13/+35
2022-07-05macros: add diagnostic derive for lintsDavid Wood-603/+787
`SessionDiagnostic` isn't suitable for use on lints as whether or not it creates an error or a warning is decided at compile-time by the macro, whereas lints decide this at runtime based on the location of the lint being reported (as it will depend on the user's `allow`/`deny` attributes, etc). Re-using most of the machinery for `SessionDiagnostic`, this macro introduces a `LintDiagnostic` derive which implements a `DecorateLint` trait, taking a `LintDiagnosticBuilder` and adding to the lint according to the diagnostic struct.
2022-07-05macros: move `sess` out of builderDavid Wood-6/+4
`sess` field of `SessionDiagnosticDeriveBuilder` is never actually used in the builder's member functions, so it doesn't need to be a field. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-05macros: introduce `build_field_mapping`David Wood-20/+22
Move the logic for building a field mapping (which is used by the building of format strings in `suggestion` annotations) into a helper function. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-05macros: fix documentation link for diag deriveDavid Wood-1/+1
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-24macros: use typed identifiers in subdiag deriveDavid Wood-15/+75
As in the diagnostic derive, using typed identifiers in the subdiagnostic derive improves the diagnostics of using the subdiagnostic derive as Fluent messages will be confirmed to exist at compile-time. Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-24macros: use typed identifiers in diag deriveDavid Wood-192/+320
Using typed identifiers instead of strings with the Fluent identifier enables the diagnostic derive to benefit from the compile-time validation that comes with typed identifiers - use of a non-existent Fluent identifier will not compile. Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-08Auto merge of #94732 - nnethercote:infallible-encoder, r=bjorn3bors-17/+9
Make `Encodable` and `Encoder` infallible. A follow-up to #93066. r? `@ghost`