Skip to content

Avoid complex diagnostics in snippets which contain newlines #75020

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

Merged
merged 6 commits into from
Nov 2, 2020

Conversation

JohnTitor
Copy link
Member

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 1, 2020
@JohnTitor
Copy link
Member Author

@estebank said:

I think there is an open PR that adds description to all ExprKind variants.

I guess you meant DefKind?

@Dylan-DPC-zz
Copy link

@estebank this is ready to review

LL | | foo(tx.clone());
LL | | }).await;
| |________________^
note: ...but, the value is later dropped here
Copy link
Member

Choose a reason for hiding this comment

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

I don't think ...but is clearer here. To me, it implies that the fact that it is dropped is part of the problem. And in the case of the borrow check errors that sound like this, it is.

Sometimes that's true in that you could drop the value earlier, before the await point. But in both of these cases it's not; the extra note is just information. (And not very useful information in these cases, but that's something we can clean up later.)

Anyway, it might be helpful to represent that this is a continuation of the above note, in which case I'd ask that we keep only the ellipsis, e.g. note: ...the value is later dropped here

await_or_yield, snippet
),
);
err.span_note(
Copy link
Member

Choose a reason for hiding this comment

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

Removing the type information makes the error less verbose, but it's quite useful in a lot of cases. If I were to pick one thing to remove, it would be the "Foo is later dropped here" message.

Or we can emit the same set of messages in both cases, in which case I think we could deduplicate a lot of this code.

@bors
Copy link
Collaborator

bors commented Aug 30, 2020

☔ The latest upstream changes (presumably #74862) made this pull request unmergeable. Please resolve the merge conflicts.

@crlf0710 crlf0710 added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 18, 2020
@crlf0710
Copy link
Member

Triage: there are merge conflicts now.

// LL | / baz(|| async{
// LL | | foo(tx.clone());
// LL | | }).await;
// | |________________^
Copy link
Contributor

Choose a reason for hiding this comment

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

These two spans don't seem right. The case we're proactively handling here originally had a span pointing until the end of the await and another pointing at the end of the call if baz.

--> $DIR/issue-65436-raw-ptr-not-send.rs:14:9
|
LL | bar(Foo(std::ptr::null())).await;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Copy link
Contributor

@estebank estebank Sep 19, 2020

Choose a reason for hiding this comment

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

Would it make sense to combine these two along the lines of

note: future is not `Send` as this value is used across an await
  --> $DIR/issue-65436-raw-ptr-not-send.rs:14:9
   |
LL |         bar(Foo(std::ptr::null())).await;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ first, await occurs here, with `std::ptr::null()` maybe used later...
note: `std::ptr::null()` is later dropped here
  --> $DIR/issue-65436-raw-ptr-not-send.rs:14:41
   |
LL |         bar(Foo(std::ptr::null())).await;
   |                 ----------------        ^ `std::ptr::null()` is later dropped here
   |                 |
   |                 has type `*const u8` which is not `Send`

@tmandry
Copy link
Member

tmandry commented Oct 6, 2020

The PR needs a rebase and there are some review comments to address.

Ping @JohnTitor, are you still interested in working on this?

@JohnTitor
Copy link
Member Author

Sorry for the delay! Rebased and tweaked some spans and wording.

@estebank @tmandry Could you take a look?

@JohnTitor JohnTitor removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Oct 10, 2020
@tmandry
Copy link
Member

tmandry commented Oct 21, 2020

Sorry for the delay on my end.

I still think the new message should include the has type {} which is not {} message that we have in the other case.

Otherwise, I think this looks good.

@tmandry tmandry added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 21, 2020
Comment on lines +20 to +27
note: this has type `[closure@$DIR/issue-70935-complex-spans.rs:13:13: 15:10]` which is not `Send`
--> $DIR/issue-70935-complex-spans.rs:13:13
|
LL | baz(|| async{
| _____________^
LL | | foo(tx.clone());
LL | | }).await;
| |_________^
Copy link
Member Author

Choose a reason for hiding this comment

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

Added this note separately, since this span has some lines and loses readability when we do as @estebank suggested (#75020 (comment)). I feel it's redundant a bit.

@tmandry Does this make sense for you?

Copy link
Contributor

Choose a reason for hiding this comment

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

@JohnTitor something I've done in other errors i check whether Spans are exactly the same, if one encloses the other, or if one of them is multiline to provide different output depending on what looks best. In this case just checking whether the "inner" span is multiline to decide between span_labels and span_notes should be easy to do and reasonable as a solution. What do you two think?

Copy link
Contributor

Choose a reason for hiding this comment

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

r=me with or without the proposed changes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good! Addressed via 54d9ffc.

@tmandry
Copy link
Member

tmandry commented Oct 28, 2020

@bors delegate+

@bors
Copy link
Collaborator

bors commented Oct 28, 2020

✌️ @JohnTitor can now approve this pull request

@JohnTitor
Copy link
Member Author

Applied the suggestion from @estebank via 54d9ffc and added 8d65101 to make the prior commit diff-less.
@bors r=estebank,tmandry

@bors
Copy link
Collaborator

bors commented Nov 2, 2020

📌 Commit 8d65101 has been approved by estebank,tmandry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 2, 2020
@bors
Copy link
Collaborator

bors commented Nov 2, 2020

⌛ Testing commit 8d65101 with merge 234099d...

@bors
Copy link
Collaborator

bors commented Nov 2, 2020

☀️ Test successful - checks-actions
Approved by: estebank,tmandry
Pushing 234099d to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 2, 2020
@bors bors merged commit 234099d into rust-lang:master Nov 2, 2020
@rustbot rustbot added this to the 1.49.0 milestone Nov 2, 2020
@JohnTitor JohnTitor deleted the fix-multispan branch November 2, 2020 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hard to read error message with 2D line drawing and multi-line expressions
8 participants