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

Improved error message when type must be bound due to generator. #59111

Merged
merged 1 commit into from
Apr 25, 2019

Conversation

gilescope
Copy link
Contributor

@gilescope gilescope commented Mar 11, 2019

Fixes #58930.

Keen to get some feedback - is this as minimal as we can get it or is there an existing visitor I could repurpose?

@rust-highfive
Copy link
Collaborator

r? @zackmdavis

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 11, 2019
@gilescope
Copy link
Contributor Author

(This PR is to fix #58930 )

src/librustc/infer/mod.rs Outdated Show resolved Hide resolved
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.

Wow, nice!

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.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.
travis_time:end:22139daf:start=1552950955234833528,finish=1552951029670501309,duration=74435667781
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
Setting environment variables from .travis.yml
---
[00:08:28]    Compiling syntax_ext v0.0.0 (/checkout/src/libsyntax_ext)
[00:08:48] error[E0061]: this function takes 2 parameters but 1 parameter was supplied
[00:08:48]    --> src/librustc/infer/error_reporting/need_type_info.rs:168:25
[00:08:48]     |
[00:08:48] 69  | /     pub fn extract_type_name(
[00:08:48] 70  | |         &self,
[00:08:48] 71  | |         ty: &'a Ty<'tcx>,
[00:08:48] 72  | |         highlight: Option<ty::print::RegionHighlightMode>,
[00:08:48] 88  | |         s
[00:08:48] 89  | |     }
[00:08:48]     | |_____- defined here
[00:08:48] ...
[00:08:48] ...
[00:08:48] 168 |           let name = self.extract_type_name(&ty);
[00:08:48] 
[00:09:02] error: aborting due to previous error
[00:09:02] 
[00:09:02] For more information about this error, try `rustc --explain E0061`.
---
travis_time:end:14c3a0e1:start=1552951582334241514,finish=1552951582339595020,duration=5353506
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0d1e3e28
$ 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 --batch -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:1daa473c
travis_time:start:1daa473c
$ 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 

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)

@gilescope
Copy link
Contributor Author

Penny drops - rust master has moved on. Will fetch upstream and diagnose.

@gilescope
Copy link
Contributor Author

gilescope commented Mar 20, 2019

The one thing I was wondering about was whether I could use the fully_resolve visitor in resolve.rs and map the TyVid inside the FixupError to a Ty and a Span...

I tried:

if let Err(FixupError::UnresolvedTy(x)) = self.fcx.fully_resolve(&ty) {
   let ty = self.fcx.probe_ty_var(x);

but alas the probe returned an error. I'm also not sure how to map a Ty (or TyVid) to the relevant span.

What we have works and is definitely an improvement on the status quo, just wondering if it could be done with less code / simpler.

@Dylan-DPC-zz
Copy link

ping from triage @zackmdavis awaiting your review on this

@gilescope
Copy link
Contributor Author

@nikomatsakis I think I've done all the requested changes?

@zackmdavis
Copy link
Member

(sorry I haven't really been involved here despite being tagged by @bors)

r? @nikomatsakis

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.

Hi @gilescope -- sorry for the delay. This looks basically good, but I left some nits.

src/librustc/diagnostics.rs Outdated Show resolved Hide resolved
src/librustc/infer/error_reporting/need_type_info.rs Outdated Show resolved Hide resolved
src/librustc/infer/resolve.rs Outdated Show resolved Hide resolved
@bors
Copy link
Contributor

bors commented Apr 18, 2019

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

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.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.
travis_time:end:04f8f6e4:start=1556007801982773210,finish=1556007802737137811,duration=754364601
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
travis_time:start:test_assembly
Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:14:51] 
[01:14:51] running 9 tests
[01:14:51] iiiiiiiii
[01:14:51] 
[01:14:51]  finished in 0.162
[01:14:51] travis_fold:end:test_assembly

---
travis_time:start:test_debuginfo
Check compiletest suite=debuginfo mode=debuginfo-both (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:15:07] 
[01:15:07] running 121 tests
[01:15:33] .iiiii...i.....i..i...i..i.i.i..i.ii...i.....i..i....i..........iiii..........i...ii...i.......ii.i. 100/121
[01:15:37] i.i......iii.i.....ii
[01:15:37] 
[01:15:37]  finished in 30.364
[01:15:37] travis_fold:end:test_debuginfo

---
[01:43:27] 
[01:43:27] failures:
[01:43:27] 
[01:43:27] ---- /checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md - Rust_Compiler_Error_Index::E0698 (line 11243) stdout ----
[01:43:27] error[E0670]: `async fn` is not permitted in the 2015 edition
[01:43:27]   |
[01:43:27]   |
[01:43:27] 4 | async fn bar<T>() -> () {}
[01:43:27] 
[01:43:27] 
[01:43:27] error[E0670]: `async fn` is not permitted in the 2015 edition
[01:43:27]   |
[01:43:27]   |
[01:43:27] 6 | async fn foo() {
[01:43:27] 
[01:43:27] error: aborting due to 2 previous errors
[01:43:27] 
[01:43:27] For more information about this error, try `rustc --explain E0670`.
---
[01:43:27] 
[01:43:27] 
[01:43:27] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:43:27] Build completed unsuccessfully in 0:40:09
[01:43:27] Makefile:48: recipe for target 'check' failed
[01:43:27] make: *** [check] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:2e7c3890
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Tue Apr 23 10:07:02 UTC 2019
---
travis_time:end:022a290a:start=1556014024082967818,finish=1556014024087678923,duration=4711105
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:03636af8
$ 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 --batch -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:008db78d
travis_time:start:008db78d
$ 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:0b9f2290
$ 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)

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.

Looks great! r=me with nits below fixed. Thanks!

src/librustc/error_codes.rs Show resolved Hide resolved
src/librustc/infer/resolve.rs Outdated Show resolved Hide resolved
src/librustc/infer/resolve.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/generator_interior.rs Outdated Show resolved Hide resolved
src/librustc/traits/project.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/generator_interior.rs Outdated Show resolved Hide resolved
@nikomatsakis
Copy link
Contributor

@bors delegate=gilescope

@gilescope -- this should mean that you can do @bors r=nikomatsakis once you've made the changes and rebased etc to approve the PR.

@bors
Copy link
Contributor

bors commented Apr 23, 2019

📌 Commit 262b2851abe6e7b4e2ebbac9c53e35a6c98e8005 has been approved by `nikomatsakis``

@bors
Copy link
Contributor

bors commented Apr 23, 2019

✌️ @gilescope can now approve this pull request

@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-review Status: Awaiting review from the assignee but also interested parties. labels Apr 23, 2019
@nikomatsakis
Copy link
Contributor

@bors r-

bors got a bit overeager there, I think.

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 23, 2019
Error now mentions type var name and span is highlighted.
@gilescope
Copy link
Contributor Author

(squashed as all looking good)

@gilescope
Copy link
Contributor Author

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Apr 25, 2019

📌 Commit 66e41bc has been approved by nikomatsakis

@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 Apr 25, 2019
@gilescope
Copy link
Contributor Author

@nikomatsakis great, hopefully that's a wrap.

@bors
Copy link
Contributor

bors commented Apr 25, 2019

⌛ Testing commit 66e41bc with merge 3991285...

bors added a commit that referenced this pull request Apr 25, 2019
Improved error message when type must be bound due to generator.

Fixes #58930.

Keen to get some feedback - is this as minimal as we can get it or is there an existing visitor I could repurpose?
@bors
Copy link
Contributor

bors commented Apr 25, 2019

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 25, 2019
@bors bors merged commit 66e41bc into rust-lang:master Apr 25, 2019
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.

async/await produces unspecific "type inside generator must be known in this context" error messages
9 participants