Skip to content
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

Point at signature on unused lint #44847

Merged
merged 1 commit into from
Sep 29, 2017
Merged

Conversation

estebank
Copy link
Contributor

warning: struct is never used: `Struct`
  --> $DIR/unused-warning-point-at-signature.rs:22:1
   |
22 | struct Struct {
   | ^^^^^^^^^^^^^

Fix #33961.

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

Nice.

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Sep 25, 2017

📌 Commit bc7554a has been approved by nikomatsakis

@estebank
Copy link
Contributor Author

Fix missed test.

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Sep 25, 2017

📌 Commit 9c3fa4d has been approved by nikomatsakis

@estebank estebank added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Sep 26, 2017
35 | | -> usize
36 | | {
37 | | 3
38 | | }
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this span including the body? Just because it's multiline?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@oli-obk it was originally proposed that given that in cases where a multiline span was already being shown, we might as well point at the entire body. This decision can be revised if needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

For RLS this is a major annoyance.

Copy link
Member

Choose a reason for hiding this comment

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

@oli-obk For RLS indeed it'd be very handy to only point at the symbol name, but I think from the CLI ergonomics point of view, displaying multiline diagnostics might still be superior? (gives more context, CLIs are often run out-of-the-editor etc.)

Copy link
Contributor

Choose a reason for hiding this comment

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

It would still be multiline, it just wouldn't show the function body. I don't see much use in showing function bodies at all for such diagnostics

Copy link
Member

Choose a reason for hiding this comment

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

If that would work, I guess we could. However, aren't there other def_span users who still rely on the full multiline when a signature is also spanning across multiple lines? I'm not very well versed in rustc itself, sorry.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Xanewok there're are only two users of def_span at the moment, including this one, and neither rely on it showing the full span when multiline.

Copy link
Member

Choose a reason for hiding this comment

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

@estebank ah, my bad. Must've looked up wrong def_span, sorry. The one from the codemap seems to only be used for lints (if I'm not mistaken?) so I think it'd be great to go ahead and limit the multiline spans only to signatures, without bodies, in lints.

Copy link
Member

@Xanewok Xanewok Oct 7, 2017

Choose a reason for hiding this comment

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

@estebank @oli-obk with the change now also ui\span\multiline-span-E0072.rs fails as follows:
after change:

error[E0072]: recursive type `ListNode` has infinite size
  --> $DIR/multiline-span-E0072.rs:12:1
   |
12 | / struct
13 | | ListNode
   | |________^ recursive type has infinite size
...
16 |       tail: Option<ListNode>,
   |       ---------------------- recursive without indirection
   |
   = help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `ListNode` representable

expected:

error[E0072]: recursive type `ListNode` has infinite size
  --> $DIR/multiline-span-E0072.rs:12:1
   |
12 | / struct
13 | | ListNode
14 | | {
15 | |     head: u8,
16 | |     tail: Option<ListNode>,
   | |     ---------------------- recursive without indirection
17 | | }
   | |_^ recursive type has infinite size
   |
   = help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `ListNode` representable

Is this desired? On one hand it's handy to highlight the faulty (recursive here) bit within the whole span, on the other highlighting entire definition may be an overkill, especially for RLS (iirc right now RLS can't even highlight primary/secondary spans properly per a single diagnostic, only the primary one).
cc @GuillaumeGomez

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Xanewok I also prefer the current output, but understand that we're bound by the limitations of VSCode/RLS here.

@nikomatsakis would you have a comment? I'm inclined to move ahead with the change.

@bors
Copy link
Contributor

bors commented Sep 29, 2017

⌛ Testing commit 9c3fa4d with merge 0253d98...

bors added a commit that referenced this pull request Sep 29, 2017
Point at signature on unused lint

```
warning: struct is never used: `Struct`
  --> $DIR/unused-warning-point-at-signature.rs:22:1
   |
22 | struct Struct {
   | ^^^^^^^^^^^^^
```

Fix #33961.
@bors
Copy link
Contributor

bors commented Sep 29, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing 0253d98 to master...

@bors bors merged commit 9c3fa4d into rust-lang:master Sep 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

None yet

6 participants