Skip to content

Conversation

@brson
Copy link
Contributor

@brson brson commented May 3, 2013

These cause valgrind errors in subprocesses. I don't think these errors
lead to actual test failures but they are very confusing.

These cause valgrind errors in subprocesses. I don't *think* these errors
lead to actual test failures but they are very confusing.
bors added a commit that referenced this pull request May 7, 2013
These cause valgrind errors in subprocesses. I don't *think* these errors
lead to actual test failures but they are very confusing.
@bors bors closed this May 7, 2013
flip1995 pushed a commit to flip1995/rust that referenced this pull request Sep 9, 2022
Unlike past similar work done in rust-lang#6228, expand the existing `or_fun_call`
lint to detect `or_insert` calls with a `T::new()` or `T::default()`
argument, much like currently done for `unwrap_or` calls. In that case,
suggest the use of `or_default`, which is more idiomatic.

Note that even with this change, `or_insert_with(T::default)` calls
aren't detected as candidates for `or_default()`, in the same manner
that currently `unwrap_or_else(T::default)` calls aren't detected as
candidates for `unwrap_or_default()`.

Also, as a nearby cleanup, change `KNOW_TYPES` from `static` to `const`,
since as far as I understand it's preferred (should Clippy have a lint
for that?).

Fixes rust-lang#3812.
flip1995 pushed a commit to flip1995/rust that referenced this pull request Sep 9, 2022
Suggest `Entry::or_default` for `Entry::or_insert(Default::default())`

Unlike past similar work done in rust-lang#6228, expand the existing `or_fun_call`
lint to detect `or_insert` calls with a `T::new()` or `T::default()`
argument, much like currently done for `unwrap_or` calls. In that case,
suggest the use of `or_default`, which is more idiomatic.

Note that even with this change, `or_insert_with(T::default)` calls
aren't detected as candidates for `or_default()`, in the same manner
that currently `unwrap_or_else(T::default)` calls aren't detected as
candidates for `unwrap_or_default()`.

Also, as a nearby cleanup, change `KNOW_TYPES` from `static` to `const`,
since as far as I understand it's preferred (should Clippy have a lint
for that?).

Addresses rust-lang#3812.

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: [`or_fun_call`]: Suggest `Entry::or_default` for `Entry::or_insert(Default::default())`
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.

2 participants