Skip to content

declare_tool_lint: allow use without default_field_values feature - #164990

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
mejrs:tool_lint_allow_internal_unstable
Nov 9, 2026
Merged

rust-bors[bot] merged 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

Comment thread compiler/rustc_hir_typeck/src/expr.rs Outdated
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 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We are allowed to write trailing .. in a struct expression if either the feature has been enabled or if the span allows it. If not, we emit an error.

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.

In that case, it should be

if !(self.tcx.features().default_field_values()
  && !span.allows_unstable(sym::default_field_values))

The reasoning behind this is,

TRUE means allow writing trailing ``..``
FALSE means don't allow writing trailing ``..``

(feature enabled) OR (span allows) = TRUE

negate both side then we get...
!((feature enabled) OR (span allows)) = NOT TRUE

according to De Morgan's law
!(feature enabled) AND !(span allows) = FALSE

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That doesn't look correct to me, did you mean

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.

Ah yes! xD

@tiif tiif Nov 8, 2026 •

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.

Oh wait, I see it wrongly, your original one is correct!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Actually, most code in the compiler uses the form I just mentioned, I'll switch it over to use it instead.

@bors r-

@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
@mejrs
mejrs force-pushed the tool_lint_allow_internal_unstable branch from a7682d7 to 540d5f4 Compare November 2, 2026 20:39
@rustbot

This comment has been minimized.

@mejrs

mejrs commented Nov 2, 2026

Copy link
Copy Markdown
Member Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 2, 2026
@tiif tiif 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 8, 2026

@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.

Sorry about misreading the code :> Let's ship this!

@bors r+ rollup

View changes since this review

@rust-bors

rust-bors Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Unknown command "r+rollup". Run @bors help or go to https://bors.rust-lang.org/help to see available commands.

@tiif

tiif commented Nov 8, 2026

Copy link
Copy Markdown
Member

@bors r+ rollup

@rust-bors

rust-bors Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 540d5f4 has been approved by tiif

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 8, 2026
@rust-bors

rust-bors Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

View changes since this unapproval

@mejrs
mejrs force-pushed the tool_lint_allow_internal_unstable branch from 540d5f4 to 7159e13 Compare November 8, 2026 11:56
@mejrs
mejrs force-pushed the tool_lint_allow_internal_unstable branch from 7159e13 to f007482 Compare November 8, 2026 11:57
@rustbot

rustbot commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@mejrs

mejrs commented Nov 8, 2026

Copy link
Copy Markdown
Member Author

@bors r=tiif

@rust-bors

rust-bors Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

📌 Commit f007482 has been approved by tiif

It is now in the queue for this repository.

@rust-bors rust-bors Bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Nov 8, 2026
@rust-bors rust-bors Bot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Nov 8, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 9, 2026
Rollup of 3 pull requests

Successful merges:

 - #164990 (declare_tool_lint: allow use without `default_field_values` feature)
 - #165420 (Do not suggest deriving Clone on foreign types in noop_method_call)
 - #165640 (Avoid Terminator:None in coroutine transform)
@rust-bors
rust-bors Bot merged commit 726268a into rust-lang:main Nov 9, 2026
14 checks passed
rust-bors Bot pushed a commit that referenced this pull request Nov 9, 2026
Rollup merge of #164990 - mejrs:tool_lint_allow_internal_unstable, r=tiif

declare_tool_lint: allow use without `default_field_values` feature

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 this to the 1.102.0 milestone Nov 9, 2026
programskillforverification pushed a commit to programskillforverification/miri that referenced this pull request Nov 10, 2026
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#164990 (declare_tool_lint: allow use without `default_field_values` feature)
 - rust-lang/rust#165420 (Do not suggest deriving Clone on foreign types in noop_method_call)
 - rust-lang/rust#165640 (Avoid Terminator:None in coroutine transform)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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