-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revise never type fallback algorithm #88804
Commits on Sep 17, 2021
-
introduce new fallback algorithm
We now fallback type variables using the following rules: * Construct a coercion graph `A -> B` where `A` and `B` are unresolved type variables or the `!` type. * Let D be those variables that are reachable from `!`. * Let N be those variables that are reachable from a variable not in D. * All variables in (D \ N) fallback to `!`. * All variables in (D & N) fallback to `()`.
Configuration menu - View commit details
-
Copy full SHA for 2ee8914 - Browse repository at this point
Copy the full SHA 2ee8914View commit details -
remove diverging type variables from fn check
The comment seems incorrect. Testing revealed that the examples in question still work (as well as some variants) even without the special casing here.
Configuration menu - View commit details
-
Copy full SHA for ebb8ff9 - Browse repository at this point
Copy the full SHA ebb8ff9View commit details -
remove reliance on "diverging" type variables
Instead, we now record those type variables that are the target of a `NeverToAny` adjustment and consider those to be the "diverging" type variables. This allows us to remove the special case logic that creates a type variable for `!` in coercion.
Configuration menu - View commit details
-
Copy full SHA for 1c004f2 - Browse repository at this point
Copy the full SHA 1c004f2View commit details -
stop categorizing inference variables as diverging when created
Instead, we now rely on the code that looks for a NeverToAny adjustment.
Configuration menu - View commit details
-
Copy full SHA for bc2ece2 - Browse repository at this point
Copy the full SHA bc2ece2View commit details -
optimization: use a single DepthFirstSearch instead of hashsets
Extend the `DepthFirstSearch` iterator so that it can be re-used and extended with add'l start nodes. Then replace the FxHashSets of nodes we were using in the fallback analysis with a single iterator. This way we won't re-walk portions of the graph that are reached more than once, and we also do less allocation etc.
Configuration menu - View commit details
-
Copy full SHA for 59dc201 - Browse repository at this point
Copy the full SHA 59dc201View commit details -
Add another case of fallback to () avoid breakage
This adds src/test/ui/never_type/fallback-closure-ret.rs as a test case which showcases the failure mode fixed by this commit.
Configuration menu - View commit details
-
Copy full SHA for 078e3fd - Browse repository at this point
Copy the full SHA 078e3fdView commit details -
Configuration menu - View commit details
-
Copy full SHA for c4c5fc8 - Browse repository at this point
Copy the full SHA c4c5fc8View commit details