Explicitly mark a hack as a HACK and elaborate its comment

This commit is contained in:
León Orell Valerian Liehr 2024-09-18 19:30:20 +02:00
parent bd8e88fd7b
commit 682c5f485b
No known key found for this signature in database
GPG key ID: D17A07215F68E713
3 changed files with 20 additions and 17 deletions

View file

@ -1049,13 +1049,14 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
);
if span.is_empty() {
// Avoid ICE when types with the same name with `derive`s are in the same scope:
// struct NotSM;
// #[derive(PartialEq, Eq)]
// struct NotSM<T>(T);
// With the above code, the suggestion is to remove the generics of the first
// `NotSM`, which doesn't *have* generics, so we're suggesting to remove no code
// with no code, which ICEs on nightly due to an `assert!`.
// HACK: Avoid ICE when types with the same name with `derive`s are in the same scope:
// struct NotSM;
// #[derive(PartialEq, Eq)]
// struct NotSM<T>(T);
// With the above code, the suggestion would be to remove the generics of the first
// `NotSM`, which doesn't *have* generics, so we would suggest to remove no code with
// no code, which would trigger an `assert!` later. Ideally, we would do something a
// bit more principled. See closed PR #109082.
} else {
err.span_suggestion(span, msg, "", Applicability::MaybeIncorrect);
}