-
Notifications
You must be signed in to change notification settings - Fork 443
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
build is failing in 1.8 because a Unicode feature isn't enabled, but previously worked in 1.7 #982
Comments
Could you please include a complete reproduction here? I cannot reproduce it: use regex::Regex;
fn main() {
let pat = r"(\d+\s?(years|year|y))?\s?(\d+\s?(months|month|m))?\s?(\d+\s?(weeks|week|w))?\s?(\d+\s?(days|day|d))?\s?(\d+\s?(hours|hour|h))?";
let result = Regex::new(pat);
assert!(result.is_ok());
} And my
And the result:
Trying to work backwards from the error, the message you're getting is here: regex/regex-syntax/src/hir/mod.rs Lines 125 to 128 in 93316a3
Which corresponds to this error kind variant: regex/regex-syntax/src/hir/mod.rs Lines 97 to 100 in 93316a3
This error variant is constructed in precisely one place in non-test code: regex/regex-syntax/src/hir/translate.rs Lines 1071 to 1073 in 93316a3
Which occurs only when an internal Unicode error occurs indicating that a Perl class could not be found: regex/regex-syntax/src/unicode.rs Line 22 in 93316a3
That variant in turn is constructed in three places. Here: regex/regex-syntax/src/unicode.rs Lines 389 to 392 in 93316a3
here: regex/regex-syntax/src/unicode.rs Lines 407 to 410 in 93316a3
and here: regex/regex-syntax/src/unicode.rs Lines 431 to 434 in 93316a3
You use So I can't quite figure out what's going on here without more details. Please do try to include a complete reproduction here. Thanks. |
Folks, I need a reproduction. Please find a way to hand me a set of commands and source code that I can enter and run. As I mentioned above, I still don't understand how this error is appearing. |
@BratSinot And the error you're showing is different from the error in the OP. It's not the same. |
I have a guess as to what is happening. This PR tipped me off to it: tokio-rs/tracing#2566 Unfortunately, this is one of those cases where folks were able to under specify regex crate features and still have their patterns work even though the features specified weren't actually sufficient to do so. The way this manifests is likely going to be a little different in each case, but taking Now But because of how feature unification works in Cargo, this means that even though the With the release of So... probably everything is actually working correctly here and folks are just now getting hit over the head with the fact that they under-specified the regex crate features. If you think this analysis is wrong or have a case where this doesn't apply, please let me know. And please provide as many details as possible. Ideally a reproduction. |
Here is a minimal repro: Cargo.toml: [package]
name = "regex_repro"
version = "0.1.0"
edition = "2021"
[dependencies]
regex = { version = "=1.8.1", default_features = false, features = ["std"] }
regex-syntax = { version = "0.7", default_features = false } main.rs: use regex::Regex;
fn main() {
let pat = r"(\d+\s?(years|year|y))?\s?(\d+\s?(months|month|m))?\s?(\d+\s?(weeks|week|w))?\s?(\d+\s?(days|day|d))?\s?(\d+\s?(hours|hour|h))?";
let result = Regex::new(pat).unwrap();
} Ouput:
Judging from your comment above this looks like it's one of those times where we have relied on incorrect assumptions. Even tho it hurts in the short term I'd be in favor of correctness over legacy hacks and backwards compatibility hacks like you see in webkit. |
So I actually think that example isn't quite right. You want [dependencies]
regex = { version = "1.6.0", default_features = false, features = ["std"] }
regex-syntax = "0.6.29" With the same
Now let's downgrade to
And re-run:
(I've snipped out unrelated warnings from the above output. Anyway, that's the right repro, because it simulates real world conditions:
And then when you upgrade to |
I hate to say it, but wouldn't the latest change then be considered "breaking" if features were changed which causes all these cascading failures with different crates? |
The features weren't changed. I'm confused as to why you're saying that. As I said above, the issue is that some were implicitly relying on Cargo feature unification. The only cause of this is that I put out a new breaking change release of |
Gotcha,that makes sense for sure. This is the first time actually looking into the inner workings of this crate so I didn't realize the breaking change was a dependency and not the actual crate. Thanks for clarifying :) |
Yes, I suppose this is a case study in some costs that were previously not anticipated:
Of course, if Cargo's feature unification worked in a different way, then we might not also have had this problem either. So I don't mean to say that (1) and (2) above are the only causes, but they are certainly part of the story here. |
Is there any automation that crate authors can use to detect these sorts of underspecified dependencies to help avoid these sorts of problems going forward? |
No idea personally. That would be a good question for @epage though. @epage - If you only read one comment in this thread to figure out what's going on, this is the one to read: #982 (comment) |
I can't think of a sure-fire way of detecting this.
If it isn't already there, we should probably explicitly document this compatibility hazard. I definitely don't think it should be considered a major breaking change. I think it shouldn't even be a minor breaking change. Its just a hazard. |
I'm going to close this because I think the root cause is known and folks have fixed it. I also don't think there is really much that can be done here. It is apparently neither possible to fully guard against this and nor is it feasible to never put out a breaking change release of |
Hello
When i updated regex version from 1.7.3 up to 1.8.0 i've received a problem with regex parsing.
Output:
Even if i enable unicode feature manually it still does not work:
But if i downgrade version to 1.7.3, everything works good:
The text was updated successfully, but these errors were encountered: