Skip to content

Commit 931c55f

Browse files
committed
Explicitly mark a hack as a HACK and elaborate its comment
1 parent bd8e88f commit 931c55f

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -1049,13 +1049,14 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
10491049
);
10501050

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

tests/ui/duplicate/multiple-types-with-same-name-and-derive.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// expansion these `impl`s are associated to the the *other* type. There is a suggestion to remove
33
// unneded type parameters, but because we're now point at a type with no type parameters, the
44
// suggestion would suggest removing code from an empty span, which would ICE in nightly.
5+
//
6+
// issue: rust-lang/rust#108748
57

68
struct NotSM;
79

0 commit comments

Comments
 (0)