rust-lang / rust-lang/rfcs

Macro that expands into string holding function name (or module path, etc)

Open
#1,743 27 comments 46 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-macros A-macros-libstd T-lang T-libs
Dominant language
Markdown
Stars
6.6k
Forks
1.7k
Avg merge
16h 14m
Merged PRs (30d)
1

Description

View all comments

RFC #466 was closed back in the days before we had a protocol for opening up follow-up issues to use to gather links to related discussion.

The idea is that we already have some macros (file! and line!) that are useful for reporting source code context, and it might be nice to expand that collection with macros that include other information, such as the current function name, which I believe was the suggestion of the function! macro that was at one point described in RFC #466 (whose draft contents have now been lost, apparently).

Here is my attempt to retrieve the Motivation from that original draft text. (I don't think we need the detailed design in the description of an issue like this.)

Motivation

For error reporting cases we already have file!, line!, col! and module_path!
but there is no way yet to figure out in which function an error was reported. Python's
tracebacks are well received and for many people the function name information is much
more important than the line number.

  • An alternative (or complement) would be to have a module_path! macro that expands into a string representing the path to the current module; such a macro would be usable outside of fn definitions, e.g. in static items.

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

Start by reviewing RFC #466 and the existing file!, line!, col!, and module_path! macros described in the issue. Clarify whether the goal is a current-function-name macro, a module-path enhancement, or both, and document a settled design and scope before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
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.