Skip to content

Resolve names during stubbing #1866

Description

@aaronbembenek-aws

This issue affects how we treat the function/method names supplied in kani::stub(<original>, <replacement>) attributes. We currently treat <original> and <replacement> verbatim as strings, so that they have to exactly match a name we find in the HIR. This means that we are unable to find many functions/methods in foreign crates, that we do not support relative paths, and that we are unable to take into account use ... as ... statements.

We should instead correctly resolve names during stubbing, as well as support path constructs like self and super.

Activity

  1. celinval commented on Nov 14, 2022

    @celinval
    Contributor

    Would it be safe to assume that by correctly resolving names you would also be properly handling multiple versions of a crate? It might be nice to clarify that in the RFC.

  2. aaronbembenek-aws commented on Nov 14, 2022

    @aaronbembenek-aws
    ContributorAuthor

    Yes, we should be able to handle that.

  3. celinval commented on Nov 14, 2022

    @celinval
    Contributor

    Just to double check, in the case of multiple versions, one stub would only be applied to one specific version right?

  4. aaronbembenek-aws commented on Nov 14, 2022

    @aaronbembenek-aws
    ContributorAuthor

    That would be the optimal behavior, but it's going to take some experimenting with our path resolution algorithm to make sure we get this right. Luckily, it looks like clippy is in the process of updating its path resolution algorithm to handle this correctly (rust-lang/rust-clippy#9800), so we can probably draw from there.

  5. added
    [C] Feature / EnhancementA new feature request or enhancement to an existing feature.
    [E] User ExperienceAn UX enhancement for an existing feature. Including deprecation of an existing one.
    on Dec 1, 2022
  6. moved this to In Progress in Kani 0.18on Dec 13, 2022
  7. aaronbembenek-aws commented on Dec 15, 2022

    @aaronbembenek-aws
    ContributorAuthor

    It might actually be harder to handle multiple versions of the same crate than I thought, if they are included via the renaming-dependencies feature of Cargo. As far as I can tell, the data we have available at the MIR level refers to the original name of the crate, and not what it has been renamed to...

  8. moved this from Todo to In Progress in Kani 2023-05-29on May 24, 2023
  9. moved this to In Progress in Kani 2023-06-19on Jun 1, 2023
  10. celinval commented on Aug 15, 2024

    @celinval
    Contributor

    Closing this issue in favor of more specific ones.

    Note that we have already implemented support for relative paths, including usage of self and super. I believe we are missing qualified paths needed for trait methods, and primitive type methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[C] Feature / EnhancementA new feature request or enhancement to an existing feature.[E] User ExperienceAn UX enhancement for an existing feature. Including deprecation of an existing one.

Type

No type

Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions