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

Clarify minimal support rust version #83

Closed
WorldSEnder opened this issue May 30, 2022 · 3 comments · Fixed by #84
Closed

Clarify minimal support rust version #83

WorldSEnder opened this issue May 30, 2022 · 3 comments · Fixed by #84

Comments

@WorldSEnder
Copy link

WorldSEnder commented May 30, 2022

The recent update to 0.8.1 breaks when compiling with rust 1.56:

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]`

error[E0277]: expected a `Fn<(char,)>` closure, found `[char; 3]`
   --> src/lib.rs:362:44
    |
362 |                 needs_cap = word.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]`

error[E0277]: expected a `Fn<(char,)>` closure, found `[char; 3]`
   --> src/lib.rs:366:36
    |
366 |             if !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]`

For more information about this error, try `rustc --explain E0277`.

I'm not certain what's the underlying cause for this change (the repo is still tagged with rust 1.31, but reading #77 leads me to believe the tag is outdated). Most likely cause to me is this commit: 72c48a1

In any case, edition 2021 is part of 1.56.0 so at least that part shouldn't be an issue. Can you clarify the minimal supported compiler version, thanks :)


Breaking downstream CI: https://github.com/yewstack/yew/runs/6649247160?check_suite_focus=true#step:5:24

@mgeisler
Copy link
Owner

mgeisler commented Jun 6, 2022

Hi @WorldSEnder,

Thanks a lot for letting me know! I had forgotten about the badge in the README! Let me clean that up ASAP...

Testing with different versions of Rust shows that str::ends_with works with a &[char] from 1.58 onwards. Testing more, shows that the problem here is the lack of an explicit type annotation. That is, this works fine on 1.56:

            let punctuation: &[char] = &['.', '!', '?'];

I'm not sure why, but when I compare the 1.56.1 Pattern page with the 1.58.0 page, I see that it grew support for [char; N]. So perhaps this is what enabled the code to to compile after 1.58?

I'll fix this and push out a new release!

mgeisler added a commit that referenced this issue 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 issue 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.
mgeisler added a commit that referenced this issue 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.
mgeisler added a commit that referenced this issue 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
Copy link
Owner

mgeisler commented Jun 9, 2022

The newly released 0.8.2 version makes the library build again on 1.56.0.

I realized that I never actually answered your question about the minimum supported version: back in 2020, I stopped trying to make lipsum compile with Rust 1.31 (first version to suppor the 2018 edition). That happened in 9d622cc, where I describe the problem a bit: repeated build failures even when nothing had changed in lipsum. It became frustrating to see CI fail when fixing, e.g., a totally safe thing such as a typo in the README.

So, I've been tracking the latest stable Rust release since — with no hurry to push up the required version, of course. I would be happy to try again with the 2021 edition, perhaps the Rust community have slowed down a bit so that this is feasible now. I'll try with #90 which adds Rust 1.56 to CI and then we can see how it goes.

@WorldSEnder
Copy link
Author

That sounds great, thanks for the effort 👍

mgeisler added a commit that referenced this issue Jun 11, 2022
This is the first version to support the 2021 edition. I tried
tracking the minimum supported Rust version (MSRV) back in 2020, but
this turned out to be infeasible because of frequent bumps to the MSRV
in our dependencies (see 9d622cc). I hope the update pace has cooled
enough to make the feasible again.

I plan to (conservatively) bump this version up as needed going
forward. This will of course announcing it in the release notes of new
releases.

See #83 for the motivation.
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 a pull request may close this issue.

2 participants