rust-lang / rust-lang/rustc_public

Add an API to resolve the name of a function

Open
#68 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
125
Forks
19
PR merge metrics
No merged PRs in 30d

Description

It would be really nice to be able to get the definition of a function by its name. In some cases, users may query a tool to perform analysis starting from a specific function. In other cases, tools may want to provide further instrumentation or manipulation such as adding extra assertions, or stubbing a method.

Ideally, the API should be something like:

/// Resolve the name of a function starting from the context of a definition.
fn resolve_function<T: CrateDef>(path: &str, context: T) -> Result<FnDef, Error> { /* */ }

See this discussion here where multiple tool developers describe their current solution:

https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Resolve.20string.20to.20DefId

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Begin with the proposed resolve_function signature and read the linked Zulip discussion, where tool developers describe their current solutions. Done would mean an API can resolve a function name from a definition context and return either an FnDef or an Error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.