fix overly-aggressive pruning of types based on features #1958
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.
Previously,
ast::Resolvewould sometimes assign aStabilityto types according to the first function it found that type in as a parameter or result. That's a problem if such a function is marked@unstable, since it will effectively poison that type and prevent it from being used by any other function -- even if the type itself is ungated.This fixes the problem by removing the
&Stabilityparameter fromresolve_paramsandresolve_resultsand instead passing&Stability::Unknowntoresolve_typefrom those functions. Additionally, I've added a newfind_stabilityfunction which recursively inspects a&TypeDefKind, looking for a non-unknown stability. If it finds one, it will use that; otherwise, it will default toStability::Unknown.For example, if
option<T>appears as a parameter type in a function, we'll start by assuming that type has unknown stability, then look to see ifThas a stability (directly or transitively) and use that if so. Things get interesting in the case of e.g.tuple<T, U, V>, whereT,U, andVeach have their own stability. Currently we just use the first known stability we find, but perhaps there's a better approach to consider?