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

Keep resolved defs in path prefixes and emit them in save-analysis #54145

Merged
merged 10 commits into from
Oct 26, 2018

Conversation

nrc
Copy link
Member

@nrc nrc commented Sep 12, 2018

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[00:20:45]    Compiling unwind v0.0.0 (file:///checkout/src/libunwind)
[00:20:51]    Compiling compiler_builtins v0.0.0 (file:///checkout/src/rustc/compiler_builtins_shim)
[00:20:51]    Compiling cmake v0.1.33
[00:20:51]    Compiling alloc_jemalloc v0.0.0 (file:///checkout/src/liballoc_jemalloc)
[00:20:53] thread 'main' panicked at 'librustc/hir/map/collector.rs:221: inconsistent DepNode for `PathSegment(PathSegment { ident: prelude#0, id: Some(NodeId(104)), def: Some(Mod(DefId(0/0:547))), args: None, infer_types: false })`: current_dep_node_owner=::{{?}}[0], hir_id.owner=', librustc/util/bug.rs:47:26

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@eddyb
Copy link
Member

eddyb commented Sep 12, 2018

r? @petrochenkov cc @alexcrichton @nikomatsakis

Could you add support in stability checking, for looking at these Defs?
I think it would finally solve the "std::intrinsics::transmute is allowed on stable" problem, and e.g. #54006 (which even if we have a workaround for, an actual fix would be preferred).

@pietroalbini pietroalbini added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 12, 2018
} else {
// Generic arguments are not found.
PathSegment::from_ident(ident)
PathSegment::from_ident(ident,)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: stray comma

// })
// .collect(),
// span: path.span,
// };
Copy link
Contributor

Choose a reason for hiding this comment

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

?

@petrochenkov
Copy link
Contributor

CI is failing + this needs a perf run (new fields in path segments + a lot more node IDs).

.collect::<Vec<_>>();
self.smart_resolve_path_fragment(id, qself, segments, path.span, source, crate_lint)
}

fn smart_resolve_path_fragment(&mut self,
id: NodeId,
qself: Option<&QSelf>,
path: &[Ident],
path: &[(Ident, Option<NodeId>)],
Copy link
Contributor

Choose a reason for hiding this comment

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

Resolve code is a lot uglier now due to these &[(Ident, Option<NodeId>)] things, but hopefully this can be refactored later.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe a resolve-specific PathSegment struct would be better?

@petrochenkov petrochenkov 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 Sep 12, 2018
@eddyb
Copy link
Member

eddyb commented Sep 12, 2018

Long-term we might instead want nested Paths, e.g. a::b::c would be ((a)::b)::c, but moving away from "a path is a list of segments" seems harder than adding node IDs to each path segment.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[00:20:25]    Compiling alloc_jemalloc v0.0.0 (file:///checkout/src/liballoc_jemalloc)
[00:20:28] error: build failed
[00:20:28] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" "panic-unwind jemalloc backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "--message-format" "json"
[00:20:28] expected success, got: exit code: 101
[00:20:28] thread 'main' panicked at 'cargo must succeed', bootstrap/compile.rs:1155:9
[00:20:28] travis_fold:end:stage1-std

[00:20:28] travis_time:end:stage1-std:start=1536800562278918855,finish=1536800572232211657,duration=9953292802


[00:20:28] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap build
[00:20:28] Build completed unsuccessfully in 0:15:54
[00:20:28] make: *** [all] Error 1
[00:20:28] Makefile:28: recipe for target 'all' failed
1470244 ./obj
1470208 ./obj/build
1192184 ./.git
1067244 ./src
---
151412 ./src/tools/clang
149112 ./src/llvm-emscripten/test
149020 ./obj/build/bootstrap/debug/incremental
134588 ./obj/build/bootstrap/debug/incremental/bootstrap-j9sjo2qxwegl
134584 ./obj/build/bootstrap/debug/incremental/bootstrap-j9sjo2qxwegl/s-f4qzy5rdjf-1cauxoh-1jtu7ee7y4raz
104700 ./src/tools/lldb
98948 ./obj/build/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends
93748 ./src/tools/clang/test
93748 ./src/tools/clang/test
90752 ./obj/build/x86_64-unkn-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:2b4191f8
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@nrc
Copy link
Member Author

nrc commented Sep 13, 2018

I've addressed reviewer comments, but looks like we're still failing CI. I'm away for a few days and will investigate when I get back

@bors
Copy link
Contributor

bors commented Sep 13, 2018

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

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[00:25:36]    Compiling build_helper v0.1.0 (file:///checkout/src/build_helper)
[00:25:42]    Compiling compiler_builtins v0.0.0 (file:///checkout/src/rustc/compiler_builtins_shim)
[00:25:42]    Compiling cmake v0.1.33
[00:25:42]    Compiling alloc_jemalloc v0.0.0 (file:///checkout/src/liballoc_jemalloc)
[00:25:43] thread 'main' panicked at 'librustc/hir/map/collector.rs:217: inconsistent DepNode for `PathSegment(PathSegment { ident: prelude#0, id: Some(NodeId(103)), def: Some(Mod(DefId(0/0:547))), args: None, infer_types: false })`: current_dep_node_owner=::{{?}}[0], hir_id.owner=', librustc/util/bug.rs:47:26
[00:25:43] 
[00:25:43] error: internal compiler error: unexpected panic
[00:25:43] 
[00:25:43] note: the compiler unexpectedly panicked. this is a bug.
[00:25:43] note: the compiler unexpectedly panicked. this is a bug.
[00:25:43] 
[00:25:43] note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
[00:25:43] 
[00:25:43] note: rustc 1.30.0-dev running on x86_64-unknown-linux-gnu
[00:25:43] 
[00:25:43] note: compiler flags: -Z force-unstable-if-unmarked -C opt-level=2 -C prefer-dynamic -C debug-assertions=y -C link-args=-Wl,-rpath,$ORIGIN/../lib --crate-type lib
[00:25:43] note: some of the compiler flags provided by cargo are hidden
[00:25:43] 
[00:25:43] error: Could not compile `core`.
[00:25:43] warning: build failed, waiting for other jobs to finish...
---
travis_time:end:003c4446:start=1537345035028561735,finish=1537345035032539718,duration=3977983
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:3cb70ed3
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:07f79280
travis_time:start:07f79280
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:09537984
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@bors
Copy link
Contributor

bors commented Sep 21, 2018

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

@@ -1093,6 +1095,7 @@ impl<'a> print::State<'a> {
Node::AnonConst(a) => self.print_anon_const(&a),
Node::Expr(a) => self.print_expr(&a),
Node::Stmt(a) => self.print_stmt(&a),
Node::PathSegment(_) => bug!("cannot print PathSegment"),
Copy link
Member

Choose a reason for hiding this comment

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

You should probably implement this, to avoid cascading issues.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -337,6 +337,8 @@ impl fmt::Display for Path {
pub struct PathSegment {
/// The identifier portion of this path segment.
pub ident: Ident,
pub id: Option<NodeId>,
pub def: Option<Def>,
Copy link
Member

Choose a reason for hiding this comment

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

Any reason these are Option? I'd say fix and/or document them.

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't use them for synthesized path segments. I've added docs.

nrc added a commit to nrc/rustc-perf-data that referenced this pull request Oct 12, 2018
@TimNN TimNN added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 16, 2018
@petrochenkov
Copy link
Contributor

Still needs a rebase, ICE fix, and @rust-timer run.

@rust-timer
Copy link
Collaborator

Insufficient permissions to issue commands to rust-timer.

@petrochenkov petrochenkov 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 17, 2018
@nrc nrc force-pushed the save-path-segments branch from 404c55c to 81ee74b Compare October 18, 2018 01:13
@nrc
Copy link
Member Author

nrc commented Oct 18, 2018

Rebased and ICE fixed. How do I do a rust-timer run? I collected data locally but couldn't run the site.

@bors
Copy link
Contributor

bors commented Oct 25, 2018

📌 Commit 6dd5bb1 has been approved by petrochenkov

@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 Oct 25, 2018
@bors
Copy link
Contributor

bors commented Oct 26, 2018

⌛ Testing commit 6dd5bb1 with merge 7b0735a...

bors added a commit that referenced this pull request Oct 26, 2018
Keep resolved defs in path prefixes and emit them in save-analysis

Closes rust-dev-tools/rls-analysis#109

r? @eddyb or @petrochenkov
@bors
Copy link
Contributor

bors commented Oct 26, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: petrochenkov
Pushing 7b0735a to master...

@rust-highfive
Copy link
Collaborator

📣 Toolstate changed by #54145!

Tested on commit 7b0735a.
Direct link to PR: #54145

💔 rls on windows: test-pass → test-fail (cc @nrc, @rust-lang/infra).
💔 rls on linux: test-pass → test-fail (cc @nrc, @rust-lang/infra).

rust-highfive added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Oct 26, 2018
Tested on commit rust-lang/rust@7b0735a.
Direct link to PR: <rust-lang/rust#54145>

💔 rls on windows: test-pass → test-fail (cc @nrc, @rust-lang/infra).
💔 rls on linux: test-pass → test-fail (cc @nrc, @rust-lang/infra).
@kennytm
Copy link
Member

kennytm commented Oct 26, 2018

The RLS test failures:

[01:31:46] ---- test::test_goto_def stdout ----
[01:31:46] thread 'test::test_goto_def' panicked at 'Assert failed: Could not find `"start":{"line":20,"character":8}` in `{"jsonrpc":"2.0","id":11,"result":[]}`', tools/rls/src/test/harness.rs:227:9
[01:31:46] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:31:46] 
[01:31:46] ---- test::test_hover stdout ----
[01:31:46] thread 'test::test_hover' panicked at 'Assert failed: Could not find `[{"language":"rust","value":"&str"},{"language":"rust","value":"let world = \"world\";"}]` in `{"jsonrpc":"2.0","id":11,"result":{"contents":[{"language":"rust","value":"let world = \"     \";"}]}}`', tools/rls/src/test/harness.rs:227:9
[01:31:46] 
[01:31:46] ---- test::test_highlight stdout ----
[01:31:46] thread 'test::test_highlight' panicked at 'Assert failed: Could not find `{"start":{"line":20,"character":8},"end":{"line":20,"character":13}}` in `{"jsonrpc":"2.0","id":42,"result":[]}`', tools/rls/src/test/harness.rs:227:9
[01:31:46] 
[01:31:46] ---- test::test_rename stdout ----
[01:31:46] thread 'test::test_rename' panicked at 'Assert failed: Could not find `{"start":{"line":20,"character":8},"end":{"line":20,"character":13}}` in `{"jsonrpc":"2.0","id":42,"result":{}}`', tools/rls/src/test/harness.rs:227:9
[01:31:46] 
[01:31:46] 
[01:31:46] failures:
[01:31:46]     test::test_goto_def
[01:31:46]     test::test_highlight
[01:31:46]     test::test_hover
[01:31:46]     test::test_rename
[01:31:46] 
[01:31:46] test result: FAILED. 87 passed; 4 failed; 1 ignored; 0 measured; 0 filtered out

@petrochenkov
Copy link
Contributor

@nrc
This did caused ICEs elsewhere - #55376.

bors added a commit that referenced this pull request Oct 31, 2018
save-analysis: bug fix and optimisation.

The first commit fixes a bug in name resolution and save-analysis (introduced in #54145) and removes an unused parameter. This fixes the RLS tests, which are currently blocking distribution of the RLS. The second commit removes macro uses from save-analysis data, since these are never used, they just take up space.

r? @petrochenkov
bors added a commit that referenced this pull request Nov 1, 2018
save-analysis: bug fix and optimisation.

The first commit fixes a bug in name resolution and save-analysis (introduced in #54145) and removes an unused parameter. This fixes the RLS tests, which are currently blocking distribution of the RLS. The second commit removes macro uses from save-analysis data, since these are never used, they just take up space.

r? @petrochenkov
@nikomatsakis nikomatsakis added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Nov 19, 2018
@nikomatsakis nikomatsakis mentioned this pull request Nov 20, 2018
20 tasks
nikomatsakis pushed a commit to nikomatsakis/rust that referenced this pull request Nov 20, 2018
Give each PathSegment a NodeId

Store a resolved def on hir::PathSegment

save-analysis: remove hacky, unnecessary code now that we have spans for every ident

dump data for prefix path segments

dump refs for path segments in save-analysis

Requires adding path segments to the hir map

Fix tests and rustdoc

save-analysis: handle missing field names

FIxes rust-lang/rls#1031

rebasing and reviewer changes

Primarily refactoring `(Ident, Option<NodeId>)` to `Segment`

Fix tests and assertions; add some comments

more reviewer changes
@alexcrichton alexcrichton added beta-accepted Accepted for backporting to the compiler in the beta channel. and removed beta-nominated Nominated for backporting to the compiler in the beta channel. labels Nov 20, 2018
bors added a commit that referenced this pull request Nov 20, 2018
beta backport rollup

Backports of some beta-approved PRs

- [x] #55385: NLL: cast causes failure to promote to static
- [x] #56043: remove "approx env bounds" if we already know from trait
- [x] #56003: do not propagate inferred bounds on trait objects if they involve `Self`
- [x] #55852: Rewrite `...` as `..=` as a `MachineApplicable` 2018 idiom lint
- [x] #55804: rustdoc: don't inline `pub use some_crate` unless directly asked to
- [x] #56059: Increase `Duration` approximate equal threshold to 1us
- [x]  Keep resolved defs in path prefixes and emit them in save-analysis #54145
- [x]  Adjust Ids of path segments in visibility modifiers #55487
- [x]  save-analysis: bug fix and optimisation. #55521
- [x]   save-analysis: be even more aggressive about ignorning macro-generated defs #55936
- [x]  save-analysis: fallback to using path id #56060
- [x]  save-analysis: Don't panic for macro-generated use globs #55879
- [x]  Add temporary renames to manifests for rustfmt/clippy #56081
- [x] Revert #51601 #56049
- [x]  Fix stability hole with `static _` #55983
- [x] #56077
- [x] Fix Rustdoc ICE when checking blanket impls #55258
- [x]  Updated RELEASES.md for 1.31.0 #55678
- [x] ~~#56061~~ #56111
- [x]  Stabilize `extern_crate_item_prelude` #56032

Still running tests locally, and I plan to backport @nrc's other PRs too

(cc @petrochenkov -- thanks for the advice)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.