about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/errors.rs
AgeCommit message (Collapse)AuthorLines
2025-08-01Tweak rendering of cfg'd out itemEsteban Küber-20/+32
``` error[E0433]: failed to resolve: could not find `doesnt_exist` in `inner` --> $DIR/diagnostics-cross-crate.rs:18:23 | LL | cfged_out::inner::doesnt_exist::hello(); | ^^^^^^^^^^^^ could not find `doesnt_exist` in `inner` | note: found an item that was configured out --> $DIR/auxiliary/cfged_out.rs:6:13 | LL | #[cfg(false)] | ----- the item is gated here LL | pub mod doesnt_exist { | ^^^^^^^^^^^^ ```
2025-07-23Ports `#[macro_use]` and `#[macro_escape]` to the new attribute parsing ↵Jonathan Brouwer-7/+0
infrastructure
2025-07-03Rollup merge of #134006 - klensy:typos, r=nnethercoteJana Dönszelmann-5/+5
setup typos check in CI This allows to check typos in CI, currently for compiler only (to reduce commit size with fixes). With current setup, exclude list is quite short, so it worth trying? Also includes commits with actual typo fixes. MCP: https://github.com/rust-lang/compiler-team/issues/817 typos check currently turned for: * ./compiler * ./library * ./src/bootstrap * ./src/librustdoc After merging, PRs which enables checks for other crates (tools) can be implemented too. Found typos will **not break** other jobs immediately: (tests, building compiler for perf run). Job will be marked as red on completion in ~ 20 secs, so you will not forget to fix it whenever you want, before merging pr. Check typos: `python x.py test tidy --extra-checks=spellcheck` Apply typo fixes: `python x.py test tidy --extra-checks=spellcheck:fix` (in case if there only 1 suggestion of each typo) Current fail in this pr is expected and shows how typo errors emitted. Commit with error will be removed after r+.
2025-07-03setup CI and tidy to use typos for spellchecking and fix few typosklensy-5/+5
2025-07-01Suggest use another lifetime specifier instead of underscore lifetimexizheyin-0/+1
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-25Add runtime check to avoid overwrite arg easily in diag and store and ↵xizheyin-4/+1
restore snapshot when set subdiag arg Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-02resolve: Support imports of associated types and glob imports from traitsVadim Petrochenkov-16/+0
2025-03-19Allow builtin macros to be used more than once.Mara Bos-9/+0
This removes E0773 "A builtin-macro was defined more than once."
2025-03-12Disentangle ForwardGenericParamBan and ConstParamTy ribsMichael Goulet-1/+17
2025-02-28Introduce `feature(generic_const_parameter_types)`Boxy-13/+0
2025-01-27Use identifiers in diagnostics more oftenMichael Goulet-8/+8
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-2/+1
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-11-22Diagnostic for using macro_rules macro as attr/deriveclubby789-0/+16
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-2/+2
2024-09-02chore: Fix typos in 'compiler' (batch 2)Alexander Cyon-1/+1
2024-08-21Use bool in favor of Option<()> for diagnosticsMichael Goulet-1/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-6/+6
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-26Rollup merge of #127557 - linyihai:issue-126694, r=compiler-errorsTrevor Gross-1/+1
Add a label to point to the lacking macro name definition Fixes https://github.com/rust-lang/rust/issues/126694, but adopts the suggestion from https://github.com/rust-lang/rust/issues/118295 ``` --> src/main.rs:1:14 | 1 | macro_rules! { | ^ put a macro name here ```
2024-07-26Add a label to point to the lacking macro name definitionLin Yihai-1/+1
2024-07-12When finding item gated behind a `cfg` flat, point at itEsteban Küber-0/+9
Previously we would only mention that the item was gated out, and opportunisitically mention the feature flag name when possible. We now point to the place where the item was gated, which can be behind layers of macro indirection, or in different modules. ``` error[E0433]: failed to resolve: could not find `doesnt_exist` in `inner` --> $DIR/diagnostics-cross-crate.rs:18:23 | LL | cfged_out::inner::doesnt_exist::hello(); | ^^^^^^^^^^^^ could not find `doesnt_exist` in `inner` | note: found an item that was configured out --> $DIR/auxiliary/cfged_out.rs:6:13 | LL | pub mod doesnt_exist { | ^^^^^^^^^^^^ note: the item is gated here --> $DIR/auxiliary/cfged_out.rs:5:5 | LL | #[cfg(FALSE)] | ^^^^^^^^^^^^^ ```
2024-07-12Auto merge of #127382 - estebank:const-let, r=compiler-errorsbors-5/+7
Use verbose style when suggesting changing `const` with `let`
2024-07-11Account for `let foo = expr`; to suggest `const foo: Ty = expr;`Esteban Küber-4/+6
2024-07-11Use verbose style when suggesting changing `const` with `let`Esteban Küber-2/+2
2024-07-10Fix diagnostic and add a test for itMichael Goulet-1/+1
2024-05-24And more general errorMichael Baikov-0/+8
2024-05-24A custom error message for lending iteratorsMichael Baikov-0/+9
2024-04-21Move "elided lifetime in path" to subdiagnostic structXiretza-1/+3
This requires nested subdiagnostics.
2024-04-13Reorder error messagesJean CASPAR-1/+0
2024-04-13Migrate more diagnosticsJean CASPAR-0/+267
2024-04-13Migrate some diagnosticsJean CASPAR-2/+1
2024-04-13Port build_reduce_graphJeanCASPAR-3/+158
2024-03-11Remove `Default` derive from `MacroExpectedFound`.Nicholas Nethercote-1/+1
It's the only diagnostic in the entire project that impls `Default`, and the code is clearer without it.
2024-03-04Rollup merge of #121130 - chenyukang:yukang-fix-121061-macro-later, ↵Matthias Krüger-0/+15
r=matthiaskrgr Suggest moving definition if non-found macro_rules! is defined later Fixes #121061
2024-02-29Suggest moving if non-found macro_rules! is defined lateryukang-0/+15
2024-02-29Remove unused diagnostic structr0cky-39/+0
2024-02-06Rollup merge of #119939 - clubby789:static-const-generic-note, r=compiler-errorsMatthias Krüger-0/+11
Improve 'generic param from outer item' error for `Self` and inside `static`/`const` items Fixes #109596 Fixes #119936
2024-02-04Suggest `[tail @ ..]` on `[..tail]` and `[...tail]` where `tail` is unresolvedLeón Orell Valerian Liehr-0/+14
2024-02-02Suggest changing ty to const params if appropriateLeón Orell Valerian Liehr-1/+14
2024-01-29Stop using `String` for error codes.Nicholas Nethercote-31/+32
Error codes are integers, but `String` is used everywhere to represent them. Gross! This commit introduces `ErrCode`, an integral newtype for error codes, replacing `String`. It also introduces a constant for every error code, e.g. `E0123`, and removes the `error_code!` macro. The constants are imported wherever used with `use rustc_errors::codes::*`. With the old code, we have three different ways to specify an error code at a use point: ``` error_code!(E0123) // macro call struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call \#[diag(name, code = "E0123")] // string struct Diag; ``` With the new code, they all use the `E0123` constant. ``` E0123 // constant struct_span_code_err!(dcx, span, E0123, "msg"); // constant \#[diag(name, code = E0123)] // constant struct Diag; ``` The commit also changes the structure of the error code definitions: - `rustc_error_codes` now just defines a higher-order macro listing the used error codes and nothing else. - Because that's now the only thing in the `rustc_error_codes` crate, I moved it into the `lib.rs` file and removed the `error_codes.rs` file. - `rustc_errors` uses that macro to define everything, e.g. the error code constants and the `DIAGNOSTIC_TABLES`. This is in its new `codes.rs` file.
2024-01-29Remove bogus `{code}` attributes on `TraitImplMismatch`.Nicholas Nethercote-2/+1
This makes no sense, and has no effect. I suspect it's been confused with a `code = "{code}"` attribute on a subdiagnostic suggestion, where it is valid (but the "code" there is suggested source code, rather than an error code.)
2024-01-14Special case 'generic param from outer item' message for `Self`clubby789-0/+1
2024-01-14Add note to resolve error about generics from inside static/constclubby789-0/+10
2024-01-09Check bindings around never patternsNadrieril-0/+9
2023-12-06tip for define macro name after `macro_rules!`bohan-0/+7
2023-09-11Rollup merge of #115744 - fmease:fix-e0401, r=compiler-errorsMatthias Krüger-0/+34
Improve diagnostic for generic params from outer items (E0401) Generalize the wording of E0401 to talk about *outer items* instead of *outer functions* since the current phrasing is outdated. The outer item can be a function, constant, trait, ADT or impl block (see the new UI test for the more exotic examples). Further, don't suggest introducing generic parameters to constant items unless the feature `generic_const_items` is enabled. Lastly, make E0401 translatable while we're at it. Fixes #115720.
2023-09-10Make E0401 translatableLeón Orell Valerian Liehr-0/+34
2023-09-04resolve: derive diag for undetermined macro resolutionbohan-0/+10
2023-06-25Add translatable diagnostic for import resolution stringsTom Martin-0/+81
Add translatable diagnostic for cannot be reexported error also added for subdiagnostics Add translatable diagnostics for resolve_glob_import errors Add translatable diag for unable to determine import resolution Add translatable diag for is not directly importable
2023-06-19Remove unreachable and untested suggestion for invalid span enum derive(Default)Tom Martin-7/+0
2023-06-18Add translatable diagnostic for various strings in ↵Tom Martin-0/+31
resolve::unresolved_macro_suggestions