Skip to content
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

conditional fallback for the ! type #79366

Commits on Nov 19, 2020

  1. Configuration menu
    Copy the full SHA
    1cbde85 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    0005746 View commit details
    Browse the repository at this point in the history

Commits on Nov 20, 2020

  1. Configuration menu
    Copy the full SHA
    d8a881b View commit details
    Browse the repository at this point in the history
  2. shallow resolve target type in coercion

    We used to avoid doing this because we didn't want to make coercion depend on
    the state of inference. For better or worse, we have moved away from this
    position over time. Therefore, I am going to go ahead and resolve the `b`
    target type early on so that it is done uniformly.
    
    (The older technique for managing this was always something of a hack
    regardless; if we really wanted to avoid integrating coercion and inference we
    needed to be more disciplined about it.)
    nikomatsakis committed Nov 20, 2020
    Configuration menu
    Copy the full SHA
    00786cf View commit details
    Browse the repository at this point in the history

Commits on Nov 21, 2020

  1. Configuration menu
    Copy the full SHA
    b3f8d74 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    448eb37 View commit details
    Browse the repository at this point in the history
  3. move the sub-unify check and extend the documentation a bit

    I didn't like the sub-unify code executing when a predicate was
    ENQUEUED, that felt fragile. I would have preferred to move the
    sub-unify code so that it only occurred during generalization, but
    that impacted diagnostics, so having it also occur when we process
    subtype predicates felt pretty reasonable. (I guess we only need one
    or the other, but I kind of prefer both, since the generalizer
    ultimately feels like the *right* place to guarantee the properties we
    want.)
    nikomatsakis committed Nov 21, 2020
    Configuration menu
    Copy the full SHA
    b37daab View commit details
    Browse the repository at this point in the history

Commits on Nov 23, 2020

  1. create Coercion obligations given 2 unbound type variables

    Motivation: in upcoming commits, we are going to create a graph of the
    coercion relationships between variables. We want to
    distinguish *coercion* specifically from other sorts of subtyping, as
    it indicates values flowing from one place to another via assignment.
    nikomatsakis committed Nov 23, 2020
    Configuration menu
    Copy the full SHA
    a4f357d View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    de3bf35 View commit details
    Browse the repository at this point in the history
  3. move fallback_if_possible and friends to fallback.rs

    Along the way, simplify and document the logic more clearly.
    nikomatsakis committed Nov 23, 2020
    Configuration menu
    Copy the full SHA
    73b743b View commit details
    Browse the repository at this point in the history
  4. 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 `()`.
    nikomatsakis committed Nov 23, 2020
    Configuration menu
    Copy the full SHA
    694d3c8 View commit details
    Browse the repository at this point in the history
  5. 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.
    nikomatsakis committed Nov 23, 2020
    Configuration menu
    Copy the full SHA
    8eda90e View commit details
    Browse the repository at this point in the history
  6. 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.
    nikomatsakis committed Nov 23, 2020
    Configuration menu
    Copy the full SHA
    fceb523 View commit details
    Browse the repository at this point in the history
  7. stop categorizing inference variables as diverging when created

    Instead, we now rely on the code that looks for a NeverToAny adjustment.
    nikomatsakis committed Nov 23, 2020
    Configuration menu
    Copy the full SHA
    fc02f0f View commit details
    Browse the repository at this point in the history
  8. fix bug in DepthFirstSearch where start node was not visited

    This could cause us to visit the start node twice.
    nikomatsakis committed Nov 23, 2020
    Configuration menu
    Copy the full SHA
    128de40 View commit details
    Browse the repository at this point in the history
  9. 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.
    nikomatsakis committed Nov 23, 2020
    Configuration menu
    Copy the full SHA
    4157667 View commit details
    Browse the repository at this point in the history