summary refs log tree commit diff
path: root/compiler/rustc_session/src/parse.rs
AgeCommit message (Collapse)AuthorLines
2023-05-16Avoid `&format("...")` calls in error message code.Nicholas Nethercote-2/+2
Error message all end up passing into a function as an `impl Into<{D,Subd}iagnosticMessage>`. If an error message is creatd as `&format("...")` that means we allocate a string (in the `format!` call), then take a reference, and then clone (allocating again) the reference to produce the `{D,Subd}iagnosticMessage`, which is silly. This commit removes the leading `&` from a lot of these cases. This means the original `String` is moved into the `{D,Subd}iagnosticMessage`, avoiding the double allocations. This requires changing some function argument types from `&str` to `String` (when all arguments are `String`) or `impl Into<{D,Subd}iagnosticMessage>` (when some arguments are `String` and some are `&str`).
2023-05-01remove type_ascription_path_suggestions in parseryukang-3/+0
2023-04-09Fix some clippy::complexityNilstrieb-9/+10
2023-04-04Use new iteration helpers instead of manually rolling themOli Scherer-4/+1
2023-04-04Replace another lock with an append-only vecOli Scherer-2/+2
2023-04-04Remove a lock in favor of an AppendOnlyVecOli Scherer-7/+10
2023-04-04Replace a lock with an atomicOli Scherer-3/+3
2023-02-22various: translation resources from cg backendDavid Wood-5/+2
Extend `CodegenBackend` trait with a function returning the translation resources from the codegen backend, which can be added to the complete list of resources provided to the emitter. Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-22errors: generate typed identifiers in each crateDavid Wood-3/+6
Instead of loading the Fluent resources for every crate in `rustc_error_messages`, each crate generates typed identifiers for its own diagnostics and creates a static which are pulled together in the `rustc_driver` crate and provided to the diagnostic emitter. Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-16Add feature gate for non_lifetime_bindersMichael Goulet-3/+3
2022-12-20rustc: Remove needless lifetimesJeremy Stucki-6/+6
2022-10-31Add more track_callermejrs-0/+6
2022-10-07errors: add `emit_note`/`create_note`David Wood-1/+12
Add `Noted` marker struct that implements `EmissionGuarantee` so that `emit_note` and `create_note` can be implemented for struct diagnostics. Signed-off-by: David Wood <david.wood@huawei.com>
2022-09-30Remove expr_parentheses_needed from ParseSessMichael Goulet-11/+3
2022-09-28Auto merge of #101619 - Xiretza:rustc_parse-session-diagnostics, r=davidtwcobors-7/+5
Migrate more of rustc_parse to SessionDiagnostic Still far from complete, but I thought I'd add a checkpoint here because rebasing was starting to get annoying.
2022-09-27Migrate rustc_session::expr_parentheses_needed to Subdiagnostic structXiretza-7/+5
2022-09-27session: remove now-unnecessary lint `#[allow]`sDavid Wood-8/+0
In #101230, the internal diagnostic migration lints - `diagnostic_outside_of_impl` and `untranslatable_diagnostic` - were modified so that they wouldn't trigger on functions annotated with `#[rustc_lint_diagnostics]`. However, this change has to make it into the bootstrap compiler before the `#[allow]` annotations that it aims to remove can be removed, which is possible now that #102051 has landed. Signed-off-by: David Wood <david.wood@huawei.com>
2022-09-21FIX - adopt new Diagnostic naming in newly migrated modulesJhonny Bill Mena-2/+2
FIX - ambiguous Diagnostic link in docs UPDATE - rename diagnostic_items to IntoDiagnostic and AddToDiagnostic [Gardening] FIX - formatting via `x fmt` FIX - rebase conflicts. NOTE: Confirm wheather or not we want to handle TargetDataLayoutErrorsWrapper this way DELETE - unneeded allow attributes in Handler method FIX - broken test FIX - Rebase conflict UPDATE - rename residual _SessionDiagnostic and fix LintDiag link
2022-09-21UPDATE - rename DiagnosticHandler trait to IntoDiagnosticJhonny Bill Mena-8/+8
2022-09-21UPDATE - move SessionDiagnostic from rustc_session to rustc_errorsJhonny Bill Mena-2/+1
2022-09-14make `mk_attr_id` part of `ParseSess`SparrowLii-0/+4
2022-09-05UPDATE - into_diagnostic to take a Handler instead of a ParseSessJhonny Bill Mena-3/+3
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-02Make CrateConfig make order depended for linting purposeUrgau-3/+3
2022-08-26translations(rustc_session): migrate 80% of the file parse.rsLuis Cardoso-6/+15
This commit migrates around 80% of the parse file to use SsessionDiagnostic We still have to migrate struct_err and struct_warn.
2022-08-22Support #[fatal(..)]finalchild-0/+16
2022-08-21Add Handler::struct_diagnostic()Xiretza-1/+9
This unifies the struct_{warn,error,fatal}() methods in one generic method.
2022-08-17Reenable early feature-gates as future-compat warningsChristopher Durham-3/+52
2022-07-01update cfg(bootstrap)sPietro Albini-2/+2
2022-06-10lint: add diagnostic translation migration lintsDavid Wood-0/+2
Introduce allow-by-default lints for checking whether diagnostics are written in `SessionDiagnostic`/`AddSubdiagnostic` impls and whether diagnostics are translatable. These lints can be denied for modules once they are fully migrated to impls and translation. Signed-off-by: David Wood <david.wood@huawei.com>
2022-05-06sess: add `create_{err,warning}`David Wood-2/+16
Currently, the only API for creating errors from a diagnostic derive will emit it immediately. This makes it difficult to add subdiagnostics to diagnostics from the derive, so add `create_{err,warning}` functions that return the diagnostic without emitting it. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-25add `struct_warn` methodChristian Poveda-0/+4
2022-04-25use `ParseSess` instead of `Session` in `into_diagnostic`Christian Poveda-1/+17
2022-04-13errors: lazily load fallback fluent bundleDavid Wood-4/+2
Loading the fallback bundle in compilation sessions that won't go on to emit any errors unnecessarily degrades compile time performance, so lazily create the Fluent bundle when it is first required. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-09expand: Remove `ParseSess::missing_fragment_specifiers`Vadim Petrochenkov-2/+0
It was used for deduplicating some errors for legacy code which are mostly deduplicated even without that, but at cost of global mutable state, which is not a good tradeoff.
2022-04-05session: opt for enabling directionality markersDavid Wood-2/+2
Add an option for enabling and disabling Fluent's directionality isolation markers in output. Disabled by default as these can render in some terminals and applications. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05errors: implement sysroot/testing bundle loadingDavid Wood-3/+6
Extend loading of Fluent bundles so that bundles can be loaded from the sysroot based on the language requested by the user, or using a nightly flag. Sysroot bundles are loaded from `$sysroot/share/locale/$locale/*.ftl`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05errors: implement fallback diagnostic translationDavid Wood-3/+13
This commit updates the signatures of all diagnostic functions to accept types that can be converted into a `DiagnosticMessage`. This enables existing diagnostic calls to continue to work as before and Fluent identifiers to be provided. The `SessionDiagnostic` derive just generates normal diagnostic calls, so these APIs had to be modified to accept Fluent identifiers. In addition, loading of the "fallback" Fluent bundle, which contains the built-in English messages, has been implemented. Each diagnostic now has "arguments" which correspond to variables in the Fluent messages (necessary to render a Fluent message) but no API for adding arguments has been added yet. Therefore, diagnostics (that do not require interpolation) can be converted to use Fluent identifiers and will be output as before.
2022-04-05span: move `MultiSpan`David Wood-2/+4
`MultiSpan` contains labels, which are more complicated with the introduction of diagnostic translation and will use types from `rustc_errors` - however, `rustc_errors` depends on `rustc_span` so `rustc_span` cannot use types like `DiagnosticMessage` without dependency cycles. Introduce a new `rustc_error_messages` crate that can contain `DiagnosticMessage` and `MultiSpan`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-03-24Prettify rustc_session fmt with capturing args (nfc)Jubilee Young-3/+2
2022-03-16resolve the conflict in compiler/rustc_session/src/parse.rscodehorseman-1/+1
Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-15fix typosDylan DPC-1/+1
2022-03-08Switch the primary diagnostic to `unknown_lints`David Koloski-2/+19
This also affects the `non_exhaustive_omitted_patterns` and `must_not_suspend` lints as they are not stable. This also changes the diagnostic level to pull from `unknown_lints` instead of always being allow or deny.
2022-03-02rename ErrorReported -> ErrorGuaranteedmark-3/+3
2022-02-23rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission".Eduard-Mihai Burtescu-3/+3
2022-02-23Replace `&mut DiagnosticBuilder`, in signatures, with `&mut Diagnostic`.Eduard-Mihai Burtescu-2/+2
2022-02-16Implement --check-cfg option (RFC 3013)Loïc BRANSTETT-0/+4
Co-authored-by: Urgau <lolo.branstett@numericable.fr> Co-authored-by: Marcelina Kościelnicka <mwk@0x04.net>
2021-11-23review comment: plural of emoji is emojiEsteban Kuber-1/+1
2021-11-23Tokenize emoji as if they were valid indentifiersEsteban Kuber-1/+7
In the lexer, consider emojis to be valid identifiers and reject them later to avoid knock down parse errors.
2021-10-02Report fatal lexer errors in `--cfg` command line argumentsFabian Wolff-2/+7
2021-07-30Use multispan suggestions more oftenEsteban Küber-14/+6
* Use more accurate span for `async move` suggestion * Use more accurate span for deref suggestion * Use `multipart_suggestion` more often