Rollup merge of #137092 - RalfJung:abi_unsupported_vector_types-better-error, r=compiler-errors
abi_unsupported_vector_types: say which type is the problem
This commit is contained in:
commit
f10f0f09c8
13 changed files with 129 additions and 124 deletions
|
@ -1,17 +1,17 @@
|
|||
monomorphize_abi_error_disabled_vector_type_call =
|
||||
this function call uses a SIMD vector type that (with the chosen ABI) requires the `{$required_feature}` target feature, which is not enabled in the caller
|
||||
this function call uses SIMD vector type `{$ty}` which (with the chosen ABI) requires the `{$required_feature}` target feature, which is not enabled in the caller
|
||||
.label = function called here
|
||||
.help = consider enabling it globally (`-C target-feature=+{$required_feature}`) or locally (`#[target_feature(enable="{$required_feature}")]`)
|
||||
monomorphize_abi_error_disabled_vector_type_def =
|
||||
this function definition uses a SIMD vector type that (with the chosen ABI) requires the `{$required_feature}` target feature, which is not enabled
|
||||
this function definition uses SIMD vector type `{$ty}` which (with the chosen ABI) requires the `{$required_feature}` target feature, which is not enabled
|
||||
.label = function defined here
|
||||
.help = consider enabling it globally (`-C target-feature=+{$required_feature}`) or locally (`#[target_feature(enable="{$required_feature}")]`)
|
||||
|
||||
monomorphize_abi_error_unsupported_vector_type_call =
|
||||
this function call uses a SIMD vector type that is not currently supported with the chosen ABI
|
||||
this function call uses SIMD vector type `{$ty}` which is not currently supported with the chosen ABI
|
||||
.label = function called here
|
||||
monomorphize_abi_error_unsupported_vector_type_def =
|
||||
this function definition uses a SIMD vector type that is not currently supported with the chosen ABI
|
||||
this function definition uses SIMD vector type `{$ty}` which is not currently supported with the chosen ABI
|
||||
.label = function defined here
|
||||
|
||||
monomorphize_couldnt_dump_mono_stats =
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use rustc_macros::{Diagnostic, LintDiagnostic};
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_span::{Span, Symbol};
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
@ -75,6 +76,7 @@ pub(crate) struct AbiErrorDisabledVectorTypeDef<'a> {
|
|||
#[label]
|
||||
pub span: Span,
|
||||
pub required_feature: &'a str,
|
||||
pub ty: Ty<'a>,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
|
@ -84,18 +86,21 @@ pub(crate) struct AbiErrorDisabledVectorTypeCall<'a> {
|
|||
#[label]
|
||||
pub span: Span,
|
||||
pub required_feature: &'a str,
|
||||
pub ty: Ty<'a>,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(monomorphize_abi_error_unsupported_vector_type_def)]
|
||||
pub(crate) struct AbiErrorUnsupportedVectorTypeDef {
|
||||
pub(crate) struct AbiErrorUnsupportedVectorTypeDef<'a> {
|
||||
#[label]
|
||||
pub span: Span,
|
||||
pub ty: Ty<'a>,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(monomorphize_abi_error_unsupported_vector_type_call)]
|
||||
pub(crate) struct AbiErrorUnsupportedVectorTypeCall {
|
||||
pub(crate) struct AbiErrorUnsupportedVectorTypeCall<'a> {
|
||||
#[label]
|
||||
pub span: Span,
|
||||
pub ty: Ty<'a>,
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ fn do_check_abi<'tcx>(
|
|||
tcx: TyCtxt<'tcx>,
|
||||
abi: &FnAbi<'tcx, Ty<'tcx>>,
|
||||
target_feature_def: DefId,
|
||||
mut emit_err: impl FnMut(Option<&'static str>),
|
||||
mut emit_err: impl FnMut(Ty<'tcx>, Option<&'static str>),
|
||||
) {
|
||||
let feature_def = tcx.sess.target.features_for_correct_vector_abi();
|
||||
let codegen_attrs = tcx.codegen_fn_attrs(target_feature_def);
|
||||
|
@ -45,7 +45,7 @@ fn do_check_abi<'tcx>(
|
|||
let feature = match feature_def.iter().find(|(bits, _)| size.bits() <= *bits) {
|
||||
Some((_, feature)) => feature,
|
||||
None => {
|
||||
emit_err(None);
|
||||
emit_err(arg_abi.layout.ty, None);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
@ -53,7 +53,7 @@ fn do_check_abi<'tcx>(
|
|||
if !tcx.sess.unstable_target_features.contains(&feature_sym)
|
||||
&& !codegen_attrs.target_features.iter().any(|x| x.name == feature_sym)
|
||||
{
|
||||
emit_err(Some(&feature));
|
||||
emit_err(arg_abi.layout.ty, Some(&feature));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,21 +69,21 @@ fn check_instance_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) {
|
|||
// function.
|
||||
return;
|
||||
};
|
||||
do_check_abi(tcx, abi, instance.def_id(), |required_feature| {
|
||||
do_check_abi(tcx, abi, instance.def_id(), |ty, required_feature| {
|
||||
let span = tcx.def_span(instance.def_id());
|
||||
if let Some(required_feature) = required_feature {
|
||||
tcx.emit_node_span_lint(
|
||||
ABI_UNSUPPORTED_VECTOR_TYPES,
|
||||
CRATE_HIR_ID,
|
||||
span,
|
||||
AbiErrorDisabledVectorTypeDef { span, required_feature },
|
||||
AbiErrorDisabledVectorTypeDef { span, required_feature, ty },
|
||||
);
|
||||
} else {
|
||||
tcx.emit_node_span_lint(
|
||||
ABI_UNSUPPORTED_VECTOR_TYPES,
|
||||
CRATE_HIR_ID,
|
||||
span,
|
||||
AbiErrorUnsupportedVectorTypeDef { span },
|
||||
AbiErrorUnsupportedVectorTypeDef { span, ty },
|
||||
);
|
||||
}
|
||||
})
|
||||
|
@ -123,20 +123,20 @@ fn check_call_site_abi<'tcx>(
|
|||
// ABI failed to compute; this will not get through codegen.
|
||||
return;
|
||||
};
|
||||
do_check_abi(tcx, callee_abi, caller.def_id(), |required_feature| {
|
||||
do_check_abi(tcx, callee_abi, caller.def_id(), |ty, required_feature| {
|
||||
if let Some(required_feature) = required_feature {
|
||||
tcx.emit_node_span_lint(
|
||||
ABI_UNSUPPORTED_VECTOR_TYPES,
|
||||
CRATE_HIR_ID,
|
||||
span,
|
||||
AbiErrorDisabledVectorTypeCall { span, required_feature },
|
||||
AbiErrorDisabledVectorTypeCall { span, required_feature, ty },
|
||||
);
|
||||
} else {
|
||||
tcx.emit_node_span_lint(
|
||||
ABI_UNSUPPORTED_VECTOR_TYPES,
|
||||
CRATE_HIR_ID,
|
||||
span,
|
||||
AbiErrorUnsupportedVectorTypeCall { span },
|
||||
AbiErrorUnsupportedVectorTypeCall { span, ty },
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue