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

Function pointer types never display higher-ranked region when they are used as argument types #44887

Closed
tirr-c opened this issue Sep 27, 2017 · 0 comments · Fixed by #44888
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lifetimes Area: Lifetimes / regions T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@tirr-c
Copy link
Contributor

tirr-c commented Sep 27, 2017

fn f<F>(_: F) where F: for<'a> Fn(&'a u8, for<'b> fn(&'b u8)) {}

fn main() {
    f(|_: (), _: ()| {});
}
error[E0631]: type mismatch in closure arguments
 --> src/main.rs:4:5
  |
4 |     f(|_: (), _: ()| {});
  |     ^ ----------------- found signature of `fn((), ()) -> _`
  |     |
  |     expected signature of `for<'a> fn(&'a u8, fn(&'b u8)) -> _`
  |
  = note: required by `f`

Here, only for<'b> is omitted.

Meta

$ rustc --version --verbose
rustc 1.22.0-nightly (930d3b17d 2017-09-26)
binary: rustc
commit-hash: 930d3b17dd91b6564cf535ac717c688db757be5d
commit-date: 2017-09-26
host: x86_64-unknown-linux-gnu
release: 1.22.0-nightly
LLVM version: 4.0
@tirr-c tirr-c changed the title function pointer types never display higher-ranked region when it is used as argument types Function pointer types never display higher-ranked region when it is used as argument types Sep 27, 2017
@tirr-c tirr-c changed the title Function pointer types never display higher-ranked region when it is used as argument types Function pointer types never display higher-ranked region when they are used as argument types Sep 27, 2017
@aidanhs aidanhs added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Sep 28, 2017
bors added a commit that referenced this issue Oct 11, 2017
Refactor fmt::Display and fmt::Debug impls in ppaux

Also fixes #44887.

There was a problem that unnamed late-bound regions are *always* named `'r` while they are displayed using `std::fmt::Display`.

---

```rust
fn main() {
    f(|_: (), _: ()| {});
}
fn f<F>(_: F) where F: Fn(&(), for<'r> fn(&'r ())) {}
```

Before (incorrectly shadows lifetime, `for<'r>` omitted for the second argument):

```
error[E0631]: type mismatch in closure arguments
 --> test.rs:2:5
  |
2 |     f(|_: (), _: ()| {});
  |     ^ ----------------- found signature of `fn((), ()) -> _`
  |     |
  |     expected signature of `for<'r> fn(&'r (), fn(&'r ())) -> _`
  |
  = note: required by `f`
```

After:

```
error[E0631]: type mismatch in closure arguments
 --> test.rs:2:5
  |
2 |     f(|_: (), _: ()| {});
  |     ^ ----------------- found signature of `fn((), ()) -> _`
  |     |
  |     expected signature of `for<'s> fn(&'s (), for<'r> fn(&'r ())) -> _`
  |
  = note: required by `f`
```

r? @nikomatsakis
@jieyouxu jieyouxu added A-diagnostics Area: Messages for errors, warnings, and lints A-lifetimes Area: Lifetimes / regions T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lifetimes Area: Lifetimes / regions T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants