Skip to content

Cleanup libsyntax a bit #7873

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

Conversation

mstewartgallus
Copy link
Contributor

No description provided.

} else {
lhs

match ((*self.token).clone(), (*self.restriction).clone()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the calls to clone be avoided here?

@mstewartgallus
Copy link
Contributor Author

So I fixed up the problem that was causing the dynamic borrow error. Unfortunately to fix that problem I had to reintroduce the calls to clone @alexcrichton .

@alexcrichton
Copy link
Member

Well I'm not exactly wholly-opposed to having calls to clone, but I just figured it'd be a good idea to not introduce new ones (because there weren't any before). I'm not really basing this from a perf point of view, but rather just a "we should reduce clones" point of view.

@thestinger
Copy link
Contributor

I think you just need to wrap an extra block around the new borrows. Introducing clones as a workaround isn't necessary since you can just limit the scope of the borrows instead.

@mstewartgallus
Copy link
Contributor Author

@thestinger The fix was slightly more complicated than you described but I was able to fix the dynamic borrow error, and get rid of the clones.

@bors bors closed this Jul 23, 2013
flip1995 pushed a commit to flip1995/rust that referenced this pull request Nov 4, 2021
…shearth

Update `str` utils to prevent ICEs and FNs

This PR reworks some string handling for lints regarding enum naming. I hope the refactoring will prevent future ICEs and help with new bug free implementations.

It might be better to review this PR by going through the commits, as `clippy_utils::camel_case` was renamed to `clippy_utils::str_utils` and then changed further. GH sadly doesn't really make the changes that obvious 🙃

Not too much more to say. Have a nice day 🌞

---

Fixes: rust-lang/rust-clippy#7869

changelog: ICE Fix: [`enum_variant_names`] rust-lang#7869
flip1995 pushed a commit to flip1995/rust that referenced this pull request Dec 30, 2021
Test clippy_utils in CI

r? `@xFrednet` Since you did the last refactor of the `str_utils` functions in rust-lang#7873

changelog: Make sure tests in `clippy_utils` are passing by testing it in CI
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.

5 participants