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

Default Type Parameter Fallback: Revival #46206

Closed

Commits on Nov 27, 2017

  1. Configuration menu
    Copy the full SHA
    7e8509f View commit details
    Browse the repository at this point in the history
  2. Refactor default type parameter fallback

    The previous implementation was not very clear, this commit attempts to clarify and clean up the code that
    applies all defaults.
    jroesch authored and leoyvens committed Nov 27, 2017
    Configuration menu
    Copy the full SHA
    f20a4d8 View commit details
    Browse the repository at this point in the history
  3. Address nits and add assertation

    jroesch authored and leoyvens committed Nov 27, 2017
    Configuration menu
    Copy the full SHA
    9b07e1b View commit details
    Browse the repository at this point in the history
  4. Fix tidy

    jroesch authored and leoyvens committed Nov 27, 2017
    Configuration menu
    Copy the full SHA
    b29ba68 View commit details
    Browse the repository at this point in the history
  5. Ensure defaults are normalized after application

    Thanks to @eddyb for bringing this bug to my attention.
    jroesch authored and leoyvens committed Nov 27, 2017
    Configuration menu
    Copy the full SHA
    233397e View commit details
    Browse the repository at this point in the history
  6. Address nits and fix tidy ... again

    jroesch authored and leoyvens committed Nov 27, 2017
    Configuration menu
    Copy the full SHA
    bff6d6b View commit details
    Browse the repository at this point in the history
  7. Rebase fixes

    jroesch authored and leoyvens committed Nov 27, 2017
    Configuration menu
    Copy the full SHA
    28609d5 View commit details
    Browse the repository at this point in the history
  8. wip

    nikomatsakis authored and leoyvens committed Nov 27, 2017
    Configuration menu
    Copy the full SHA
    978bbca View commit details
    Browse the repository at this point in the history
  9. Manually merge moved files

    infer/mod.rs, infer/type_variable.rs and error.rs were manually rebased
    due to being moved from librustc/middle/infer/ to librustc/infer
    leoyvens committed Nov 27, 2017
    Configuration menu
    Copy the full SHA
    f279dd6 View commit details
    Browse the repository at this point in the history
  10. Fix rebase of default-type-param-fallback branch

    Had screwed up the rebase of `check/mod.rs`. The error handling code is
    commented out because I don't know how to rebase it.
    leoyvens committed Nov 27, 2017
    Configuration menu
    Copy the full SHA
    d4654b1 View commit details
    Browse the repository at this point in the history
  11. trying stuff out

    leoyvens committed Nov 27, 2017
    Configuration menu
    Copy the full SHA
    ad30796 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    e1ef324 View commit details
    Browse the repository at this point in the history
  13. Combine propagates defaults.

    leoyvens committed Nov 27, 2017
    Configuration menu
    Copy the full SHA
    b9e9f0f View commit details
    Browse the repository at this point in the history
  14. Conservative default type param fallback.

    User fallbacks are applied as a last ditch attempt at inference.
    If a type variable could gain a fallback in the future, it may not
    unify with anything, for future-proofing. This means adding a default
    is always backwards-compatible.
    Check `apply_user_type_parameter_fallback` for the algorithm.
    leoyvens committed Nov 27, 2017
    Configuration menu
    Copy the full SHA
    ce861ae View commit details
    Browse the repository at this point in the history
  15. Fix regression on diverging fallback, remove old user fallback implem…

    …entation.
    
    Regression fixed by reverting from rebased version to
    `default_type_parameters` in master.
    Renamed it to `apply_diverging_and_numeric_type_parameter_fallback`.
    Removed the previous algorithm for user fallback.
    leoyvens committed Nov 27, 2017
    Configuration menu
    Copy the full SHA
    8b44ca5 View commit details
    Browse the repository at this point in the history
  16. Give priority to defaults in fns and impls over defaults in types.

    The origin of the type parameter had to be plumbed down to typeck,
    maybe there is a better way to do it?
    leoyvens committed Nov 27, 2017
    Configuration menu
    Copy the full SHA
    9239233 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    9a98d23 View commit details
    Browse the repository at this point in the history
  18. Remove default data from TypeVariableValue::Bounded.

    We use the default information in TypeVariableData. Also improved some
    comments.
    leoyvens committed Nov 27, 2017
    Configuration menu
    Copy the full SHA
    ced2600 View commit details
    Browse the repository at this point in the history
  19. Fix rebase conflict

    leoyvens committed Nov 27, 2017
    Configuration menu
    Copy the full SHA
    f27f976 View commit details
    Browse the repository at this point in the history
  20. Set OriginOfTyParam for methods.

    Fixes bug with default fallback, and small refactorings to default
    fallback.
    leoyvens committed Nov 27, 2017
    Configuration menu
    Copy the full SHA
    bdda07b View commit details
    Browse the repository at this point in the history
  21. Run pass tests.

    The happy kind of test.
    leoyvens committed Nov 27, 2017
    Configuration menu
    Copy the full SHA
    3857826 View commit details
    Browse the repository at this point in the history
  22. Tests for default fallback: ui tests, run fail test, more run pass te…

    …sts.
    
    The tests under bad_messages in ui are the ones that have bad messages
    that need fixing.
    leoyvens committed Nov 27, 2017
    Configuration menu
    Copy the full SHA
    5362bbe View commit details
    Browse the repository at this point in the history
  23. Adjust fallback algorithm.

    We only demand equality when we are sure now, fixing bad error
    messages. We also skip a priority level if we detect a conflict, an
    improvement over the previous algorithm. But there is a bug related to
    normalizing dependent defaults, see FIXME.
    leoyvens committed Nov 27, 2017
    Configuration menu
    Copy the full SHA
    0bd87ef View commit details
    Browse the repository at this point in the history
  24. Get normalization of dependent defaults right.

    Since this means there are cross-bag dependencies, we use a fixed point
    algorithm, looping over the bags until we can no longer solve any of
    them.
    leoyvens committed Nov 27, 2017
    Configuration menu
    Copy the full SHA
    babfa76 View commit details
    Browse the repository at this point in the history
  25. Fallback: Don't skip conflicting defaults.

    While this was future-proof wrt API evolution, it is not future proof
    wrt to compiler evolution, such as making priority levels more
    fine-grained or just fixing bugs. It's a not very useful behavior and a
    complexity this feature doesn't need.
    
    Refactored the fallback algorithm to be simpler.
    
    Just fails on conflicting defaults.
    leoyvens committed Nov 27, 2017
    Configuration menu
    Copy the full SHA
    14a9420 View commit details
    Browse the repository at this point in the history
  26. Fallback: Stop relying on sty equality, use rollbacks.

    I tried preventing having to rollback inference and being clever with
    sty equality, but dependent defaults means we need full inference here.
    
    All application of defaults goes in the same transaction, again because
    of dependent defaults. We can't mess with the fulfillment context in a
    snapshot, so we clone our own fulfillment context.
    
    The downside is that if we fail one bag we fail all, which can be very
    confusing as the user may be presented with several errors when only
    one of them is the "real one".
    
    This is not so bad because we may easily have a heuristic that solves
    the bags that can be solved in isolation and then puts the complicated
    cases in a single transaction, making the pathological situation quite
    rare.
    leoyvens committed Nov 27, 2017
    Configuration menu
    Copy the full SHA
    423de71 View commit details
    Browse the repository at this point in the history
  27. Refactor tests.

    Make test more focused, and clarify what the bug is. Add new ui test.
    leoyvens committed Nov 27, 2017
    Configuration menu
    Copy the full SHA
    91da0cc View commit details
    Browse the repository at this point in the history

Commits on Nov 28, 2017

  1. Configuration menu
    Copy the full SHA
    da4dcad View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    90a42a8 View commit details
    Browse the repository at this point in the history

Commits on Nov 29, 2017

  1. Test that trait definition owns the default, not the impl.

    I don't know if it's what we want but it's how it works now. If we want
    to keep it then we should forbid writing the default in the impl.
    leoyvens committed Nov 29, 2017
    Configuration menu
    Copy the full SHA
    d84f3ed View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    4753319 View commit details
    Browse the repository at this point in the history
  3. Fix "associated type not found" when using associated type in default.

    Makes associated types in defaults less verbose.
    leoyvens committed Nov 29, 2017
    Configuration menu
    Copy the full SHA
    bad548a View commit details
    Browse the repository at this point in the history

Commits on Nov 30, 2017

  1. Propagate defaults in fudge

    If you propagate the origin, you propagate the default. Fixes fallback
    for field access.
    
    Also small refactoring in combine.
    leoyvens committed Nov 30, 2017
    Configuration menu
    Copy the full SHA
    5c28224 View commit details
    Browse the repository at this point in the history
  2. Use fallbacks to avoid "the type of this value must be known in this …

    …context"
    
    Try fallback right in `structurally_resolve_type_or_else` right before
    we hit "the type of this value must be known in this context".
    
    This gets casts working, and probably other things not tested for.
    
    Also remove some dead code.
    leoyvens committed Nov 30, 2017
    Configuration menu
    Copy the full SHA
    973f782 View commit details
    Browse the repository at this point in the history
  3. Fix fallback for _ placeholders.

    It seems we have pretty much the same logic in three different places,
    so it was fixed in three different places. Took the opportunity to
    leave FIXMEs regarding elision of defaulted params.
    leoyvens committed Nov 30, 2017
    Configuration menu
    Copy the full SHA
    06e7456 View commit details
    Browse the repository at this point in the history