Skip to content

update identifier naming warnings to give an example #14740

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

Merged
merged 1 commit into from
Jun 9, 2014

Conversation

ftxqxd
Copy link
Contributor

@ftxqxd ftxqxd commented Jun 8, 2014

This updates identifier warnings such as struct foo_bar should have a camel case identifier to provide an example.

Closes #14738.

fn to_camel_case(s: &str) -> String {
let mut buf = String::new();
for word in s.split('_') {
buf.push_str(word.chars().enumerate().map(|(i, v)|
Copy link
Member

Choose a reason for hiding this comment

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

I think this can actually just be

buf.extend(words.chars().enumerate().map(...));

i.e. no collect or as_slice.

In fact, the whole function can probably be

s.split('_').flat_map(|word| word.chars().enumerate().map(...)).collect::<String>()

(Could you also rename v to c?)

This updates identifier warnings such as ``struct `foo_bar` should have a
camel case identifier`` to provide an example.

Closes rust-lang#14738.
@@ -46,7 +46,7 @@ fn h() {
use not_okay = self::n::OKAY;
let r = match (0,0) {
(0, not_okay) => 0,
//~^ ERROR static constant in pattern should be all caps
//~^ ERROR static constant in pattern `not_okay` should have an uppercase name such as `NOT_OKAY`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is dedenting the right way of doing this? (The line was over 100 chars long).

bors added a commit that referenced this pull request Jun 9, 2014
This updates identifier warnings such as ``struct `foo_bar` should have a
camel case identifier`` to provide an example.

Closes #14738.
@bors bors closed this Jun 9, 2014
@bors bors merged commit c1c7659 into rust-lang:master Jun 9, 2014
flip1995 pushed a commit to flip1995/rust that referenced this pull request May 15, 2025
…ang#14740)

When a `non_std_lazy_statics` warning is generated about an item type
which can be replaced by a standard library one, ensure that the lint
happens on the item HIR node so that it can be expected.

changelog: [`non_std_lazy_statics`]: generate the warning onto the right
node

Fixes rust-lang/rust-clippy#14729

Note that this doesn't change anything on lints generated for the
`lazy_static::lazy_static` macro because the `expect` attribute cannot
be applied to a macro.
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.

Identifier format warnings should give an example
4 participants