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

Fix build error on Rust 1.56 #84

Merged
merged 1 commit into from
Jun 6, 2022
Merged

Fix build error on Rust 1.56 #84

merged 1 commit into from
Jun 6, 2022

Conversation

mgeisler
Copy link
Owner

@mgeisler mgeisler commented Jun 6, 2022

Something changed between Rust 1.57 and 1.58 so that the slice pattern doesn’t work without an explicit type annotation in the earlier version. Without it, we get

error[E0277]: expected a `Fn<(char,)>` closure, found `[char; 3]`
   --> src/lib.rs:350:52
    |
350 |             let mut needs_cap = sentence.ends_with(punctuation);
    |                                                    ^^^^^^^^^^^ expected an `Fn<(char,)>` closure, found `[char; 3]`
    |
    = help: the trait `Fn<(char,)>` is not implemented for `[char; 3]`
    = note: required because of the requirements on the impl of `FnOnce<(char,)>` for `&[char; 3]`
    = note: required because of the requirements on the impl of `Pattern<'_>` for `&[char; 3]`

Between 1.57 and 1.58, the Pattern trait got a new implementation for [char; N], and I guess this somehow made the code work afterwards (even though we’re using a [char] here).

The problematic code change was introduced in #75.

Fixes #83.

mgeisler added a commit that referenced this pull request Jun 6, 2022
Back in 2020, I gave up on trying to keep the library compatible with
old Rust releases. This was with the 0.7.0 release which gave up
compatibility with Rust 1.31 (the first version of the 2018 edition).

Since then, the releases have roughly tracked the latest stable
release of Rust, with no particular urgency to bump this of course.

This is related to #83 where @WorldSEnder noticed that Lipsum no
longer compiles on Rust 1.56. This was easy to fix (#84), but we
should still remove the misleading badge.
Something changed between Rust 1.57 and 1.58 so that the slice pattern
doesn’t work without an explicit type annotation in the earlier
version. Without it, we get

```
error[E0277]: expected a `Fn<(char,)>` closure, found `[char; 3]`
   --> src/lib.rs:350:52
    |
350 |             let mut needs_cap = sentence.ends_with(punctuation);
    |                                                    ^^^^^^^^^^^ expected an `Fn<(char,)>` closure, found `[char; 3]`
    |
    = help: the trait `Fn<(char,)>` is not implemented for `[char; 3]`
    = note: required because of the requirements on the impl of `FnOnce<(char,)>` for `&[char; 3]`
    = note: required because of the requirements on the impl of `Pattern<'_>` for `&[char; 3]`
```

Between 1.57 and 1.58, the `Pattern` trait got a new implementation
for `[char; N]`, and I guess this somehow made the code work
afterwards (even though we’re using a `[char]` here).

The problematic code change was introduced in #75.

Fixes #83.
@mgeisler mgeisler enabled auto-merge June 6, 2022 21:17
@mgeisler mgeisler merged commit 2ddc2eb into master Jun 6, 2022
@mgeisler mgeisler deleted the fix-1.56-build branch June 6, 2022 21:20
@github-actions github-actions bot mentioned this pull request Jun 6, 2022
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.

Clarify minimal support rust version
1 participant