Repository navigation
Skip long type files for expected lints - #166357
LusterSourav wants to merge 6 commits into
Conversation
|
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:
|
There was a problem hiding this comment.
Why is the file called allowed.rs if the lint is warn in the file?
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
Could we also test what the behaviour for allowed lints is?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
This could be a const rather than a function
There was a problem hiding this comment.
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 { .. }))) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
wowow didn't thought about it !!!!!
trueee valide point ...
There was a problem hiding this comment.
If a later step overwrites the field unconditionally, the marker is lost and the fix does nothing
There was a problem hiding this comment.
Well on the other hand the test seems to pass, so apparently it does something
| 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 { .. }))) |
There was a problem hiding this comment.
Actually could we make this a custom enum rather than an option? I think that's clearer
Like
enum LongTyPath {
None,
Surpressed,
Some(PathBuf)
}
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
this enum get me more edits... ???????
There was a problem hiding this comment.
could u please suggest me what to doooo plsss
|
Reminder, once the PR becomes ready for a review, use |
|
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 |
#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 -_-