Skip to content

Compilation error when compiling with nightly with unstable feature enabled #1216

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

Closed
jqnatividad opened this issue Jul 27, 2024 · 4 comments · Fixed by #1219
Closed

Compilation error when compiling with nightly with unstable feature enabled #1216

jqnatividad opened this issue Jul 27, 2024 · 4 comments · Fixed by #1219
Labels

Comments

@jqnatividad
Copy link
Contributor

jqnatividad commented Jul 27, 2024

What version of regex are you using?

1.10.5

Describe the bug at a high level.

Compilation error when compiling with rust 1.82.0-nightly (7120fdac7 2024-07-25)

What are the steps to reproduce the behavior?

Compile a program that uses regex 1.10.5 with latest rust nightly with the unstable feature enabled.

What is the actual behavior?

Running `/home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name regex --edition=2021 /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/regex-1.10.5/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="pattern"' --cfg 'feature="perf"' --cfg 'feature="perf-backtrack"' --cfg 'feature="perf-cache"' --cfg 'feature="perf-dfa"' --cfg 'feature="perf-inline"' --cfg 'feature="perf-literal"' --cfg 'feature="perf-onepass"' --cfg 'feature="std"' --cfg 'feature="unicode"' --cfg 'feature="unicode-age"' --cfg 'feature="unicode-bool"' --cfg 'feature="unicode-case"' --cfg 'feature="unicode-gencat"' --cfg 'feature="unicode-perl"' --cfg 'feature="unicode-script"' --cfg 'feature="unicode-segment"' --cfg 'feature="unstable"' --check-cfg 'cfg(docsrs)' --check-cfg 'cfg(feature, values("default", "logging", "pattern", "perf", "perf-backtrack", "perf-cache", "perf-dfa", "perf-dfa-full", "perf-inline", "perf-literal", "perf-onepass", "std", "unicode", "unicode-age", "unicode-bool", "unicode-case", "unicode-gencat", "unicode-perl", "unicode-script", "unicode-segment", "unstable", "use_std"))' -C metadata=e15ac38c36a6cd7f -C extra-filename=-e15ac38c36a6cd7f --out-dir /home/runner/work/qsv/qsv/target/debug/deps -L dependency=/home/runner/work/qsv/qsv/target/debug/deps --extern aho_corasick=/home/runner/work/qsv/qsv/target/debug/deps/libaho_corasick-417a2760a2457731.rmeta --extern memchr=/home/runner/work/qsv/qsv/target/debug/deps/libmemchr-c7ff0286392b94eb.rmeta --extern regex_automata=/home/runner/work/qsv/qsv/target/debug/deps/libregex_automata-213236c3a36ea036.rmeta --extern regex_syntax=/home/runner/work/qsv/qsv/target/debug/deps/libregex_syntax-c1e3dd509c68fbb0.rmeta --cap-lints allow -C target-cpu=native`
error[E0107]: trait takes 0 lifetime arguments but 1 lifetime argument was supplied
   --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/regex-1.10.5/src/pattern.rs:13:14
    |
13  | impl<'r, 't> Pattern<'t> for &'r Regex {
    |              ^^^^^^^---- help: remove the unnecessary generics
    |              |
    |              expected 0 lifetime arguments
    |
note: trait defined here, with 0 lifetime parameters
   --> /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/pattern.rs:100:11
    |
100 | pub trait Pattern: Sized {
    |           ^^^^^^^

error[E0207]: the lifetime parameter `'t` is not constrained by the impl trait, self type, or predicates
  --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/regex-1.10.5/src/pattern.rs:13:10
   |
13 | impl<'r, 't> Pattern<'t> for &'r Regex {
   |          ^^ unconstrained lifetime parameter

What is the expected behavior?

Compile with nightly with unstable feature enabled.

@BurntSushi
Copy link
Member

That's interesting. I didn't know about a change to that trait. Patches are welcome, otherwise I'll do it soon.

But I generally wouldn't recommend relying on or even using unstable APIs. If I could go back in time, I wouldn't even offer Pattern trait integration in this crate. But it's been there for a long time and it isn't that costly to maintain.

@BurntSushi BurntSushi added the bug label Jul 27, 2024
@jqnatividad
Copy link
Contributor Author

Thanks for the quick response!

I'm not actually using Pattern, I enabled unstable with nightly primarily because I wanted SIMD acceleration and there's an old changelog entry about the simd feature being dropped in lieu of unstable:

regex/CHANGELOG.md

Lines 1224 to 1230 in 8856fe3

0.2.9 (2018-03-12)
==================
This release introduces a new nightly only feature, `unstable`, which enables
SIMD optimizations for certain types of regexes. No additional compile time
options are necessary, and the regex crate will automatically choose the
best CPU features at run time. As a result, the `simd` (nightly only) crate
dependency has been dropped.

And since pattern is enabled by the unstable feature, we get this error.

If I'm just interested in tapping regex's SIMD optimizations, how does one do it?

@BurntSushi
Copy link
Member

BurntSushi commented Jul 27, 2024

If I'm just interested in tapping regex's SIMD optimizations, how does one do it?

You don't. It just happens automatically. There is nothing that unstable enables other than the Pattern trait. Search for "simd" in the CHANGELOG. In the regex 1.0.1 release on 2018-06-19, SIMD was enabled automatically on Rust 1.27+ stable. You are six years behind the eight ball. :P

Unlike some other crates in the ecosystem, the regex crate adopted the stable SIMD API as soon as it was released, many years ago. Other crates still rely on the std::simd API which is not stable (but is platform independent).

@jqnatividad
Copy link
Contributor Author

LOL! I missed that entry!

Thanks @BurntSushi !

jqnatividad added a commit to dathere/qsv that referenced this issue Jul 27, 2024
as it was not enabling SIMD optimization like I thought it was

rust-lang/regex#1216
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants