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 @@ -3797,7 +3797,6 @@ dependencies = [
"rustc_session",
"rustc_span",
"rustc_target",
"rustc_trait_selection",
"serde_json",
"shlex",
"tracing",
Expand Down Expand Up @@ -4724,7 +4723,6 @@ dependencies = [
"rustc_ast",
"rustc_data_structures",
"rustc_errors",
"rustc_fluent_macro",
"rustc_hir",
"rustc_infer",
"rustc_macros",
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 @@ -36,7 +36,6 @@ rustc_resolve = { path = "../rustc_resolve" }
rustc_session = { path = "../rustc_session" }
rustc_span = { path = "../rustc_span" }
rustc_target = { path = "../rustc_target" }
rustc_trait_selection = { path = "../rustc_trait_selection" }
serde_json = "1.0.59"
shlex = "1.0"
tracing = { version = "0.1.35" }
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 @@ -121,7 +121,6 @@ pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
rustc_mir_build::DEFAULT_LOCALE_RESOURCE,
rustc_parse::DEFAULT_LOCALE_RESOURCE,
rustc_passes::DEFAULT_LOCALE_RESOURCE,
rustc_trait_selection::DEFAULT_LOCALE_RESOURCE,
// tidy-alphabetical-end
];

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_error_messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub fn fluent_bundle(
Ok(Some(bundle))
}

fn register_functions(bundle: &mut FluentBundle) {
pub fn register_functions<R, M>(bundle: &mut fluent_bundle::bundle::FluentBundle<R, M>) {
bundle
.add_function("STREQ", |positional, _named| match positional {
[FluentValue::String(a), FluentValue::String(b)] => format!("{}", (a == b)).into(),
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_errors/src/translation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::env;
use std::error::Report;
use std::sync::Arc;

use rustc_error_messages::langid;
pub use rustc_error_messages::{FluentArgs, LazyFallbackBundle};
use rustc_error_messages::{langid, register_functions};
use tracing::{debug, trace};

use crate::error::{TranslateError, TranslateErrorKind};
Expand Down Expand Up @@ -91,6 +91,7 @@ impl Translator {
let mut bundle = fluent_bundle::FluentBundle::new(vec![langid!("en-US")]);
bundle.set_use_isolating(false);
bundle.add_resource(resource).unwrap();
register_functions(&mut bundle);
let message = bundle.get_message(GENERATED_MSG_ID).unwrap();
let value = message.value().unwrap();

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_trait_selection/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ rustc_abi = { path = "../rustc_abi" }
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_infer = { path = "../rustc_infer" }
rustc_macros = { path = "../rustc_macros" }
Expand Down
470 changes: 0 additions & 470 deletions compiler/rustc_trait_selection/messages.ftl

This file was deleted.

37 changes: 24 additions & 13 deletions compiler/rustc_trait_selection/src/error_reporting/infer/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use std::iter;

use rustc_data_structures::fx::FxIndexSet;
use rustc_errors::{
Applicability, Diag, E0309, E0310, E0311, E0803, Subdiagnostic, struct_span_code_err,
Applicability, Diag, E0309, E0310, E0311, E0803, Subdiagnostic, inline_fluent,
struct_span_code_err,
};
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LocalDefId};
Expand All @@ -25,7 +26,6 @@ use crate::errors::{
self, FulfillReqLifetime, LfBoundNotSatisfied, OutlivesBound, OutlivesContent,
RefLongerThanData, RegionOriginNote, WhereClauseSuggestions, note_and_explain,
};
use crate::fluent_generated as fluent;
use crate::infer::region_constraints::GenericKind;
use crate::infer::{
BoundRegionConversionTime, InferCtxt, RegionResolutionError, RegionVariableOrigin,
Expand Down Expand Up @@ -228,18 +228,22 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
expected_found: self.values_str(trace.values, &trace.cause, err.long_ty_path()),
}
.add_to_diag(err),
SubregionOrigin::Reborrow(span) => {
RegionOriginNote::Plain { span, msg: fluent::trait_selection_reborrow }
.add_to_diag(err)
SubregionOrigin::Reborrow(span) => RegionOriginNote::Plain {
span,
msg: inline_fluent!("...so that reference does not outlive borrowed content"),
}
.add_to_diag(err),
SubregionOrigin::RelateObjectBound(span) => {
RegionOriginNote::Plain { span, msg: fluent::trait_selection_relate_object_bound }
.add_to_diag(err);
RegionOriginNote::Plain {
span,
msg: inline_fluent!("...so that it can be closed over into an object"),
}
.add_to_diag(err);
}
SubregionOrigin::ReferenceOutlivesReferent(ty, span) => {
RegionOriginNote::WithName {
span,
msg: fluent::trait_selection_reference_outlives_referent,
msg: inline_fluent!("...so that the reference type `{$name}` does not outlive the data it points at"),
name: &self.ty_to_string(ty),
continues: false,
}
Expand All @@ -248,30 +252,37 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
SubregionOrigin::RelateParamBound(span, ty, opt_span) => {
RegionOriginNote::WithName {
span,
msg: fluent::trait_selection_relate_param_bound,
msg: inline_fluent!("...so that the type `{$name}` will meet its required lifetime bounds{$continues ->
[true] ...
*[false] {\"\"}
}"),
name: &self.ty_to_string(ty),
continues: opt_span.is_some(),
}
.add_to_diag(err);
if let Some(span) = opt_span {
RegionOriginNote::Plain {
span,
msg: fluent::trait_selection_relate_param_bound_2,
msg: inline_fluent!("...that is required by this bound"),
}
.add_to_diag(err);
}
}
SubregionOrigin::RelateRegionParamBound(span, _) => {
RegionOriginNote::Plain {
span,
msg: fluent::trait_selection_relate_region_param_bound,
msg: inline_fluent!(
"...so that the declared lifetime parameter bounds are satisfied"
),
}
.add_to_diag(err);
}
SubregionOrigin::CompareImplItemObligation { span, .. } => {
RegionOriginNote::Plain {
span,
msg: fluent::trait_selection_compare_impl_item_obligation,
msg: inline_fluent!(
"...so that the definition in impl matches the definition from the trait"
),
}
.add_to_diag(err);
}
Expand All @@ -281,7 +292,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
SubregionOrigin::AscribeUserTypeProvePredicate(span) => {
RegionOriginNote::Plain {
span,
msg: fluent::trait_selection_ascribe_user_type_prove_predicate,
msg: inline_fluent!("...so that the where clause holds"),
}
.add_to_diag(err);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rustc_data_structures::unord::UnordSet;
use rustc_errors::codes::*;
use rustc_errors::{
Applicability, Diag, ErrorGuaranteed, Level, MultiSpan, StashKey, StringPart, Suggestions,
pluralize, struct_span_code_err,
inline_fluent, pluralize, struct_span_code_err,
};
use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId};
use rustc_hir::intravisit::Visitor;
Expand Down Expand Up @@ -3003,7 +3003,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
{
err.span_help(
self.tcx.def_span(trait_def_id),
crate::fluent_generated::trait_selection_trait_has_no_impls,
inline_fluent!("this trait has no implementations, consider adding one"),
);
} else if !suggested && trait_predicate.polarity() == ty::PredicatePolarity::Positive {
// Can't show anything else useful, try to find similar impls.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,10 @@ pub enum AppendConstMessage {
}

#[derive(LintDiagnostic)]
#[diag(trait_selection_malformed_on_unimplemented_attr)]
#[help]
#[diag("malformed `on_unimplemented` attribute")]
#[help("only `message`, `note` and `label` are allowed as options")]
pub struct MalformedOnUnimplementedAttrLint {
#[label]
#[label("invalid option found here")]
pub span: Span,
}

Expand All @@ -374,17 +374,17 @@ impl MalformedOnUnimplementedAttrLint {
}

#[derive(LintDiagnostic)]
#[diag(trait_selection_missing_options_for_on_unimplemented_attr)]
#[help]
#[diag("missing options for `on_unimplemented` attribute")]
#[help("at least one of the `message`, `note` and `label` options are expected")]
pub struct MissingOptionsForOnUnimplementedAttr;

#[derive(LintDiagnostic)]
#[diag(trait_selection_ignored_diagnostic_option)]
#[diag("`{$option_name}` is ignored due to previous definition of `{$option_name}`")]
pub struct IgnoredDiagnosticOption {
pub option_name: &'static str,
#[label]
#[label("`{$option_name}` is already declared here")]
pub span: Span,
#[label(trait_selection_other_label)]
#[label("`{$option_name}` is first declared here")]
pub prev_span: Span,
}

Expand All @@ -410,7 +410,7 @@ impl IgnoredDiagnosticOption {
}

#[derive(LintDiagnostic)]
#[diag(trait_selection_wrapped_parser_error)]
#[diag("{$description}")]
pub struct WrappedParserError {
pub description: String,
pub label: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,25 +310,27 @@ pub mod errors {
use super::*;

#[derive(LintDiagnostic)]
#[diag(trait_selection_unknown_format_parameter_for_on_unimplemented_attr)]
#[help]
#[diag("there is no parameter `{$argument_name}` on trait `{$trait_name}`")]
#[help("expect either a generic argument name or {\"`{Self}`\"} as format argument")]
pub struct UnknownFormatParameterForOnUnimplementedAttr {
pub argument_name: Symbol,
pub trait_name: Ident,
}

#[derive(LintDiagnostic)]
#[diag(trait_selection_disallowed_positional_argument)]
#[help]
#[diag("positional format arguments are not allowed here")]
#[help(
"only named format arguments with the name of one of the generic types are allowed in this context"
)]
pub struct DisallowedPositionalArgument;

#[derive(LintDiagnostic)]
#[diag(trait_selection_invalid_format_specifier)]
#[help]
#[diag("invalid format specifier")]
#[help("no format specifier are supported in this position")]
pub struct InvalidFormatSpecifier;

#[derive(LintDiagnostic)]
#[diag(trait_selection_missing_options_for_on_unimplemented_attr)]
#[help]
#[diag("missing options for `on_unimplemented` attribute")]
#[help("at least one of the `message`, `note` and `label` options are expected")]
pub struct MissingOptionsForOnUnimplementedAttr;
}
Loading
Loading