-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #98420 - davidtwco:translation-lint-fixes-and-more-mi…
…gration, r=compiler-errors translation: lint fix + more migration - Unfortunately, the diagnostic lints are very broken and trigger much more often than they should. This PR corrects the conditional which checks if the function call being made is to a diagnostic function so that it returns in every intended case. - The `rustc_lint_diagnostics` attribute is used by the diagnostic translation/struct migration lints to identify calls where non-translatable diagnostics or diagnostics outwith impls are being created. Any function used in creating a diagnostic should be annotated with this attribute so this PR adds the attribute to many more functions. - Port the diagnostics from the `rustc_privacy` crate and enable the lints for that crate. r? ``@compiler-errors``
- Loading branch information
Showing
14 changed files
with
188 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
privacy-field-is-private = field `{$field_name}` of {$variant_descr} `{$def_path_str}` is private | ||
privacy-field-is-private-is-update-syntax-label = field `{$field_name}` is private | ||
privacy-field-is-private-label = private field | ||
privacy-item-is-private = {$kind} `{$descr}` is private | ||
.label = private {$kind} | ||
privacy-unnamed-item-is-private = {$kind} is private | ||
.label = private {$kind} | ||
privacy-in-public-interface = {$vis_descr} {$kind} `{$descr}` in public interface | ||
.label = can't leak {$vis_descr} {$kind} | ||
.visibility-label = `{$descr}` declared as {$vis_descr} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic}; | ||
use rustc_span::{Span, Symbol}; | ||
|
||
#[derive(SessionDiagnostic)] | ||
#[error(privacy::field_is_private, code = "E0451")] | ||
pub struct FieldIsPrivate { | ||
#[primary_span] | ||
pub span: Span, | ||
pub field_name: Symbol, | ||
pub variant_descr: &'static str, | ||
pub def_path_str: String, | ||
#[subdiagnostic] | ||
pub label: FieldIsPrivateLabel, | ||
} | ||
|
||
#[derive(SessionSubdiagnostic)] | ||
pub enum FieldIsPrivateLabel { | ||
#[label(privacy::field_is_private_is_update_syntax_label)] | ||
IsUpdateSyntax { | ||
#[primary_span] | ||
span: Span, | ||
field_name: Symbol, | ||
}, | ||
#[label(privacy::field_is_private_label)] | ||
Other { | ||
#[primary_span] | ||
span: Span, | ||
}, | ||
} | ||
|
||
#[derive(SessionDiagnostic)] | ||
#[error(privacy::item_is_private)] | ||
pub struct ItemIsPrivate<'a> { | ||
#[primary_span] | ||
#[label] | ||
pub span: Span, | ||
pub kind: &'a str, | ||
pub descr: String, | ||
} | ||
|
||
#[derive(SessionDiagnostic)] | ||
#[error(privacy::unnamed_item_is_private)] | ||
pub struct UnnamedItemIsPrivate { | ||
#[primary_span] | ||
pub span: Span, | ||
pub kind: &'static str, | ||
} | ||
|
||
// Duplicate of `InPublicInterface` but with a different error code, shares the same slug. | ||
#[derive(SessionDiagnostic)] | ||
#[error(privacy::in_public_interface, code = "E0445")] | ||
pub struct InPublicInterfaceTraits<'a> { | ||
#[primary_span] | ||
#[label] | ||
pub span: Span, | ||
pub vis_descr: &'static str, | ||
pub kind: &'a str, | ||
pub descr: String, | ||
#[label(privacy::visibility_label)] | ||
pub vis_span: Span, | ||
} | ||
|
||
// Duplicate of `InPublicInterfaceTraits` but with a different error code, shares the same slug. | ||
#[derive(SessionDiagnostic)] | ||
#[error(privacy::in_public_interface, code = "E0446")] | ||
pub struct InPublicInterface<'a> { | ||
#[primary_span] | ||
#[label] | ||
pub span: Span, | ||
pub vis_descr: &'static str, | ||
pub kind: &'a str, | ||
pub descr: String, | ||
#[label(privacy::visibility_label)] | ||
pub vis_span: Span, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.