about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/errors.rs
AgeCommit message (Collapse)AuthorLines
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
2023-06-18Add translatable diagnostic for cannot find in this scopeTom Martin-0/+9
2023-06-18Add translatable diagnostic for invalid importsTom Martin-0/+8
2023-06-18Add translatable diagnostic for changing import bindingTom Martin-0/+19
2023-06-01Remember names of `cfg`-ed out items to mention them in diagnosticsNilstrieb-0/+4
`#[cfg]`s are frequently used to gate crate content behind cargo features. This can lead to very confusing errors when features are missing. For example, `serde` doesn't have the `derive` feature by default. Therefore, `serde::Serialize` fails to resolve with a generic error, even though the macro is present in the docs. This commit adds a list of all stripped item names to metadata. This is filled during macro expansion and then, through a fed query, persisted in metadata. The downstream resolver can then access the metadata to look at possible candidates for mentioning in the errors. This slightly increases metadata (800k->809k for the feature-heavy windows crate), but not enough to really matter.
2023-05-11Improve error for `self: Box<self>`clubby789-0/+8
2023-05-05improve diagnostics and bless testsBoxy-6/+41
2023-04-25Fix static string lintsclubby789-0/+22
2023-04-24Rollup merge of #110255 - clubby789:proc-macro-test-help, r=jackh726Matthias Krüger-0/+9
Suggest using integration tests for test crate using own proc-macro cc #110247
2023-04-17Spelling - compilerJosh Soref-1/+1
* account * achieved * advising * always * ambiguous * analysis * annotations * appropriate * build * candidates * cascading * category * character * clarification * compound * conceptually * constituent * consts * convenience * corresponds * debruijn * debug * debugable * debuggable * deterministic * discriminant * display * documentation * doesn't * ellipsis * erroneous * evaluability * evaluate * evaluation * explicitly * fallible * fulfill * getting * has * highlighting * illustrative * imported * incompatible * infringing * initialized * into * intrinsic * introduced * javascript * liveness * metadata * monomorphization * nonexistent * nontrivial * obligation * obligations * offset * opaque * opportunities * opt-in * outlive * overlapping * paragraph * parentheses * poisson * precisely * predecessors * predicates * preexisting * propagated * really * reentrant * referent * responsibility * rustonomicon * shortcircuit * simplifiable * simplifications * specify * stabilized * structurally * suggestibility * translatable * transmuting * two * unclosed * uninhabited * visibility * volatile * workaround Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-17Suggest using integration tests for proc-macrosclubby789-0/+9
2023-04-10Auto merge of #109638 - NotStirred:suggest/non-derive, r=davidtwcobors-0/+27
Add suggestion to remove `derive()` if invoked macro is non-derive Adds to the existing `expected derive macro, found {}` error message: ``` help: remove the surrounding "derive()": --> $DIR/macro-path-prelude-fail-4.rs:1:3 | LL | #[derive(inline)] | ^^^^^^^ ^ ``` This suggestion will either fix the issue, in the case that the macro was valid, or provide a better error message if not Not ready for merge yet, as the highlighted span is only valid for trivial formatting. Is there a nice way to get the parent span of the macro path within `smart_resolve_macro_path`? Closes #109589
2023-04-07Change type and field name to be clearerTom Martin-2/+2
2023-04-07Rewrite added diagnostics as translatableTom Martin-0/+27
Start messages with lowercase
2023-04-04Deny `use`ing tool pathsclubby789-0/+9
2023-02-22errors: generate typed identifiers in each crateDavid Wood-7/+7
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>
2022-11-13migrating rustc_resolve to SessionDiagnostic. work in progress. startRajput, Rajat-0/+474
implement binding_shadows migrate till self-in-generic-param-default use braces in fluent message as suggested by @compiler-errors. to fix lock file issue reported by CI migrate 'unreachable label' error run formatter name the variables correctly in fluent file SessionDiagnostic -> Diagnostic test "pattern/pat-tuple-field-count-cross.rs" passed test "resolve/bad-env-capture2.rs" passed test "enum/enum-in-scope.rs" and other depended on "resolve_binding_shadows_something_unacceptable" should be passed now. fix crash errors while running test-suite. there might be more. then_some(..) suits better here. all tests passed convert TraitImpl and InvalidAsm. TraitImpl is buggy yet. will fix after receiving help from Zulip migrate "Ralative-2018" migrate "ancestor only" migrate "expected found" migrate "Indeterminate" migrate "module only" revert to the older implementation for now. since this is failing at the moment. follow the convension for fluent variable order the diag attribute as suggested in review comment fix merge error. migrate trait-impl-duplicate make the changes compatible with "Flatten diagnostic slug modules #103345" fix merge remove commented code merge issues fix review comments fix tests