Skip to content

declare_tool_lint: allow use without default_field_values feature - #164990

Open
mejrs wants to merge 1 commit into
rust-lang:mainfrom
mejrs:tool_lint_allow_internal_unstable
Open

mejrs wants to merge 1 commit into
rust-lang:mainfrom
mejrs:tool_lint_allow_internal_unstable

Conversation

@mejrs

@mejrs mejrs commented Oct 26, 2026

Copy link
Copy Markdown
Member

Followup to #164329

It's somewhat inconvenient, for 3rd party lint tool authors, to have to enable a feature that's really an implementation detail of the macro.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 26, 2026
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 26, 2026
@rustbot

rustbot commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

r? @tiif

rustbot has assigned @tiif.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 77 candidates
  • Random selection from 21 candidates

@tiif tiif left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this!

View changes since this review

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will need to write a cross-crate test to test the behavior of using #[allow_internal_unstable(..)] across upstream and downstream crates.

In tests/ui/structs/default-field-values/auxiliary/, you can define the upstream crate, for example aux.rs with something like...

#![feature(default_field_values)]
#![feature(allow_internal_unstable)]
#[allow_internal_unstable(default_field_values)]
#[macro_export]
macro_rules! foo {
    () => { fn foo() { struct Foo {x: usize = 0, } Foo {..}; } };
}

In tests/ui/structs/default-field-values/allow_internal_unstable.rs, you can use the macro with...

//@ aux-build:aux.rs
//@check-pass

extern crate aux;
use aux::foo;

foo!();

fn main(){

You will see different behavior in downstream crate when allow_internal_unstable is used and when it is not used.

Comment on lines +2056 to +2058
if !(self.tcx.features().default_field_values()
|| span.allows_unstable(sym::default_field_values))
{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea that I get from this diff is whenever we use #[allow_internal_unstable(default_field_values)]], we always execute the if path below that suggests adding #![feature(default_field_values)]? I feel I am missing something 🤔

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 1, 2026

This branch has not been deployed

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

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants