Skip to content

Avoid linting unreachable_code on todo!()#3928

Open
llogiq wants to merge 4 commits into
rust-lang:masterfrom
llogiq:todo-overreach
Open

Avoid linting unreachable_code on todo!()#3928
llogiq wants to merge 4 commits into
rust-lang:masterfrom
llogiq:todo-overreach

Conversation

@llogiq
Copy link
Copy Markdown
Contributor

@llogiq llogiq commented Mar 14, 2026

Because todo!() is often used as a placeholder while working on the code, we should avoid linting unreachable_code on code after those macro uses. Instead let's add a todo_macro_uses lint that we can selectively activate e.g. when compiling a release.

This will reduce message churn and allow users to concentrate on the warnings and errors that matter while they work on the code.

Rendered

@llogiq
Copy link
Copy Markdown
Contributor Author

llogiq commented Mar 14, 2026

Note that rust#149543 has an implementation.

@ehuss ehuss added the T-lang Relevant to the language team, which will review and decide on the RFC. label Mar 15, 2026
@llogiq
Copy link
Copy Markdown
Contributor Author

llogiq commented May 21, 2026

Another note: The implementation is finally ready to merge, provided this RFC is accepted.

Comment thread text/0000-todo-overreach.md
Comment thread text/0000-todo-overreach.md Outdated
llogiq and others added 2 commits May 21, 2026 21:53
Add another alternative

Co-authored-by: Josh Triplett <josh@joshtriplett.org>
@joshtriplett joshtriplett added the I-lang-nominated Indicates that an issue has been nominated for prioritizing at the next lang team meeting. label May 21, 2026
@joshtriplett
Copy link
Copy Markdown
Member

This is the RFC we solicited, presenting exactly what we asked for.

@rfcbot merge lang

@rust-rfcbot
Copy link
Copy Markdown
Collaborator

rust-rfcbot commented May 21, 2026

Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns.
See this document for info about what commands tagged team members can give me.

@rust-rfcbot rust-rfcbot added proposed-final-comment-period Currently awaiting signoff of all team members in order to enter the final comment period. disposition-merge This RFC is in PFCP or FCP with a disposition to merge it. labels May 21, 2026
@nikomatsakis
Copy link
Copy Markdown
Contributor

nikomatsakis commented May 22, 2026

@rfcbot reviewed

I'm a big fan of both this specific idea and the general trend of thinking about how our lints feel during the process of authoring code, not just once the code is done. Dead code warnings in particular are often a pain point for me ("sure, it's dead now but that's because I didn't get around to calling it yet..."). #[expect] helps here, I think we should in our lint messages convey to the user that #[expect(todo_macro_invocations)] or whatever is a useful way to silence those warnings.

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

Labels

disposition-merge This RFC is in PFCP or FCP with a disposition to merge it. I-lang-nominated Indicates that an issue has been nominated for prioritizing at the next lang team meeting. proposed-final-comment-period Currently awaiting signoff of all team members in order to enter the final comment period. T-lang Relevant to the language team, which will review and decide on the RFC.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants