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

Indicate origin of where type parameter for uninferred types #67285

Merged

Conversation

ohadravid
Copy link
Contributor

@ohadravid ohadravid commented Dec 13, 2019

Based on #65951 (which is not merge yet), fixes #67277.

This PR improves a little the diagnostic for code like:

 async fn foo() { 
     bar().await; 
}

 async fn bar<T>() -> () {} 

by showing:

error[E0698]: type inside `async fn` body must be known in this context
 --> unresolved_type_param.rs:9:5
  |
9 |     bar().await;
  |     ^^^ cannot infer type for type parameter `T` declared on the function `bar`
  |
...

(The

declared on the function `bar`

part is new)

A small side note: Vec and slice seem to resist this change, because querying item_name() panics, and get_opt_name() returns None.

r? @estebank

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 13, 2019
@ohadravid ohadravid changed the title Indicate origin of where type parameter Indicate origin of where type parameter for uninferred types Dec 13, 2019
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.

Looks good to me!

Left some formatting nitpicks, but r=me once CI is green and the parent PR has landed.

src/librustc/infer/error_reporting/need_type_info.rs Outdated Show resolved Hide resolved
src/librustc/infer/error_reporting/need_type_info.rs Outdated Show resolved Hide resolved
src/librustc/infer/mod.rs Outdated Show resolved Hide resolved
@ohadravid ohadravid force-pushed the indicate-origin-of-where-type-parameter branch 2 times, most recently from ed42b11 to 3a08b8a Compare December 13, 2019 21:58
@estebank
Copy link
Contributor

r=me

@ohadravid ohadravid force-pushed the indicate-origin-of-where-type-parameter branch from 3a08b8a to 8a4632d Compare December 14, 2019 10:10
@ohadravid
Copy link
Contributor Author

@estebank done! CI is green, the PR is rebased 🎉

@estebank
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Dec 14, 2019

📌 Commit 8a4632d has been approved by estebank

@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 Dec 14, 2019
Centril added a commit to Centril/rust that referenced this pull request Dec 15, 2019
…type-parameter, r=estebank

Indicate origin of where type parameter for uninferred types

Based on rust-lang#65951 (which is not merge yet), fixes rust-lang#67277.

This PR improves a little the diagnostic for code like:

```
 async fn foo() {
     bar().await;
}

 async fn bar<T>() -> () {}
```

by showing:
```
error[E0698]: type inside `async fn` body must be known in this context
 --> unresolved_type_param.rs:9:5
  |
9 |     bar().await;
  |     ^^^ cannot infer type for type parameter `T` declared on the function `bar`
  |
...
```
(The
```
declared on the function `bar`
```
part is new)

A small side note: `Vec` and `slice` seem to resist this change, because querying `item_name()` panics, and `get_opt_name()` returns `None`.

r? @estebank
Centril added a commit to Centril/rust that referenced this pull request Dec 15, 2019
…type-parameter, r=estebank

Indicate origin of where type parameter for uninferred types

Based on rust-lang#65951 (which is not merge yet), fixes rust-lang#67277.

This PR improves a little the diagnostic for code like:

```
 async fn foo() {
     bar().await;
}

 async fn bar<T>() -> () {}
```

by showing:
```
error[E0698]: type inside `async fn` body must be known in this context
 --> unresolved_type_param.rs:9:5
  |
9 |     bar().await;
  |     ^^^ cannot infer type for type parameter `T` declared on the function `bar`
  |
...
```
(The
```
declared on the function `bar`
```
part is new)

A small side note: `Vec` and `slice` seem to resist this change, because querying `item_name()` panics, and `get_opt_name()` returns `None`.

r? @estebank
bors added a commit that referenced this pull request Dec 15, 2019
Rollup of 6 pull requests

Successful merges:

 - #65778 (Stabilize `std::{rc,sync}::Weak::{weak_count, strong_count}`)
 - #66570 (stabilize Result::map_or)
 - #67206 (Update cargo, books)
 - #67285 (Indicate origin of where type parameter for uninferred types )
 - #67317 (fix type_name_of_val doc comment)
 - #67324 (Fix repetition in matches/mod.rs)

Failed merges:

r? @ghost
@bors
Copy link
Contributor

bors commented Dec 16, 2019

⌛ Testing commit 8a4632d with merge 8c51da8582a54d63bca13d59dc4817b02ab71aa9...

@rust-highfive
Copy link
Collaborator

Your PR failed (pretty log, 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.
2019-12-16T07:42:11.0298387Z do so (now or later) by using -b with the checkout command again. Example:
2019-12-16T07:42:11.0298812Z 
2019-12-16T07:42:11.0301717Z   git checkout -b <new-branch-name>
2019-12-16T07:42:11.0301807Z 
2019-12-16T07:42:11.0302750Z HEAD is now at 8c51da858 Auto merge of #67285 - ohadravid:indicate-origin-of-where-type-parameter, r=estebank
2019-12-16T07:42:11.0699952Z ##[section]Starting: Setup environment
2019-12-16T07:42:11.0809284Z ==============================================================================
2019-12-16T07:42:11.0809379Z Task         : Bash
2019-12-16T07:42:11.0809441Z Description  : Run a Bash script on macOS, Linux, or Windows
---
2019-12-16T07:42:13.6746111Z  async fn bar<T>() -> () {}
2019-12-16T07:42:13.6746214Z  async fn foo() {
2019-12-16T07:42:13.6746619Z (The
2019-12-16T07:42:13.6746707Z ...
2019-12-16T07:42:13.6746822Z 9 |     bar().await;
2019-12-16T07:42:13.6747420Z A small side note: `Vec` and `slice` seem to resist this change, because querying `item_name()` panics, and `get_opt_name()` returns `None`.
2019-12-16T07:42:13.6748180Z AGENT_DISABLELOGPLUGIN_TESTFILEPUBLISHERPLUGIN=true
2019-12-16T07:42:13.6748284Z AGENT_DISABLELOGPLUGIN_TESTRESULTLOGPLUGIN=true
2019-12-16T07:42:13.6748668Z AGENT_HOMEDIRECTORY=C:\agents\2.163.1
2019-12-16T07:42:13.6748778Z AGENT_ID=509
---
2019-12-16T07:42:13.6762235Z BUILD_SOURCEBRANCHNAME=auto
2019-12-16T07:42:13.6762634Z BUILD_SOURCESDIRECTORY=D:\a\1\s
2019-12-16T07:42:13.6762748Z BUILD_SOURCEVERSION=8c51da8582a54d63bca13d59dc4817b02ab71aa9
2019-12-16T07:42:13.6763306Z BUILD_SOURCEVERSIONAUTHOR=bors
2019-12-16T07:42:13.6763996Z BUILD_SOURCEVERSIONMESSAGE=Auto merge of #67285 - ohadravid:indicate-origin-of-where-type-parameter, r=estebank
2019-12-16T07:42:13.6764470Z BUILD_STAGINGDIRECTORY=D:\a\1\a
2019-12-16T07:42:13.6764621Z Based on #65951 (which is not merge yet), fixes #67277.
2019-12-16T07:42:13.6764828Z COBERTURA_HOME=C:\cobertura-2.1.1
2019-12-16T07:42:13.6765255Z COMMONPROGRAMFILES=C:\Program Files\Common Files
2019-12-16T07:42:13.6765374Z COMMON_TESTRESULTSDIRECTORY=D:\a\1\TestResults
2019-12-16T07:42:13.6765788Z COMPUTERNAME=fv-az433
---
2019-12-16T07:42:13.6806353Z ```
2019-12-16T07:42:13.6806781Z ```
2019-12-16T07:42:13.6806868Z ```
2019-12-16T07:42:13.6806974Z agent.jobstatus=Succeeded
2019-12-16T07:42:13.6807363Z by showing:
2019-12-16T07:42:13.6807492Z declared on the function `bar`
2019-12-16T07:42:13.6807585Z error[E0698]: type inside `async fn` body must be known in this context
2019-12-16T07:42:13.6807686Z part is new)
2019-12-16T07:42:13.6807842Z }
2019-12-16T07:42:13.6807879Z 
2019-12-16T07:42:13.6807996Z disk usage:
2019-12-16T07:42:13.6808411Z Filesystem            Size  Used Avail Use% Mounted on
---
2019-12-16T07:42:26.1508272Z Chocolatey v0.10.15
2019-12-16T07:42:53.8281325Z Installing the following packages:
2019-12-16T07:42:53.8289482Z msys2
2019-12-16T07:42:53.8293615Z By installing you accept licenses for the packages.
2019-12-16T07:44:34.4734654Z Error retrieving packages from source 'https://chocolatey.org/api/v2/':
2019-12-16T07:44:34.4735127Z  Could not connect to the feed specified at 'https://chocolatey.org/api/v2/'. Please verify that the package source (located in the Package Manager Settings) is valid and ensure your network connectivity.
2019-12-16T07:44:34.4743355Z msys2 not installed. The package was not found with the source(s) listed.
2019-12-16T07:44:34.4743494Z  Source(s): 'https://chocolatey.org/api/v2/'
2019-12-16T07:44:34.4743665Z  NOTE: When you specify explicit sources, it overrides default sources.
2019-12-16T07:44:34.4743793Z If the package version is a prerelease and you didn't specify `--pre`,
2019-12-16T07:44:34.4743987Z Please see https://chocolatey.org/docs/troubleshooting for more 
2019-12-16T07:44:34.4744065Z  assistance.
2019-12-16T07:44:34.4855441Z 
2019-12-16T07:44:34.4855686Z Chocolatey installed 0/1 packages. 1 packages failed.
2019-12-16T07:44:34.4855686Z Chocolatey installed 0/1 packages. 1 packages failed.
2019-12-16T07:44:34.4855789Z  See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
2019-12-16T07:44:34.4862399Z 
2019-12-16T07:44:34.4867213Z Failures
2019-12-16T07:44:34.4874833Z  - msys2 - msys2 not installed. The package was not found with the source(s) listed.
2019-12-16T07:44:34.4874997Z  Source(s): 'https://chocolatey.org/api/v2/'
2019-12-16T07:44:34.4875094Z  NOTE: When you specify explicit sources, it overrides default sources.
2019-12-16T07:44:34.4875243Z If the package version is a prerelease and you didn't specify `--pre`,
2019-12-16T07:44:34.4875451Z Please see https://chocolatey.org/docs/troubleshooting for more 
2019-12-16T07:44:34.4875557Z  assistance.
2019-12-16T07:44:34.4887154Z 
2019-12-16T07:44:34.4887507Z Enjoy using Chocolatey? Explore more amazing features to take your
2019-12-16T07:44:34.4887507Z Enjoy using Chocolatey? Explore more amazing features to take your
2019-12-16T07:44:34.4887608Z experience to the next level at
2019-12-16T07:44:34.4887707Z  https://chocolatey.org/compare
2019-12-16T07:44:34.8420196Z 
2019-12-16T07:44:34.8513360Z ##[error]Bash exited with code '1'.
2019-12-16T07:44:34.8649698Z ##[section]Starting: Checkout
2019-12-16T07:44:34.8800539Z ==============================================================================
2019-12-16T07:44:34.8800658Z Task         : Get sources
2019-12-16T07:44:34.8800750Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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 Dec 16, 2019

💔 Test failed - checks-azure

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 16, 2019
@Centril
Copy link
Contributor

Centril commented Dec 16, 2019

@bors retry

@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 Dec 16, 2019
Centril added a commit to Centril/rust that referenced this pull request Dec 20, 2019
…type-parameter, r=estebank

Indicate origin of where type parameter for uninferred types

Based on rust-lang#65951 (which is not merge yet), fixes rust-lang#67277.

This PR improves a little the diagnostic for code like:

```
 async fn foo() {
     bar().await;
}

 async fn bar<T>() -> () {}
```

by showing:
```
error[E0698]: type inside `async fn` body must be known in this context
 --> unresolved_type_param.rs:9:5
  |
9 |     bar().await;
  |     ^^^ cannot infer type for type parameter `T` declared on the function `bar`
  |
...
```
(The
```
declared on the function `bar`
```
part is new)

A small side note: `Vec` and `slice` seem to resist this change, because querying `item_name()` panics, and `get_opt_name()` returns `None`.

r? @estebank
Centril added a commit to Centril/rust that referenced this pull request Dec 20, 2019
…type-parameter, r=estebank

Indicate origin of where type parameter for uninferred types

Based on rust-lang#65951 (which is not merge yet), fixes rust-lang#67277.

This PR improves a little the diagnostic for code like:

```
 async fn foo() {
     bar().await;
}

 async fn bar<T>() -> () {}
```

by showing:
```
error[E0698]: type inside `async fn` body must be known in this context
 --> unresolved_type_param.rs:9:5
  |
9 |     bar().await;
  |     ^^^ cannot infer type for type parameter `T` declared on the function `bar`
  |
...
```
(The
```
declared on the function `bar`
```
part is new)

A small side note: `Vec` and `slice` seem to resist this change, because querying `item_name()` panics, and `get_opt_name()` returns `None`.

r? @estebank
bors added a commit that referenced this pull request Dec 20, 2019
Rollup of 7 pull requests

Successful merges:

 - #66755 (Remove a const-if-hack in RawVec)
 - #67127 (Use structured suggestion for disambiguating method calls)
 - #67219 (Fix up Command Debug output when arg0 is specified.)
 - #67285 (Indicate origin of where type parameter for uninferred types )
 - #67328 (Remove now-redundant range check on u128 -> f32 casts)
 - #67367 (Move command line option definitions into a dedicated file)
 - #67442 (Remove `SOCK_CLOEXEC` dummy variable on platforms that don't use it.)

Failed merges:

r? @ghost
@bors bors merged commit 8a4632d into rust-lang:master Dec 20, 2019
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.

indicate origin of where type parameter for uninferred types
5 participants