Skip to content

Commit ae4c6b6

Browse files
committedOct 26, 2024
Auto merge of #132152 - lqd:revert-127731, r=compiler-errors
Revert #127731 "Emit error when calling/declaring functions with unavailable …" This reverts #127731 due to the unexpected [perf regressions](#127731 (comment)) and to give time to mitigate the regressions before re-landing it. r? `@RalfJung` cc `@veluca93`
2 parents a06b7cb + bd8477b commit ae4c6b6

16 files changed

+53
-448
lines changed
 

‎compiler/rustc_lint_defs/src/builtin.rs

-67
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ declare_lint_pass! {
1616
/// that are used by other parts of the compiler.
1717
HardwiredLints => [
1818
// tidy-alphabetical-start
19-
ABI_UNSUPPORTED_VECTOR_TYPES,
2019
ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
2120
AMBIGUOUS_ASSOCIATED_ITEMS,
2221
AMBIGUOUS_GLOB_IMPORTS,
@@ -5029,69 +5028,3 @@ declare_lint! {
50295028
};
50305029
crate_level_only
50315030
}
5032-
5033-
declare_lint! {
5034-
/// The `abi_unsupported_vector_types` lint detects function definitions and calls
5035-
/// whose ABI depends on enabling certain target features, but those features are not enabled.
5036-
///
5037-
/// ### Example
5038-
///
5039-
/// ```rust,ignore (fails on non-x86_64)
5040-
/// extern "C" fn missing_target_feature(_: std::arch::x86_64::__m256) {
5041-
/// todo!()
5042-
/// }
5043-
///
5044-
/// #[target_feature(enable = "avx")]
5045-
/// unsafe extern "C" fn with_target_feature(_: std::arch::x86_64::__m256) {
5046-
/// todo!()
5047-
/// }
5048-
///
5049-
/// fn main() {
5050-
/// let v = unsafe { std::mem::zeroed() };
5051-
/// unsafe { with_target_feature(v); }
5052-
/// }
5053-
/// ```
5054-
///
5055-
/// ```text
5056-
/// warning: ABI error: this function call uses a avx vector type, which is not enabled in the caller
5057-
/// --> lint_example.rs:18:12
5058-
/// |
5059-
/// | unsafe { with_target_feature(v); }
5060-
/// | ^^^^^^^^^^^^^^^^^^^^^^ function called here
5061-
/// |
5062-
/// = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
5063-
/// = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558>
5064-
/// = help: consider enabling it globally (-C target-feature=+avx) or locally (#[target_feature(enable="avx")])
5065-
/// = note: `#[warn(abi_unsupported_vector_types)]` on by default
5066-
///
5067-
///
5068-
/// warning: ABI error: this function definition uses a avx vector type, which is not enabled
5069-
/// --> lint_example.rs:3:1
5070-
/// |
5071-
/// | pub extern "C" fn with_target_feature(_: std::arch::x86_64::__m256) {
5072-
/// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here
5073-
/// |
5074-
/// = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
5075-
/// = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558>
5076-
/// = help: consider enabling it globally (-C target-feature=+avx) or locally (#[target_feature(enable="avx")])
5077-
/// ```
5078-
///
5079-
///
5080-
///
5081-
/// ### Explanation
5082-
///
5083-
/// The C ABI for `__m256` requires the value to be passed in an AVX register,
5084-
/// which is only possible when the `avx` target feature is enabled.
5085-
/// Therefore, `missing_target_feature` cannot be compiled without that target feature.
5086-
/// A similar (but complementary) message is triggered when `with_target_feature` is called
5087-
/// by a function that does not enable the `avx` target feature.
5088-
///
5089-
/// Note that this lint is very similar to the `-Wpsabi` warning in `gcc`/`clang`.
5090-
pub ABI_UNSUPPORTED_VECTOR_TYPES,
5091-
Warn,
5092-
"this function call or definition uses a vector type which is not enabled",
5093-
@future_incompatible = FutureIncompatibleInfo {
5094-
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
5095-
reference: "issue #116558 <https://github.com/rust-lang/rust/issues/116558>",
5096-
};
5097-
}

‎compiler/rustc_monomorphize/messages.ftl

-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
monomorphize_abi_error_disabled_vector_type_call =
2-
ABI error: this function call uses a vector type that requires the `{$required_feature}` target feature, which is not enabled in the caller
3-
.label = function called here
4-
.help = consider enabling it globally (`-C target-feature=+{$required_feature}`) or locally (`#[target_feature(enable="{$required_feature}")]`)
5-
monomorphize_abi_error_disabled_vector_type_def =
6-
ABI error: this function definition uses a vector type that requires the `{$required_feature}` target feature, which is not enabled
7-
.label = function defined here
8-
.help = consider enabling it globally (`-C target-feature=+{$required_feature}`) or locally (`#[target_feature(enable="{$required_feature}")]`)
9-
101
monomorphize_couldnt_dump_mono_stats =
112
unexpected error occurred while dumping monomorphization stats: {$error}
123

‎compiler/rustc_monomorphize/src/collector.rs

-5
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@
205205
//! this is not implemented however: a mono item will be produced
206206
//! regardless of whether it is actually needed or not.
207207
208-
mod abi_check;
209208
mod move_check;
210209

211210
use std::path::PathBuf;
@@ -767,7 +766,6 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> {
767766
self.used_mentioned_items.insert(MentionedItem::Fn(callee_ty));
768767
let callee_ty = self.monomorphize(callee_ty);
769768
self.check_fn_args_move_size(callee_ty, args, *fn_span, location);
770-
abi_check::check_call_site_abi(tcx, callee_ty, *fn_span, self.body.source.instance);
771769
visit_fn_use(self.tcx, callee_ty, true, source, &mut self.used_items)
772770
}
773771
mir::TerminatorKind::Drop { ref place, .. } => {
@@ -1209,9 +1207,6 @@ fn collect_items_of_instance<'tcx>(
12091207
mentioned_items: &mut MonoItems<'tcx>,
12101208
mode: CollectionMode,
12111209
) {
1212-
// Check the instance for feature-dependent ABI.
1213-
abi_check::check_instance_abi(tcx, instance);
1214-
12151210
let body = tcx.instance_mir(instance.def);
12161211
// Naively, in "used" collection mode, all functions get added to *both* `used_items` and
12171212
// `mentioned_items`. Mentioned items processing will then notice that they have already been

‎compiler/rustc_monomorphize/src/collector/abi_check.rs

-111
This file was deleted.

‎compiler/rustc_monomorphize/src/errors.rs

-18
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,3 @@ pub(crate) struct StartNotFound;
9292
pub(crate) struct UnknownCguCollectionMode<'a> {
9393
pub mode: &'a str,
9494
}
95-
96-
#[derive(LintDiagnostic)]
97-
#[diag(monomorphize_abi_error_disabled_vector_type_def)]
98-
#[help]
99-
pub(crate) struct AbiErrorDisabledVectorTypeDef<'a> {
100-
#[label]
101-
pub span: Span,
102-
pub required_feature: &'a str,
103-
}
104-
105-
#[derive(LintDiagnostic)]
106-
#[diag(monomorphize_abi_error_disabled_vector_type_call)]
107-
#[help]
108-
pub(crate) struct AbiErrorDisabledVectorTypeCall<'a> {
109-
#[label]
110-
pub span: Span,
111-
pub required_feature: &'a str,
112-
}

‎compiler/rustc_target/src/target_features.rs

-17
Original file line numberDiff line numberDiff line change
@@ -522,13 +522,6 @@ pub fn all_known_features() -> impl Iterator<Item = (&'static str, Stability)> {
522522
.map(|(f, s, _)| (f, s))
523523
}
524524

525-
// These arrays represent the least-constraining feature that is required for vector types up to a
526-
// certain size to have their "proper" ABI on each architecture.
527-
// Note that they must be kept sorted by vector size.
528-
const X86_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] =
529-
&[(128, "sse"), (256, "avx"), (512, "avx512f")];
530-
const AARCH64_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] = &[(128, "neon")];
531-
532525
impl super::spec::Target {
533526
pub fn supported_target_features(
534527
&self,
@@ -550,16 +543,6 @@ impl super::spec::Target {
550543
}
551544
}
552545

553-
// Returns None if we do not support ABI checks on the given target yet.
554-
pub fn features_for_correct_vector_abi(&self) -> Option<&'static [(u64, &'static str)]> {
555-
match &*self.arch {
556-
"x86" | "x86_64" => Some(X86_FEATURES_FOR_CORRECT_VECTOR_ABI),
557-
"aarch64" => Some(AARCH64_FEATURES_FOR_CORRECT_VECTOR_ABI),
558-
// FIXME: add support for non-tier1 architectures
559-
_ => None,
560-
}
561-
}
562-
563546
pub fn tied_target_features(&self) -> &'static [&'static [&'static str]] {
564547
match &*self.arch {
565548
"aarch64" | "arm64ec" => AARCH64_TIED_FEATURES,

‎tests/crashes/131342-2.rs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//@ known-bug: #131342
2+
// see also: 131342.rs
3+
4+
fn main() {
5+
problem_thingy(Once);
6+
}
7+
8+
struct Once;
9+
10+
impl Iterator for Once {
11+
type Item = ();
12+
}
13+
14+
fn problem_thingy(items: impl Iterator) {
15+
let peeker = items.peekable();
16+
problem_thingy(&peeker);
17+
}
18+
19+
trait Iterator {
20+
type Item;
21+
22+
fn peekable(self) -> Peekable<Self>
23+
where
24+
Self: Sized,
25+
{
26+
loop {}
27+
}
28+
}
29+
30+
struct Peekable<I: Iterator> {
31+
_peeked: I::Item,
32+
}
33+
34+
impl<I: Iterator> Iterator for Peekable<I> {
35+
type Item = I::Item;
36+
}
37+
38+
impl<I: Iterator + ?Sized> Iterator for &I {
39+
type Item = I::Item;
40+
}

‎tests/crashes/131342.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ known-bug: #131342
2+
// see also: 131342-2.rs
23

34
fn main() {
45
let mut items = vec![1, 2, 3, 4, 5].into_iter();

‎tests/ui/layout/post-mono-layout-cycle-2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ where
4545
T: Blah,
4646
{
4747
async fn ice(&mut self) {
48+
//~^ ERROR a cycle occurred during layout computation
4849
let arr: [(); 0] = [];
4950
self.t.iter(arr.into_iter()).await;
5051
}

‎tests/ui/layout/post-mono-layout-cycle-2.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ LL | Blah::iter(self, iterator).await
1212
|
1313
= note: a recursive `async fn` call must introduce indirection such as `Box::pin` to avoid an infinitely sized future
1414

15-
note: the above error was encountered while instantiating `fn main::{closure#0}`
16-
--> $DIR/post-mono-layout-cycle-2.rs:16:15
15+
error: a cycle occurred during layout computation
16+
--> $DIR/post-mono-layout-cycle-2.rs:47:5
1717
|
18-
LL | match fut.as_mut().poll(ctx) {
19-
| ^^^^^^^^^^^^^^^^^^^^^^
18+
LL | async fn ice(&mut self) {
19+
| ^^^^^^^^^^^^^^^^^^^^^^^
2020

21-
error: aborting due to 1 previous error
21+
error: aborting due to 2 previous errors
2222

2323
For more information about this error, try `rustc --explain E0733`.

‎tests/ui/layout/post-mono-layout-cycle.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ struct Wrapper<T: Trait> {
1414
}
1515

1616
fn abi<T: Trait>(_: Option<Wrapper<T>>) {}
17+
//~^ ERROR a cycle occurred during layout computation
1718

1819
fn indirect<T: Trait>() {
1920
abi::<T>(None);

‎tests/ui/layout/post-mono-layout-cycle.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ error[E0391]: cycle detected when computing layout of `Wrapper<()>`
55
= note: cycle used when computing layout of `core::option::Option<Wrapper<()>>`
66
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
77

8-
note: the above error was encountered while instantiating `fn indirect::<()>`
9-
--> $DIR/post-mono-layout-cycle.rs:23:5
8+
error: a cycle occurred during layout computation
9+
--> $DIR/post-mono-layout-cycle.rs:16:1
1010
|
11-
LL | indirect::<()>();
12-
| ^^^^^^^^^^^^^^^^
11+
LL | fn abi<T: Trait>(_: Option<Wrapper<T>>) {}
12+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1313

14-
error: aborting due to 1 previous error
14+
error: aborting due to 2 previous errors
1515

1616
For more information about this error, try `rustc --explain E0391`.

‎tests/ui/simd-abi-checks.rs

-81
This file was deleted.

‎tests/ui/simd-abi-checks.stderr

-93
This file was deleted.

‎tests/ui/sse-abi-checks.rs

-24
This file was deleted.

‎tests/ui/sse-abi-checks.stderr

-13
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.