2022-08-25 15:42:20 +02:00
|
|
|
use rustc_errors::fluent;
|
2022-08-25 15:34:30 +02:00
|
|
|
use rustc_errors::DiagnosticBuilder;
|
|
|
|
use rustc_session::SessionDiagnostic;
|
|
|
|
|
2022-08-25 18:36:15 +02:00
|
|
|
pub(crate) enum UnknownCTargetFeature<'a> {
|
|
|
|
UnknownFeaturePrefix { feature: &'a str },
|
|
|
|
UnknownFeature { feature: &'a str, rust_feature: Option<&'a str> },
|
2022-08-25 15:34:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
impl SessionDiagnostic<'_, ()> for UnknownCTargetFeature {
|
2022-08-25 15:42:20 +02:00
|
|
|
fn into_diagnostic(
|
|
|
|
self,
|
|
|
|
sess: &'_ rustc_session::parse::ParseSess,
|
|
|
|
) -> DiagnosticBuilder<'_, ()> {
|
2022-08-25 15:34:30 +02:00
|
|
|
match self {
|
|
|
|
UnknownCTargetFeature::UnknownFeaturePrefix { feature } => {
|
|
|
|
let mut diag = sess.struct_warn(fluent::codegen_llvm::unknown_ctarget_feature);
|
|
|
|
diag.set_arg("feature", feature);
|
|
|
|
diag.note(fluent::codegen_llvm::unknown_feature_prefix);
|
|
|
|
diag
|
|
|
|
}
|
|
|
|
UnknownCTargetFeature::UnknownFeature { feature, rust_feature } => {
|
|
|
|
let mut diag = sess.struct_warn(fluent::codegen_llvm::unknown_ctarget_feature);
|
|
|
|
diag.set_arg("feature", feature);
|
|
|
|
diag.note(fluent::codegen_llvm::unknown_feature);
|
|
|
|
if let Some(rust_feature) = rust_feature {
|
|
|
|
diag.help(fluent::codegen_llvm::rust_feature);
|
|
|
|
diag.set_arg("rust_feature", rust_feature);
|
|
|
|
} else {
|
|
|
|
diag.note(fluent::codegen_llvm::unknown_feature_fill_request);
|
|
|
|
}
|
|
|
|
diag
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-08-25 15:42:20 +02:00
|
|
|
}
|