about summary refs log tree commit diff
path: root/compiler/rustc_privacy/src/errors.rs
AgeCommit message (Collapse)AuthorLines
2025-01-18Emit a single privacy error for multiple fields on the same struct expressionEsteban Küber-5/+7
Collect all unreachable fields in a single struct literal struct and emit a single error, instead of one error per private field. ``` error[E0451]: fields `beta` and `gamma` of struct `Alpha` are private --> $DIR/visibility.rs:18:13 | LL | let _x = Alpha { | ----- in this type LL | beta: 0, | ^^^^^^^ private field LL | .. | ^^ field `gamma` is private ```
2025-01-18Add context on private fields that are not on the same line as the struct nameEsteban Küber-0/+2
``` error[E0451]: field `x` of struct `S` is private --> $DIR/visibility.rs:24:9 | LL | let a = baz::S { | ------ in this type LL | .. | ^^ field `x` is private ```
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-1/+1
2024-08-29Add `warn(unreachable_pub)` to `rustc_privacy`.Nicholas Nethercote-9/+9
2024-07-29Reformat `use` declarations.Nicholas Nethercote-1/+2
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-02-28Rename `DiagnosticArgFromDisplay` as `DiagArgFromDisplay`.Nicholas Nethercote-7/+7
2024-01-29Stop using `String` for error codes.Nicholas Nethercote-3/+3
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.
2023-08-02Replace old private-in-public diagnostic with type privacy lintsBryanskiy-23/+0
2023-06-29Fix type privacy lints error messageBryanskiy-1/+1
2023-06-12Private-in-public lints implementationBryanskiy-0/+29
2023-02-22errors: generate typed identifiers in each crateDavid Wood-2/+2
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-10-23Migrate all diagnosticsNilstrieb-12/+12
2022-09-21UPDATE - rename SessionSubdiagnostic macro to SubdiagnosticJhonny Bill Mena-2/+2
Also renames: - sym::AddSubdiagnostic to sym:: Subdiagnostic - rustc_diagnostic_item = "AddSubdiagnostic" to rustc_diagnostic_item = "Subdiagnostic"
2022-09-21UPDATE - rename DiagnosticHandler macro to DiagnosticJhonny Bill Mena-6/+6
2022-09-21UPDATE - rename DiagnosticHandler trait to IntoDiagnosticJhonny Bill Mena-7/+7
2022-09-14change AccessLevels representationBryanskiy-2/+2
2022-08-31add TestReachabilityVisitorBryanskiy-0/+8
2022-08-21Replace #[lint/warning/error] with #[diag]Xiretza-7/+7
2022-08-05move DiagnosticArgFromDisplay into rustc_errorsMichael Goulet-16/+6
2022-08-05Delay formatting trimmed path until lint/error is emittedMichael Goulet-5/+16
2022-07-15errors: lint on `LintDiagnosticBuilder::build`David Wood-1/+17
Apply the `#[rustc_lint_diagnostics]` attribute to `LintDiagnosticBuilder::build` so that diagnostic migration lints will trigger for it. Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-27privacy: port "in public interface" diagDavid Wood-0/+28
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-27privacy: port unnamed "item is private" diagDavid Wood-0/+8
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-27privacy: port "item is private" diagDavid Wood-0/+10
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-27privacy: port "field is private" diagDavid Wood-0/+29
Signed-off-by: David Wood <david.wood@huawei.com>