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

Three small fixes for save-analysis #43533

Merged
merged 4 commits into from
Aug 1, 2017
Merged

Three small fixes for save-analysis #43533

merged 4 commits into from
Aug 1, 2017

Conversation

nrc
Copy link
Member

@nrc nrc commented Jul 29, 2017

First commit does some naive deduplication of macro uses. We end up with lots of duplication here because of the weird way we get this data (we extract a use for every span generated by a macro use).

Second commit is basically a typo fix.

Third commit is a bit interesting, it partially reverts a change from #40939 where temporary variables in format! (and thus println!) got a span with the primary pointing at the value stored into the temporary (e.g., x in println!("...", x)). If format! had a definition it should point at the temporary in the macro def, but since it is built-in, that is not possible (for now), so DUMMY_SP is the best we can do (using the span in the callee really breaks save-analysis because it thinks x is a definition as well as a reference).

There aren't a test for this stuff because: the deduplication is filtered by any of the users of save-analysis, so it is purely an efficiency change. I couldn't actually find an example for the second commit that we have any machinery to test, and the third commit is tested by the RLS, so there will be a test once I update the RLS version and and uncomment the previously failing tests).

r? @jseyfried

Copy link
Contributor

@estebank estebank left a comment

Choose a reason for hiding this comment

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

Small nitpicks, looks good to merge otherwise.

@@ -409,7 +409,7 @@ impl<'a> SpanUtils<'a> {

// Otherwise, a generated span is deemed invalid if it is not a sub-span of the root
// callsite. This filters out macro internal variables and most malformed spans.
!parent.source_callsite().contains(parent)
!parent.source_callsite().contains(sub_span.unwrap())
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm weary of unwrap(). Even though it the code is valid now, somebody could come later and inadvertently remove the lines 401-403 without changing this. Could you change the above lines to if let Some(sub_span), else return true;? I know it's a nitpick.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or just change 401-403 to let sub_span = unwrap_or!(sub_span, return true); (unwrap_or!).

@@ -30,6 +30,7 @@ use rustc::hir::map::Node;
use rustc::session::Session;
use rustc::ty::{self, TyCtxt};

use std::collections::HashSet;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we be using FxHashSet in the compiler?

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably, although I image the performance impact would be negligible here.

@jseyfried
Copy link
Contributor

Reviewed, r=me modulo existing discussion.

@carols10cents carols10cents added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 31, 2017
@nrc
Copy link
Member Author

nrc commented Aug 1, 2017

Thanks for the reviews, updated with changes.

@bors: r=jseyfried, estebank

@bors
Copy link
Contributor

bors commented Aug 1, 2017

📌 Commit 27b9182 has been approved by jseyfried,

@nrc nrc 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 Aug 1, 2017
@bors
Copy link
Contributor

bors commented Aug 1, 2017

⌛ Testing commit 27b9182 with merge df90a54...

bors added a commit that referenced this pull request Aug 1, 2017
Three small fixes for save-analysis

First commit does some naive deduplication of macro uses. We end up with lots of duplication here because of the weird way we get this data (we extract a use for every span generated by a macro use).

Second commit is basically a typo fix.

Third commit is a bit interesting, it partially reverts a change from #40939 where temporary variables in format! (and thus println!) got a span with the primary pointing at the value stored into the temporary (e.g., `x` in `println!("...", x)`). If `format!` had a definition it should point at the temporary in the macro def, but since it is built-in, that is not possible (for now), so `DUMMY_SP` is the best we can do (using the span in the callee really breaks save-analysis because it thinks `x` is a definition as well as a reference).

There aren't a test for this stuff because: the deduplication is filtered by any of the users of save-analysis, so it is purely an efficiency change. I couldn't actually find an example for the second commit that we have any machinery to test, and the third commit is tested by the RLS, so there will be a test once I update the RLS version and and uncomment the previously failing tests).

r? @jseyfried
@bors
Copy link
Contributor

bors commented Aug 1, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: jseyfried,
Pushing df90a54 to master...

@bors bors merged commit 27b9182 into rust-lang:master Aug 1, 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.

5 participants