Skip to content

diagnostics: span_note/span_help/etc should work with dummy spans #55669

New issue

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

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

Already on GitHub? # to your account

Closed
petrochenkov opened this issue Nov 4, 2018 · 3 comments
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@petrochenkov
Copy link
Contributor

span_note and friends require this non-obvious pattern to work correctly:

if span.is_dummy() {
    err.note(msg);
} else {
    err.span_note(span, msg);
}

If dummy span is passed to span_note then the message simply won't be displayed, but with note it will be attached to the primary err message.
The difference is that note turns into an empty multi-span, but span_note turns into multi-span containing a single dummy span.

I think span_note should "just work" with dummy spans and display the message equivalently to note.

@petrochenkov petrochenkov added the A-diagnostics Area: Messages for errors, warnings, and lints label Nov 4, 2018
@petrochenkov
Copy link
Contributor Author

cc @estebank

@eddyb
Copy link
Member

eddyb commented Nov 4, 2018

cc @nikomatsakis @nrc

@estebank
Copy link
Contributor

estebank commented Nov 4, 2018

Now multispans also have an is_dummy() method, so that won't be a source of problems. The only thing that I can think of that could present a challenge is for suggestions (which I guess are out of scope for this thicket) they usually have a fallback with tweaked wording to work as note/help.

I can write out mentoring notes for this.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

3 participants