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

Change the return type of Ty::kind from &TyKind to TyKind. #126069

Closed
wants to merge 1 commit into from

Commits on Aug 14, 2024

  1. Change the return type of Ty::kind from &TyKind to TyKind.

    This is valid because `TyKind` impls `Copy`, and makes `Ty` consistent
    with `Predicate` and `Region`, both of which have `kind` methods that
    return a non-reference.
    
    The change removes more than one thousand `&` and `*` sigils, while
    requiring the addition of just five! It's clearly moving with the grain
    of the existing code.
    
    Almost all of the removed sigils fit one of the following three
    patterns.
    
    - Remove the dereference in the match expression:
    
        `match *ty.kind() { ... }` ->
        `match ty.kind() { ... }`
    
    - Remove the dereference in the match pattern:
    
        `match ty.kind() { &ty::Foo(foo) => { ... foo ... }` ->
        `match ty.kind() { ty::Foo(foo) => { ... foo ... }`
    
    - Remove the derefernce in the match arm:
    
        `match ty.kind() { ty::Foo(foo) => { ... *foo ... }` ->
        `match ty.kind() { ty::Foo(foo) => { ... foo ... }`
    
    A couple of other methods had their signatures changed.
    - `TypeErrCtxt::cmp_fn_sig`: `&` removed from two args.
    - `EncodableWithShorthand::variant`: `&` removed from return type.
    nnethercote committed Aug 14, 2024
    Configuration menu
    Copy the full SHA
    bd3667d View commit details
    Browse the repository at this point in the history