Skip to content

Skip long type files for expected lints - #166357

Open
LusterSourav wants to merge 6 commits into
rust-lang:mainfrom
LusterSourav:wee
Open

LusterSourav wants to merge 6 commits into
rust-lang:mainfrom
LusterSourav:wee

Conversation

@LusterSourav

@LusterSourav LusterSourav commented Nov 22, 2026 •

Copy link
Copy Markdown

#166293
P=thee expected lint is never shown but its diagnostic was still built,building it wrote a long type file to disk
F+=Diagnostics for expected lints now carry an empty path marker. short_string_namespace sees the marker and returns the short string without writing a file
T+=new run make test checks that no long type file is created for an expected lint. It also checks that a shown lint still creates one

i cheked ;)
./x check compiler
and tests/run-make/expect-lint-no-long-type-file it cheekc that no long-type file pikabo ...
./x test tidy

full tests/ui and the rest of the compiler suite not run or else my lap gona cry -_-

@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 22, 2026
@rustbot

rustbot commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project has assigned @oli-obk (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks.

Please see the contribution instructions and our LLM policy for more information.

Why was this reviewer chosen?

The reviewer was selected based on:

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

@JonathanBrouwer JonathanBrouwer added the A-diagnostics Area: Messages for errors, warnings, and lints label Nov 22, 2026

@JonathanBrouwer JonathanBrouwer Nov 22, 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.

Why is the file called allowed.rs if the lint is warn in the file?

View changes since the review

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

the name is misleding , the file tests expected lints, so it should be renamed to something like expected.rs If it is meant for allowed lints, the lint lvl in it should be allllow......

.arg("-Zwrite-long-types-to-disk=yes")
.arg("--diagnostic-width=60")
.run();
assert_eq!(long_type_files(), 1, "shown lint should create a long type file");

@JonathanBrouwer JonathanBrouwer Nov 22, 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.

Could we also test what the behaviour for allowed lints is?

View changes since the review

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yep
add a second case with #[allow] and a long type then assert that 0 long type files are created its guards against a regression becauseallow already behaves correctly today.. tadawww

}

/// Marker stored in `long_ty_path` for diagnostics that are never shown. Real paths are never empty.
pub fn suppressed_long_ty_path() -> PathBuf {

@JonathanBrouwer JonathanBrouwer Nov 22, 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.

This could be a const rather than a function

View changes since the review

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yes,PathBuf::new() is const so a const can replace the func compare with the existing code before changing it,a const PathBuf can't be used directly in a match but it can still be cloned = or compared!!

is_lint: None,
long_ty_path: None,
// Expected lints are never shown, so they must not write long type files.
long_ty_path: matches!(level, Level::Warning(Some(EmissionOverride::Expected { .. })))

@JonathanBrouwer JonathanBrouwer Nov 22, 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.

I'm a bit confused about why this works. From what I'm seeing, long_ty_path is later unconditionally overwritten, so why does it matter if we set it so Some here?

View changes since the review

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

wowow didn't thought about it !!!!!
trueee valide point ...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

If a later step overwrites the field unconditionally, the marker is lost and the fix does nothing

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.

Well on the other hand the test seems to pass, so apparently it does something

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yep

is_lint: None,
long_ty_path: None,
// Expected lints are never shown, so they must not write long type files.
long_ty_path: matches!(level, Level::Warning(Some(EmissionOverride::Expected { .. })))

@JonathanBrouwer JonathanBrouwer Nov 22, 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.

Actually could we make this a custom enum rather than an option? I think that's clearer
Like

enum LongTyPath {
    None,
    Surpressed,
    Some(PathBuf)
}

View changes since the review

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, I agree a enum with none, suppresed and some(PathBuf) states the intent directl & its removes the empty path trick and makes it hard to forget the suppresed case here cost is that every place that uses the field need updting hmhmhm

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

but the q is i have to changes it one many file like 40+

The trait IntoDiagArg has a method that takes &mut option PathBuf ,it is declared in rustc_error_messages.
and every typ that implments this trait has to repeat that exact sigature. About 30 types across about 20 crates implemnt it, in rustc_abi, rustc_hir, rustc_target and others..... and the change option PathBuf to LongTyPath, evry one of those signatues stops compiling...so more and more line edts

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

this enum get me more edits... ???????

@LusterSourav LusterSourav Nov 22, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

could u please suggest me what to doooo plsss

@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 22, 2026
@rustbot

rustbot commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@LusterSourav

LusterSourav commented Nov 22, 2026 •

Copy link
Copy Markdown
Author

so i will updates the test files means rename it & add the allow case then the overwrite sites onee and i will switch to enum
good stuff right ;)
i will update it after dinner

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

A-diagnostics Area: Messages for errors, warnings, and lints A-run-make Area: port run-make Makefiles to rmake.rs 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.

4 participants