-
Notifications
You must be signed in to change notification settings - Fork 97
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
Unnecessary referencing may cause infinite recursion in compilation #149
Comments
BTW, I'm wondering why such implementation ( |
That trait impl can't be removed. It's a breaking change. I don't remember the precise reason it exists, other than to make As for the infinite loop, I think I need an MRE to determine whether the fault lies with this crate or not. |
Fair.
I don't think it's really reproducible out of the crate as unsafe impl<'a, A: Automaton + ?Sized> Automaton for &'a A {
#[inline(always)]
fn start_state(&self, anchored: Anchored) -> Result<StateID, MatchError> {
let _ = self as &dyn Automaton;
// ...
}
} But it's basically an artificial problem! |
Right. I absolutely agree that you can get an infinite loop during compilation if the trait implemented incorrectly. But all righty, I'm going to close this as a non-issue for now. Thanks for looking into this! |
These two default implementations are passing a
&&Self
instead of&Self
to the target function in place of&A
whereA: Automaton
. This is unnecessary asSelf
is implementingAutomaton
so we can passself
directly.aho-corasick/src/automaton.rs
Line 358 in 948d2e1
and
aho-corasick/src/automaton.rs
Line 372 in 948d2e1
Although this is not a problem by itself, it can possibly cause an infinite loop when converting an
Automaton
to a dynamic object (as theoretically in each call a new type is evaluated for the implementation ofAutomaton
). (Unfortunately I cannot regenerate how I managed to cause the compile error, but it's possible!).The text was updated successfully, but these errors were encountered: