Skip to content

Commit

Permalink
Explicitly mark a hack as a HACK and elaborate its comment
Browse files Browse the repository at this point in the history
  • Loading branch information
fmease committed Sep 18, 2024
1 parent bd8e88f commit 931c55f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// expansion these `impl`s are associated to the the *other* type. There is a suggestion to remove
// unneded type parameters, but because we're now point at a type with no type parameters, the
// suggestion would suggest removing code from an empty span, which would ICE in nightly.
//
// issue: rust-lang/rust#108748

struct NotSM;

Expand Down

0 comments on commit 931c55f

Please sign in to comment.