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

Rename _ to {integer} and {float} for unknown numeric types #35080

Merged
merged 2 commits into from
Jul 30, 2016

Conversation

sophiajt
Copy link
Contributor

@sophiajt sophiajt commented Jul 28, 2016

This PR renames _ to {integer} or {float} for unknown numeric types, to help people parse error messages that have numeric types that haven't been nailed down.

Example:

fn main() {
    let x: String = 4;
}

Before:

error[E0308]: mismatched types
 --> quicktest.rs:2:21
  |
2 |     let x: String = 4;
  |                     ^ expected struct `std::string::String`, found integral variable
  |
  = note: expected type `std::string::String`
  = note:    found type `_`

error: aborting due to previous error

after:

error[E0308]: mismatched types
 --> quicktest.rs:2:21
  |
2 |     let x: String = 4;
  |                     ^ expected struct `std::string::String`, found integral variable
  |
  = note: expected type `std::string::String`
  = note:    found type `{integer}`

error: aborting due to previous error

@rust-highfive
Copy link
Collaborator

r? @eddyb

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

@eddyb
Copy link
Member

eddyb commented Jul 28, 2016

Keep in mind that integer and floating-point inference variables are different and sometimes it's helpful to tell them apart.

@eddyb
Copy link
Member

eddyb commented Jul 28, 2016

cc @nikomatsakis @nrc

@sophiajt
Copy link
Contributor Author

@eddyb - agreed. I can change this to make that more explicit. Since being more explicit can also make types more cumbersome, I wanted to start simple.

@sophiajt
Copy link
Contributor Author

We could use {float} and {integer}...

@nrc
Copy link
Member

nrc commented Jul 28, 2016

+1, this is a great change. I like having float and integer. Bikeshed: I would prefer <float> rather than {float} the former suggests something generic (which this is), the latter suggests a struct or block, which this isn't.

@eddyb
Copy link
Member

eddyb commented Jul 28, 2016

@nrc Small problem is with generics, e.g. Option<<integer>>.

@sophiajt
Copy link
Contributor Author

sophiajt commented Jul 28, 2016

@nrc - yeah, I tried it with first, but like @eddyb points out, this gets confusing as you put them in generics with things like Thing<<numeric>, <numeric>>. The {numeric} seemed a slightly better solution. Thing<{numeric}, {numeric}>. Not perfect, but we don't have a lot to work with.

@nikomatsakis
Copy link
Contributor

r=me on the patch, do we want to solicit any more feedback? Or just run with it? (I'm happy either way)

@eddyb
Copy link
Member

eddyb commented Jul 28, 2016

Should update the PR title and description to use {integer}.

@sophiajt sophiajt changed the title Rename _ to {numeric} for unknown numeric types Rename _ to {integer} and {float} for unknown numeric types Jul 28, 2016
@sophiajt
Copy link
Contributor Author

@eddyb - done

@petrochenkov
Copy link
Contributor

This is awesome, such a small fix and such a fundamental improvement. Why haven't this been done years ago?

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jul 28, 2016

📌 Commit ea77049 has been approved by nikomatsakis

@alexcrichton
Copy link
Member

@bors: rollup

assuming this isn't very platform-specific and green travis means it's good to go whenever

steveklabnik added a commit to steveklabnik/rust that referenced this pull request Jul 30, 2016
…d_found, r=nikomatsakis

Rename _ to {integer} and {float} for unknown numeric types

This PR renames _ to {integer} or {float} for unknown numeric types, to help people parse error messages that have numeric types that haven't been nailed down.

Example:
```rust
fn main() {
    let x: String = 4;
}
```

Before:
```
error[E0308]: mismatched types
 --> quicktest.rs:2:21
  |
2 |     let x: String = 4;
  |                     ^ expected struct `std::string::String`, found integral variable
  |
  = note: expected type `std::string::String`
  = note:    found type `_`

error: aborting due to previous error
```

after:
```
error[E0308]: mismatched types
 --> quicktest.rs:2:21
  |
2 |     let x: String = 4;
  |                     ^ expected struct `std::string::String`, found integral variable
  |
  = note: expected type `std::string::String`
  = note:    found type `{integer}`

error: aborting due to previous error
```
```
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 30, 2016
…d_found, r=nikomatsakis

Rename _ to {integer} and {float} for unknown numeric types

This PR renames _ to {integer} or {float} for unknown numeric types, to help people parse error messages that have numeric types that haven't been nailed down.

Example:
```rust
fn main() {
    let x: String = 4;
}
```

Before:
```
error[E0308]: mismatched types
 --> quicktest.rs:2:21
  |
2 |     let x: String = 4;
  |                     ^ expected struct `std::string::String`, found integral variable
  |
  = note: expected type `std::string::String`
  = note:    found type `_`

error: aborting due to previous error
```

after:
```
error[E0308]: mismatched types
 --> quicktest.rs:2:21
  |
2 |     let x: String = 4;
  |                     ^ expected struct `std::string::String`, found integral variable
  |
  = note: expected type `std::string::String`
  = note:    found type `{integer}`

error: aborting due to previous error
```
```
bors added a commit that referenced this pull request Jul 30, 2016
Rollup of 8 pull requests

- Successful merges: #35049, #35058, #35063, #35080, #35090, #35094, #35104, #35106
- Failed merges:
@bors bors merged commit ea77049 into rust-lang:master Jul 30, 2016
@sophiajt sophiajt deleted the fix_numeric_expected_found branch August 9, 2016 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants