-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Conversation
@estebank said:
I guess you meant |
@estebank this is ready to review |
LL | | foo(tx.clone()); | ||
LL | | }).await; | ||
| |________________^ | ||
note: ...but, the value is later dropped here |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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.
☔ The latest upstream changes (presumably #74862) made this pull request unmergeable. Please resolve the merge conflicts. |
Triage: there are merge conflicts now. |
// LL | / baz(|| async{ | ||
// LL | | foo(tx.clone()); | ||
// LL | | }).await; | ||
// | |________________^ |
There was a problem hiding this comment.
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; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
There was a problem hiding this comment.
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`
The PR needs a rebase and there are some review comments to address. Ping @JohnTitor, are you still interested in working on this? |
db80f28
to
aabc1c9
Compare
Sorry for the delay on my end. I still think the new message should include the Otherwise, I think this looks good. |
aabc1c9
to
02b3bb6
Compare
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; | ||
| |_________^ |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 Span
s 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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@bors delegate+ |
✌️ @JohnTitor can now approve this pull request |
02b3bb6
to
8d65101
Compare
📌 Commit 8d65101 has been approved by |
☀️ Test successful - checks-actions |
Fixes #70935
r? @estebank @tmandry