Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Propose updates to closure pretty print #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

arora-aman
Copy link
Member

@arora-aman arora-aman commented Sep 2, 2020

Rendered

r? @rust-lang/wg-diagnostics @davidtwco

@arora-aman arora-aman force-pushed the closure_print_proposal branch from 2497280 to a4c43a3 Compare September 2, 2020 21:16
{
let x = 20;

// pretty print: mod1::f::{{closure}}#0
Copy link

Choose a reason for hiding this comment

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

Have you considered the possible notation mod1::f::{{closure@src/main.rs:8:14: 10:6}} instead? A nice property of the current output is the embedded textual span. I prefer to use labels for spans except for closures, as they are types that might appear very nested in their parent type.

Copy link
Member Author

@arora-aman arora-aman Sep 9, 2020

Choose a reason for hiding this comment

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

I feel like that can be done with/after rust-lang/rust#70334.

From rust-lang/rust#70334 (comment) on that issue

For the user-facing stuff we might want to (but not for this issue, it should probably be separate) replace the #N disambiguator with @ file.rs:line:column instead (which would neatly fit in the {...}) - this could allow us to replace the odd [closure ...] type syntax with "just" a path (IIRC, @arora-aman has been looking at this for a different reason).

@arora-aman
Copy link
Member Author

arora-aman commented Sep 9, 2020

Because of rust-lang/rust@07e7823,
if the path to the closure is unambiguous, it will be trimmed to minimum required.

So the last example would really print f::{{closure}}#0 in non verbose and f<T>::{{closure}}#0 in verbose unless -Z trim-diagnostic-paths=off is set in which case it will print what's in the document.

If this feels acceptable, I'll update the proposal.

cc @nikomatsakis

bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 30, 2020
…tsakis

pretty.rs: Update Closure and Generator print

More detailed outline: rust-lang/project-rfc-2229#17

Closes: rust-lang/project-rfc-2229#11

r? `@nikomatsakis`
cc `@eddyb` `@davidtwco` `@estebank`
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants