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

Merged
merged 2 commits into from Jul 30, 2016

Conversation

Projects
None yet
8 participants
@jonathandturner
Contributor

jonathandturner 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

This comment has been minimized.

Show comment
Hide comment
@rust-highfive

rust-highfive Jul 28, 2016

Collaborator

r? @eddyb

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

Collaborator

rust-highfive commented Jul 28, 2016

r? @eddyb

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

@eddyb

This comment has been minimized.

Show comment
Hide comment
@eddyb

eddyb Jul 28, 2016

Member

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

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

This comment has been minimized.

Show comment
Hide comment
Member

eddyb commented Jul 28, 2016

@jonathandturner

This comment has been minimized.

Show comment
Hide comment
@jonathandturner

jonathandturner Jul 28, 2016

Contributor

@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.

Contributor

jonathandturner commented Jul 28, 2016

@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.

@jonathandturner

This comment has been minimized.

Show comment
Hide comment
@jonathandturner

jonathandturner Jul 28, 2016

Contributor

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

Contributor

jonathandturner commented Jul 28, 2016

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

@nrc

This comment has been minimized.

Show comment
Hide comment
@nrc

nrc Jul 28, 2016

Member

+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.

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

This comment has been minimized.

Show comment
Hide comment
@eddyb

eddyb Jul 28, 2016

Member

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

Member

eddyb commented Jul 28, 2016

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

@jonathandturner

This comment has been minimized.

Show comment
Hide comment
@jonathandturner

jonathandturner Jul 28, 2016

Contributor

@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.

Contributor

jonathandturner 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

This comment has been minimized.

Show comment
Hide comment
@nikomatsakis

nikomatsakis Jul 28, 2016

Contributor

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

Contributor

nikomatsakis commented Jul 28, 2016

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

@eddyb

This comment has been minimized.

Show comment
Hide comment
@eddyb

eddyb Jul 28, 2016

Member

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

Member

eddyb commented Jul 28, 2016

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

@jonathandturner jonathandturner changed the title from Rename _ to {numeric} for unknown numeric types to Rename _ to {integer} and {float} for unknown numeric types Jul 28, 2016

@jonathandturner

This comment has been minimized.

Show comment
Hide comment
@jonathandturner

jonathandturner Jul 28, 2016

Contributor

@eddyb - done

Contributor

jonathandturner commented Jul 28, 2016

@eddyb - done

@petrochenkov

This comment has been minimized.

Show comment
Hide comment
@petrochenkov

petrochenkov Jul 28, 2016

Contributor

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

Contributor

petrochenkov commented Jul 28, 2016

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

@nikomatsakis

This comment has been minimized.

Show comment
Hide comment
Contributor

nikomatsakis commented Jul 28, 2016

@bors r+

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Jul 28, 2016

Contributor

📌 Commit ea77049 has been approved by nikomatsakis

Contributor

bors commented Jul 28, 2016

📌 Commit ea77049 has been approved by nikomatsakis

@alexcrichton

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton Jul 29, 2016

Member

@bors: rollup

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

Member

alexcrichton commented Jul 29, 2016

@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

Rollup merge of #35080 - jonathandturner:fix_numeric_expected_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

Auto merge of #35125 - steveklabnik:rollup, r=steveklabnik
Rollup of 11 pull requests

- Successful merges: #34904, #35004, #35049, #35058, #35060, #35063, #35080, #35090, #35094, #35104, #35106
- Failed merges:

Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 30, 2016

Rollup merge of #35080 - jonathandturner:fix_numeric_expected_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

Auto merge of #35127 - Manishearth:rollup, r=Manishearth
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

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@jonathandturner jonathandturner deleted the jonathandturner:fix_numeric_expected_found branch Aug 9, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment