about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/late/diagnostics.rs
AgeCommit message (Collapse)AuthorLines
2024-09-16Rollup merge of #130033 - compiler-errors:foreign-fn-types, r=BoxyUwUMatthias Krüger-24/+25
Don't call `fn_arg_names` query for non-`fn` foreign items in resolver Fixes #130015
2024-09-16Do precise capturing arg validation in resolveMichael Goulet-2/+7
2024-09-12Rollup merge of #130208 - nnethercote:rslv-lifetime, r=petrochenkovMatthias Krüger-2/+2
Introduce `'ra` lifetime name. `rustc_resolve` allocates many things in `ResolverArenas`. The lifetime used for references into the arena is mostly `'a`, and sometimes `'b`. This commit changes it to `'rslv`, which is much more descriptive. The commit also changes the order of lifetimes on a couple of structs so that '`rslv` is second last, before `'tcx`, and does other minor renamings such as `'r` to `'a`. r? ``@petrochenkov`` cc ``@oli-obk``
2024-09-12Rollup merge of #130235 - compiler-errors:nested-if, r=michaelwoeristerStuart Cook-17/+16
Simplify some nested `if` statements Applies some but not all instances of `clippy::collapsible_if`. Some ended up looking worse afterwards, though, so I left those out. Also applies instances of `clippy::collapsible_else_if` Review with whitespace disabled please.
2024-09-12Introduce `'ra` lifetime name.Nicholas Nethercote-2/+2
`rustc_resolve` allocates many things in `ResolverArenas`. The lifetime used for references into the arena is mostly `'a`, and sometimes `'b`. This commit changes it to `'ra`, which is much more descriptive. The commit also changes the order of lifetimes on a couple of structs so that '`ra` is second last, before `'tcx`, and does other minor renamings such as `'r` to `'a`.
2024-09-11Simplify some nested if statementsMichael Goulet-17/+16
2024-09-09Remove needless returns detected by clippy in the compilerEduardo Sánchez Muñoz-1/+1
2024-09-07Don't call fn_arg_names for non-fn in resolverMichael Goulet-24/+25
2024-08-31Implement `elided_named_lifetimes` lintPavel Grigorenko-2/+9
2024-08-11Rollup merge of #128762 - fmease:use-more-slice-pats, r=compiler-errorsMatthias Krüger-7/+6
Use more slice patterns inside the compiler Nothing super noteworthy. Just replacing the common 'fragile' pattern of "length check followed by indexing or unwrap" with slice patterns for legibility and 'robustness'. r? ghost
2024-08-07make `import.vis` is not mutablebohan-0/+1
2024-08-07Use more slice patterns inside the compilerLeón Orell Valerian Liehr-7/+6
2024-07-29Reformat `use` declarations.Nicholas Nethercote-20/+19
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-06Use field ident spans directly instead of the full field span in diagnostics ↵Oli Scherer-25/+19
on local fields
2024-06-18Remove redundant argument from `subdiagnostic` methodOli Scherer-15/+9
2024-06-17Rework precise capturing syntaxMichael Goulet-2/+2
2024-06-15delegation: Fix hygiene for `self`Vadim Petrochenkov-9/+15
And fix diagnostics for `self` from a macro.
2024-06-10Delegation: fix ICE on late diagnosticsBryanskiy-2/+5
2024-05-30Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanupLeón Orell Valerian Liehr-3/+3
2024-05-21Auto merge of #124417 - Xiretza:translate-early-lints, r=fmeasebors-4/+4
Make early lints translatable <del>Requires https://github.com/projectfluent/fluent-rs/pull/353.</del> https://github.com/rust-lang/rust/commit/5134a04eaa32b168cf5998a6ec13199356e2e017 r? diagnostics
2024-05-21Rename buffer_lint_with_diagnostic to buffer_lintXiretza-2/+2
2024-05-21Generate lint diagnostic message from BuiltinLintDiagXiretza-2/+2
Translation of the lint message happens when the actual diagnostic is created, not when the lint is buffered. Generating the message from BuiltinLintDiag ensures that all required data to construct the message is preserved in the LintBuffer, eventually allowing the messages to be moved to fluent. Remove the `msg` field from BufferedEarlyLint, it is either generated from the data in the BuiltinLintDiag or stored inside BuiltinLintDiag::Normal.
2024-05-20Fix incorrect suggestion for undeclared hrtb lifetimes in where clauses.surechen-14/+87
fixes #122714
2024-05-18Auto merge of #125105 - nnethercote:rustc_resolve-cleanups, r=estebankbors-0/+1
`rustc_resolve` cleanups Some improvements I found while looking through this code. r? `@estebank`
2024-05-15delegation: Implement list delegationVadim Petrochenkov-1/+3
```rust reuse prefix::{a, b, c} ```
2024-05-10Remove `#[macro_use] extern crate tracing` from `rustc_resolve`.Nicholas Nethercote-0/+1
Explicit imports are more standard nowadays and easier to read.
2024-04-23delegation: Support async, const, extern "ABI" and C-variadic functionsVadim Petrochenkov-2/+5
Also allow `impl Trait` in delegated functions. The delegation item will refer to the original opaque type from the callee, fresh opaque type won't be created.
2024-04-15Parsing , pre-lowering support for precise capturesMichael Goulet-1/+1
2024-03-21Don't suggest deref macro since it's unstableMichael Goulet-1/+6
2024-03-21Fix bad span for explicit lifetime suggestionShoyu Vanilla-13/+1
Move verbose logic to a function Minor renaming
2024-03-05Rename `DiagnosticMetadata` as `DiagMetadata`.Nicholas Nethercote-27/+26
2024-03-05Rename `BuiltinLintDiagnostics` as `BuiltinLintDiag`.Nicholas Nethercote-2/+2
Not the dropping of the trailing `s` -- this type describes a single diagnostic and its name should be singular.
2024-03-02avoid collecting into vecs in some placesMatthias Krüger-4/+1
2024-02-28Rename `DiagnosticBuilder` as `Diag`.Nicholas Nethercote-79/+64
Much better! Note that this involves renaming (and updating the value of) `DIAGNOSTIC_BUILDER` in clippy.
2024-02-23compiler: clippy::complexity fixesMatthias Krüger-1/+1
2024-02-19Prefer `DiagnosticBuilder` over `Diagnostic` in diagnostic modifiers.Nicholas Nethercote-63/+80
There are lots of functions that modify a diagnostic. This can be via a `&mut Diagnostic` or a `&mut DiagnosticBuilder`, because the latter type wraps the former and impls `DerefMut`. This commit converts all the `&mut Diagnostic` occurrences to `&mut DiagnosticBuilder`. This is a step towards greatly simplifying `Diagnostic`. Some of the relevant function are made generic, because they deal with both errors and warnings. No function bodies are changed, because all the modifier methods are available on both `Diagnostic` and `DiagnosticBuilder`.
2024-02-17Rollup merge of #121085 - davidtwco:always-eager-diagnostics, r=nnethercoteMatthias Krüger-9/+15
errors: only eagerly translate subdiagnostics Subdiagnostics don't need to be lazily translated, they can always be eagerly translated. Eager translation is slightly more complex as we need to have a `DiagCtxt` available to perform the translation, which involves slightly more threading of that context. This slight increase in complexity should enable later simplifications - like passing `DiagCtxt` into `AddToDiagnostic` and moving Fluent messages into the diagnostic structs rather than having them in separate files (working on that was what led to this change). r? ```@nnethercote```
2024-02-15errors: only eagerly translate subdiagnosticsDavid Wood-9/+15
Subdiagnostics don't need to be lazily translated, they can always be eagerly translated. Eager translation is slightly more complex as we need to have a `DiagCtxt` available to perform the translation, which involves slightly more threading of that context. This slight increase in complexity should enable later simplifications - like passing `DiagCtxt` into `AddToDiagnostic` and moving Fluent messages into the diagnostic structs rather than having them in separate files (working on that was what led to this change). Signed-off-by: David Wood <david@davidtw.co>
2024-02-14remove importing suggestions when there is a shadowed typo canddiateyukang-23/+39
2024-02-04Suggest `[tail @ ..]` on `[..tail]` and `[...tail]` where `tail` is unresolvedLeón Orell Valerian Liehr-14/+24
2024-02-03Rollup merge of #120592 - trevyn:cleanup-to-string, r=NilstriebMatthias Krüger-2/+2
Remove unnecessary `.to_string()`/`.as_str()`s
2024-02-02Remove unnecessary `.to_string()`/`.as_str()`strevyn-2/+2
2024-02-02Suggest changing ty to const params if appropriateLeón Orell Valerian Liehr-0/+50
2024-02-02Clean up some things in the name resolverLeón Orell Valerian Liehr-7/+9
* Get rid of a typo in a function name * Rename `currently_processing_generics`: The old name confused me at first since I assumed it referred to generic *parameters* when it was in fact referring to generic *arguments*. Generics are typically short for generic params. * Get rid of a few unwraps by properly leveraging slice patterns
2024-01-29Stop using `String` for error codes.Nicholas Nethercote-7/+7
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-20Don't delete any lifetimes with boundstrevyn-1/+2
2024-01-17Make crate_inherent_impls fallible and stop using `track_errors` for itOli Scherer-4/+2
2024-01-12Delegation implementation: step 1Bryanskiy-1/+11
2024-01-10Rename consuming chaining methods on `DiagnosticBuilder`.Nicholas Nethercote-7/+7
In #119606 I added them and used a `_mv` suffix, but that wasn't great. A `with_` prefix has three different existing uses. - Constructors, e.g. `Vec::with_capacity`. - Wrappers that provide an environment to execute some code, e.g. `with_session_globals`. - Consuming chaining methods, e.g. `Span::with_{lo,hi,ctxt}`. The third case is exactly what we want, so this commit changes `DiagnosticBuilder::foo_mv` to `DiagnosticBuilder::with_foo`. Thanks to @compiler-errors for the suggestion.
2024-01-10Rename `struct_span_err!` as `struct_span_code_err!`.Nicholas Nethercote-5/+5
Because it takes an error code after the span. This avoids the confusing overlap with the `DiagCtxt::struct_span_err` method, which doesn't take an error code.