Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3803,7 +3803,6 @@ dependencies = [
"rustc_parse",
"rustc_passes",
"rustc_pattern_analysis",
"rustc_privacy",
"rustc_public",
"rustc_resolve",
"rustc_session",
Expand Down Expand Up @@ -4487,7 +4486,6 @@ dependencies = [
"rustc_ast",
"rustc_data_structures",
"rustc_errors",
"rustc_fluent_macro",
"rustc_hir",
"rustc_macros",
"rustc_middle",
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_driver_impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ rustc_monomorphize = { path = "../rustc_monomorphize" }
rustc_parse = { path = "../rustc_parse" }
rustc_passes = { path = "../rustc_passes" }
rustc_pattern_analysis = { path = "../rustc_pattern_analysis" }
rustc_privacy = { path = "../rustc_privacy" }
rustc_public = { path = "../rustc_public", features = ["rustc_internal"] }
rustc_resolve = { path = "../rustc_resolve" }
rustc_session = { path = "../rustc_session" }
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
rustc_parse::DEFAULT_LOCALE_RESOURCE,
rustc_passes::DEFAULT_LOCALE_RESOURCE,
rustc_pattern_analysis::DEFAULT_LOCALE_RESOURCE,
rustc_privacy::DEFAULT_LOCALE_RESOURCE,
rustc_resolve::DEFAULT_LOCALE_RESOURCE,
rustc_session::DEFAULT_LOCALE_RESOURCE,
rustc_trait_selection::DEFAULT_LOCALE_RESOURCE,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_privacy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ edition = "2024"
rustc_ast = { path = "../rustc_ast" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_hir = { path = "../rustc_hir" }
rustc_macros = { path = "../rustc_macros" }
rustc_middle = { path = "../rustc_middle" }
Expand Down
39 changes: 0 additions & 39 deletions compiler/rustc_privacy/messages.ftl

This file was deleted.

50 changes: 33 additions & 17 deletions compiler/rustc_privacy/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_span::{Span, Symbol};

#[derive(Diagnostic)]
#[diag(privacy_field_is_private, code = E0451)]
#[diag("{$len ->
[1] field
*[other] fields
} {$field_names} of {$variant_descr} `{$def_path_str}` {$len ->
[1] is
*[other] are
} private", code = E0451)]
pub(crate) struct FieldIsPrivate {
#[primary_span]
pub span: MultiSpan,
#[label]
#[label("in this type")]
pub struct_span: Option<Span>,
pub field_names: String,
pub variant_descr: &'static str,
Expand All @@ -20,71 +26,81 @@ pub(crate) struct FieldIsPrivate {

#[derive(Subdiagnostic)]
pub(crate) enum FieldIsPrivateLabel {
#[label(privacy_field_is_private_is_update_syntax_label)]
#[label(
"{$rest_len ->
[1] field
*[other] fields
} {$rest_field_names} {$rest_len ->
[1] is
*[other] are
} private"
)]
IsUpdateSyntax {
#[primary_span]
span: Span,
rest_field_names: String,
rest_len: usize,
},
#[label(privacy_field_is_private_label)]
#[label("private field")]
Other {
#[primary_span]
span: Span,
},
}

#[derive(Diagnostic)]
#[diag(privacy_item_is_private)]
#[diag("{$kind} `{$descr}` is private")]
pub(crate) struct ItemIsPrivate<'a> {
#[primary_span]
#[label]
#[label("private {$kind}")]
pub span: Span,
pub kind: &'a str,
pub descr: DiagArgFromDisplay<'a>,
}

#[derive(Diagnostic)]
#[diag(privacy_unnamed_item_is_private)]
#[diag("{$kind} is private")]
pub(crate) struct UnnamedItemIsPrivate {
#[primary_span]
pub span: Span,
pub kind: &'static str,
}

#[derive(Diagnostic)]
#[diag(privacy_in_public_interface, code = E0446)]
#[diag("{$vis_descr} {$kind} `{$descr}` in public interface", code = E0446)]
pub(crate) struct InPublicInterface<'a> {
#[primary_span]
#[label]
#[label("can't leak {$vis_descr} {$kind}")]
pub span: Span,
pub vis_descr: &'static str,
pub kind: &'a str,
pub descr: DiagArgFromDisplay<'a>,
#[label(privacy_visibility_label)]
#[label("`{$descr}` declared as {$vis_descr}")]
pub vis_span: Span,
}

#[derive(Diagnostic)]
#[diag(privacy_report_effective_visibility)]
#[diag("{$descr}")]
pub(crate) struct ReportEffectiveVisibility {
#[primary_span]
pub span: Span,
pub descr: String,
}

#[derive(LintDiagnostic)]
#[diag(privacy_from_private_dep_in_public_interface)]
#[diag("{$kind} `{$descr}` from private dependency '{$krate}' in public interface")]
pub(crate) struct FromPrivateDependencyInPublicInterface<'a> {
pub kind: &'a str,
pub descr: DiagArgFromDisplay<'a>,
pub krate: Symbol,
}

#[derive(LintDiagnostic)]
#[diag(privacy_unnameable_types_lint)]
#[diag("{$kind} `{$descr}` is reachable but cannot be named")]
pub(crate) struct UnnameableTypesLint<'a> {
#[label]
#[label(
"reachable at visibility `{$reachable_vis}`, but can only be named at visibility `{$reexported_vis}`"
)]
pub span: Span,
pub kind: &'a str,
pub descr: DiagArgFromDisplay<'a>,
Expand All @@ -96,14 +112,14 @@ pub(crate) struct UnnameableTypesLint<'a> {
// They will replace private-in-public errors and compatibility lints in future.
// See https://rust-lang.github.io/rfcs/2145-type-privacy.html for more details.
#[derive(LintDiagnostic)]
#[diag(privacy_private_interface_or_bounds_lint)]
#[diag("{$ty_kind} `{$ty_descr}` is more private than the item `{$item_descr}`")]
pub(crate) struct PrivateInterfacesOrBoundsLint<'a> {
#[label(privacy_item_label)]
#[label("{$item_kind} `{$item_descr}` is reachable at visibility `{$item_vis_descr}`")]
pub item_span: Span,
pub item_kind: &'a str,
pub item_descr: DiagArgFromDisplay<'a>,
pub item_vis_descr: &'a str,
#[note(privacy_ty_note)]
#[note("but {$ty_kind} `{$ty_descr}` is only usable at visibility `{$ty_vis_descr}`")]
pub ty_span: Span,
pub ty_kind: &'a str,
pub ty_descr: DiagArgFromDisplay<'a>,
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_privacy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ use rustc_span::hygiene::Transparency;
use rustc_span::{Ident, Span, Symbol, sym};
use tracing::debug;

rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

////////////////////////////////////////////////////////////////////////////////
// Generic infrastructure used to implement specific visitors below.
////////////////////////////////////////////////////////////////////////////////
Expand Down
Loading