Skip to content

abi_unsupported_vector_types: say which type is the problem #137092

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
8 changes: 4 additions & 4 deletions compiler/rustc_monomorphize/messages.ftl
Original file line number Diff line number Diff line change
@@ -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 =
Expand Down
9 changes: 7 additions & 2 deletions compiler/rustc_monomorphize/src/errors.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down Expand Up @@ -75,6 +76,7 @@ pub(crate) struct AbiErrorDisabledVectorTypeDef<'a> {
#[label]
pub span: Span,
pub required_feature: &'a str,
pub ty: Ty<'a>,
}

#[derive(LintDiagnostic)]
Expand All @@ -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>,
}
18 changes: 9 additions & 9 deletions compiler/rustc_monomorphize/src/mono_checks/abi_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -45,15 +45,15 @@ 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;
}
};
let feature_sym = Symbol::intern(feature);
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));
}
}
}
Expand All @@ -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 },
);
}
})
Expand Down Expand Up @@ -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 },
);
}
});
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/simd-abi-checks-empty-list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ trait Copy {}
pub struct SimdVec([i32; 4]);

pub extern "C" fn pass_by_vec(_: SimdVec) {}
//~^ this function definition uses a SIMD vector type that is not currently supported with the chosen ABI
//~^ this function definition uses SIMD vector type `SimdVec` which is not currently supported with the chosen ABI
//~| WARNING this was previously accepted by the compiler
4 changes: 2 additions & 2 deletions tests/ui/simd-abi-checks-empty-list.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
warning: this function definition uses a SIMD vector type that is not currently supported with the chosen ABI
warning: this function definition uses SIMD vector type `SimdVec` which is not currently supported with the chosen ABI
--> $DIR/simd-abi-checks-empty-list.rs:17:1
|
LL | pub extern "C" fn pass_by_vec(_: SimdVec) {}
Expand All @@ -11,7 +11,7 @@ LL | pub extern "C" fn pass_by_vec(_: SimdVec) {}
warning: 1 warning emitted

Future incompatibility report: Future breakage diagnostic:
warning: this function definition uses a SIMD vector type that is not currently supported with the chosen ABI
warning: this function definition uses SIMD vector type `SimdVec` which is not currently supported with the chosen ABI
--> $DIR/simd-abi-checks-empty-list.rs:17:1
|
LL | pub extern "C" fn pass_by_vec(_: SimdVec) {}
Expand Down
20 changes: 10 additions & 10 deletions tests/ui/simd-abi-checks-s390x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ impl<T: Copy> Copy for TransparentWrapper<T> {}

#[no_mangle]
extern "C" fn vector_ret_small(x: &i8x8) -> i8x8 {
//~^ ERROR this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled
//~^ ERROR requires the `vector` target feature, which is not enabled
//~^^ WARN this was previously accepted
*x
}
#[no_mangle]
extern "C" fn vector_ret(x: &i8x16) -> i8x16 {
//~^ ERROR this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled
//~^ ERROR requires the `vector` target feature, which is not enabled
//~^^ WARN this was previously accepted
*x
}
Expand Down Expand Up @@ -99,15 +99,15 @@ extern "C" fn vector_wrapper_ret_large(x: &Wrapper<i8x32>) -> Wrapper<i8x32> {
extern "C" fn vector_transparent_wrapper_ret_small(
x: &TransparentWrapper<i8x8>,
) -> TransparentWrapper<i8x8> {
//~^^^ ERROR this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled
//~^^^ ERROR requires the `vector` target feature, which is not enabled
//~^^^^ WARN this was previously accepted
*x
}
#[no_mangle]
extern "C" fn vector_transparent_wrapper_ret(
x: &TransparentWrapper<i8x16>,
) -> TransparentWrapper<i8x16> {
//~^^^ ERROR this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled
//~^^^ ERROR requires the `vector` target feature, which is not enabled
//~^^^^ WARN this was previously accepted
*x
}
Expand All @@ -121,13 +121,13 @@ extern "C" fn vector_transparent_wrapper_ret_large(

#[no_mangle]
extern "C" fn vector_arg_small(x: i8x8) -> i64 {
//~^ ERROR this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled
//~^ ERROR requires the `vector` target feature, which is not enabled
//~^^ WARN this was previously accepted
unsafe { *(&x as *const i8x8 as *const i64) }
}
#[no_mangle]
extern "C" fn vector_arg(x: i8x16) -> i64 {
//~^ ERROR this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled
//~^ ERROR requires the `vector` target feature, which is not enabled
//~^^ WARN this was previously accepted
unsafe { *(&x as *const i8x16 as *const i64) }
}
Expand All @@ -139,13 +139,13 @@ extern "C" fn vector_arg_large(x: i8x32) -> i64 {

#[no_mangle]
extern "C" fn vector_wrapper_arg_small(x: Wrapper<i8x8>) -> i64 {
//~^ ERROR this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled
//~^ ERROR requires the `vector` target feature, which is not enabled
//~^^ WARN this was previously accepted
unsafe { *(&x as *const Wrapper<i8x8> as *const i64) }
}
#[no_mangle]
extern "C" fn vector_wrapper_arg(x: Wrapper<i8x16>) -> i64 {
//~^ ERROR this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled
//~^ ERROR requires the `vector` target feature, which is not enabled
//~^^ WARN this was previously accepted
unsafe { *(&x as *const Wrapper<i8x16> as *const i64) }
}
Expand All @@ -157,13 +157,13 @@ extern "C" fn vector_wrapper_arg_large(x: Wrapper<i8x32>) -> i64 {

#[no_mangle]
extern "C" fn vector_transparent_wrapper_arg_small(x: TransparentWrapper<i8x8>) -> i64 {
//~^ ERROR this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled
//~^ ERROR requires the `vector` target feature, which is not enabled
//~^^ WARN this was previously accepted
unsafe { *(&x as *const TransparentWrapper<i8x8> as *const i64) }
}
#[no_mangle]
extern "C" fn vector_transparent_wrapper_arg(x: TransparentWrapper<i8x16>) -> i64 {
//~^ ERROR this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled
//~^ ERROR requires the `vector` target feature, which is not enabled
//~^^ WARN this was previously accepted
unsafe { *(&x as *const TransparentWrapper<i8x16> as *const i64) }
}
Expand Down
Loading
Loading