Skip to content

Is exact count of other implementations useful in this error message? #102864

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
scottmcm opened this issue Oct 9, 2022 · 1 comment
Open
Labels
A-contributor-roadblock Area: Makes things more difficult for new or seasoned contributors to Rust A-diagnostics Area: Messages for errors, warnings, and lints A-testsuite Area: The testsuite used to check the correctness of rustc C-enhancement Category: An issue proposing an enhancement or a PR with one. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@scottmcm
Copy link
Member

scottmcm commented Oct 9, 2022

I got the following CI failure in #102862

---- [ui] src/test/ui/try-trait/bad-interconversion.rs stdout ----
diff of stderr:

16	             <f64 as From<i16>>
17	             <f64 as From<i32>>
18	             <f64 as From<i8>>
-	           and 67 others
+	           and 68 others
20	   = note: required for `Result<u64, u8>` to implement `FromResidual<Result<Infallible, i32>>`
21	
22	error[E0277]: the `?` operator can only be used on `Result`s, not `Option`s, in a function that returns `Result`

I don't know if this is a diagnostics request or a UI test normalization request, but getting UI test failures when adding a From implementation is kinda annoying (if admittedly easy enough to fix).

So I wonder how much value the exact number here is providing. I wonder if it might make sense to change the message to

and many others

if it's above some threshold.

I can't see any reason the exact count is useful to the programmer reading the error (at least when it's a large number), and it might save some work in error message generation to stop once it's found a bunch.

@compiler-errors
Copy link
Member

I'm fine with either of the suggestions, choosing some other phrasing for large numbers of trait candidates or normalizing it in the UI tests themselves.

Coincidentally, @mejrs just implemented a trybuild normalization for this in dtolnay/trybuild@ea3f207.

The code we use to generate "... and {} others" is kinda scattered all over the place for different suggestions, but if we're gonna change one we should change them all.

and it might save some work in error message generation to stop once it's found a bunch.

But this shouldn't be a primary motivation, since we calculate the list of candidates (and other lists used in suggestions that end with "... and {} others") eagerly, and it'd probably be more work to make it lazy -- especially because diagnostics code isn't focused on speed.

@jyn514 jyn514 added A-testsuite Area: The testsuite used to check the correctness of rustc A-contributor-roadblock Area: Makes things more difficult for new or seasoned contributors to Rust A-diagnostics Area: Messages for errors, warnings, and lints labels Apr 10, 2023
@Enselic Enselic added D-papercut Diagnostics: An error or lint that needs small tweaks. C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-contributor-roadblock Area: Makes things more difficult for new or seasoned contributors to Rust A-diagnostics Area: Messages for errors, warnings, and lints A-testsuite Area: The testsuite used to check the correctness of rustc C-enhancement Category: An issue proposing an enhancement or a PR with one. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants