Avoid case of a self-referential type alias. #2109
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This previously produced a type alias which referred to itself,
which was clearly wrong and resulted in downstream code recursing
infinitely.
The problem case (per bug #2102) is:
As far as I can tell, we parse clang's definition of
B<A>
; that leadsus to parse A; to find it has a field U which turns out to be of type
B<A>
. And so we hit the line in item.rs which says:and bail out, returning the original item ID: hence, a self-
referential typedef is created.
The 'fix' in this PR creates an opaque type in this case instead,
to avoid later infinite loops. It would be preferable to avoid this
situation in the first place, but presumably that would require
us to split the parsing phase into two:
Fixes #2102 (partially).