Skip to content

"snippet" for "did you mean x" is not so helpful #36164

Closed
@nikomatsakis

Description

@nikomatsakis

On current beta, at least, I see:

error: attempted access of field `test_results` on type `TestResult`, but no field with that name was
 found
   --> src/main.rs:196:25
    |
196 |         tests_passed += normal_test.test_results.iter().filter(|t| t.status == "ok").count();
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: did you mean `results`?
   --> src/main.rs:196:37
    |
196 |         tests_passed += normal_test.test_results.iter().filter(|t| t.status == "ok").count();
    |                                     ^^^^^^^^^^^^

But I feel like I'd rather see:

error: attempted access of field `test_results` on type `TestResult`, but no field with that name was
 found
   --> src/main.rs:196:25
    |
196 |         tests_passed += normal_test.test_results.iter().filter(|t| t.status == "ok").count();
    |                                     ^^^^^^^^^^^^
    =  help: did you mean `results`?

Come to think of it, we could shorten the main message and move the suggestion into the label, as I think you've done elsewhere:

error: no field `test_results` on type `TestResult`
   --> src/main.rs:196:25
    |
196 |         tests_passed += normal_test.test_results.iter().filter(|t| t.status == "ok").count();
    |                                     ^^^^^^^^^^^^ did you mean `results`?
    |

Standalone example:

https://is.gd/8STXMd

cc @jonathandturner

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions