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

Properly display note/expected details #39905

Merged
merged 1 commit into from
Feb 25, 2017
Merged

Conversation

estebank
Copy link
Contributor

@estebank estebank commented Feb 17, 2017

Given a file

fn takes_cb(f: fn(i8)) {}

fn main() {
    fn callback(x: i32) {}
    takes_cb(callback)
}

output

error[E0308]: mismatched types
 --> file2.rs:5:22
  |
5 |             takes_cb(callback)
  |                      ^^^^^^^^ expected i8, found i32
  |
  = note: expected type `fn(i8)`
             found type `fn(i32) {main::callback}`

Fix #39343.

@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 Feb 17, 2017

r? @jonathandturner
cc @nagisa @nikomatsakis

@rust-highfive rust-highfive assigned sophiajt and unassigned eddyb Feb 17, 2017
@nagisa
Copy link
Member

nagisa commented Feb 17, 2017

Can we get a ui regression test (the more the better – even a UI test derived from one of affected (with red diff) compile-fail tests would be nice). Other than that it LGTM.

@arielb1
Copy link
Contributor

arielb1 commented Feb 17, 2017

@nagisa

The important tests are the "affected with green diff" tests, and I think the error message covers these up nicely.

@bors r+

@bors
Copy link
Contributor

bors commented Feb 17, 2017

📌 Commit b2f1fb2 has been approved by arielb1

@estebank
Copy link
Contributor Author

@arielb1 Had to fix typo in test.

@sophiajt
Copy link
Contributor

Are these the only tests affected? I would have thought dozens of tests would need to be updated.

@estebank
Copy link
Contributor Author

estebank commented Feb 19, 2017

@jonathandturner I thought the same thing, but after a cursory check the specific cases where this error would trigger (type errors where the inner Tys were primitives while the actual Tys were not, like structs or closures) don't happen as often in the tests (which I guess contributed to this being undetected for so long).

There were a few tests that could have triggered this, had they not used structs or enums defined in the test for the arg types.

This triggers the error:

fn takes_cb(f: fn(i8)) {}

fn main() {
    fn callback(x: i32) {}
    takes_cb(callback)
}

while this doesn't:

struct A {}
struct B {}

fn takes_cb(f: fn(A)) {}

fn main() {
    fn callback(x: B) {}
    takes_cb(callback)
}

@nikomatsakis
Copy link
Contributor

@bors r=arielb1

@bors
Copy link
Contributor

bors commented Feb 23, 2017

📌 Commit 038a166 has been approved by arielb1

frewsxcv added a commit to frewsxcv/rust that referenced this pull request Feb 24, 2017
Properly display note/expected details

Given a file

```rust
fn takes_cb(f: fn(i8)) {}

fn main() {
    fn callback(x: i32) {}
    takes_cb(callback)
}
```

output

```rust
error[E0308]: mismatched types
 --> file2.rs:5:22
  |
5 |             takes_cb(callback)
  |                      ^^^^^^^^ expected i8, found i32
  |
  = note: expected type `fn(i8)`
             found type `fn(i32) {main::callback}`
```

Fix rust-lang#39343.
bors added a commit that referenced this pull request Feb 24, 2017
Rollup of 17 pull requests

- Successful merges: #39777, #39815, #39845, #39886, #39892, #39903, #39905, #39914, #39927, #39940, #40010, #40030, #40048, #40050, #40052, #40060, #40071
- Failed merges:
eddyb added a commit to eddyb/rust that referenced this pull request Feb 25, 2017
Properly display note/expected details

Given a file

```rust
fn takes_cb(f: fn(i8)) {}

fn main() {
    fn callback(x: i32) {}
    takes_cb(callback)
}
```

output

```rust
error[E0308]: mismatched types
 --> file2.rs:5:22
  |
5 |             takes_cb(callback)
  |                      ^^^^^^^^ expected i8, found i32
  |
  = note: expected type `fn(i8)`
             found type `fn(i32) {main::callback}`
```

Fix rust-lang#39343.
eddyb added a commit to eddyb/rust that referenced this pull request Feb 25, 2017
Properly display note/expected details

Given a file

```rust
fn takes_cb(f: fn(i8)) {}

fn main() {
    fn callback(x: i32) {}
    takes_cb(callback)
}
```

output

```rust
error[E0308]: mismatched types
 --> file2.rs:5:22
  |
5 |             takes_cb(callback)
  |                      ^^^^^^^^ expected i8, found i32
  |
  = note: expected type `fn(i8)`
             found type `fn(i32) {main::callback}`
```

Fix rust-lang#39343.
bors added a commit that referenced this pull request Feb 25, 2017
@bors bors merged commit 038a166 into rust-lang:master Feb 25, 2017
@bors
Copy link
Contributor

bors commented Feb 25, 2017

⌛ Testing commit 038a166 with merge 1572bf1...

@frewsxcv
Copy link
Member

Trying to fix bors, please ignore

@bors r-

@estebank estebank deleted the useless-error branch November 9, 2023 05:26
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.

9 participants