Skip to content
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

Update Clippy #93865

Merged
merged 92 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from 91 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
a5a07e5
single_match: Don't lint non-exhaustive matches; support tuples
jubnzv Jan 20, 2022
a0c5087
single_match: Clarify the `don't lint` test case
jubnzv Jan 21, 2022
49ae73b
matches: Simplify code
jubnzv Jan 21, 2022
64f5b36
Update Changelog
flip1995 Jan 14, 2022
5416a71
Merge remote-tracking branch 'origin/master' into 8282-single-match
jubnzv Jan 26, 2022
4aee3b1
matches: Clarify the behavior of exhaustive check
jubnzv Jan 26, 2022
8101587
matches: Improve naming. NFC.
jubnzv Jan 26, 2022
467a0bf
matches: Restore `match_type` logic; add tests for these cases
jubnzv Jan 26, 2022
a8fdf5c
matches: Remove extra comment
jubnzv Jan 26, 2022
bf66aed
Merge commit 'a98e7ab8b94485be6bd03e0c6b8682ecab5b52e6' into clippyup
flip1995 Jan 27, 2022
23fd95a
fix underflow in `check_manual_split_once` lint
pr2502 Jan 8, 2022
515ed80
Update docs for `map_flatten` on `Option`
dswij Jan 25, 2022
fb94992
Auto merge of #8354 - dswij:8345, r=giraffate
bors Jan 28, 2022
8d5d9e0
Auto merge of #8250 - pr2502:fix_repeat_underflow, r=giraffate
bors Jan 28, 2022
cc97592
Rename path_to_res to def_path_res
camsteffen Jan 6, 2022
bea09a2
Add path_def_id util
camsteffen Jan 4, 2022
20781f1
Rename qpath_generic_tys
camsteffen Jan 17, 2022
145d7fc
Factor out get_qpath_generics
camsteffen Jan 17, 2022
66a83d3
Factor out some ty param utils
camsteffen Jan 6, 2022
deadc25
Factor out differing_macro_contexts
camsteffen Nov 2, 2021
98c6381
Factor out single_segment_path
camsteffen Jan 6, 2022
3771fe4
Factor out expr_path_res
camsteffen Jan 6, 2022
ece7fa4
Factor out match_any_diagnostic_items
camsteffen Jan 6, 2022
bd583d9
Factor out is_qpath_def_path
camsteffen Jan 6, 2022
b7000b2
Add `default_union_representation` lint
jubnzv Jan 15, 2022
7ceffde
Auto merge of #8289 - jubnzv:unspecified-layout-union, r=camsteffen
bors Jan 29, 2022
4119f60
Create `core::fmt::ArgumentV1` with generics instead of fn pointer
nbdd0121 Oct 17, 2021
bee482b
Change index_refutable_slice to use FxIndexMap
nbdd0121 Jan 8, 2022
e7922f7
Format `if_chain` invocations in clippy_utils
smoelius Jan 29, 2022
66bb726
Don't lint `ptr_arg` for `&mut _` types in trait items
Jarcho Jan 29, 2022
8ccd264
modify code
tamaroning Jan 30, 2022
ba80d45
update testsuite
tamaroning Jan 30, 2022
1a2364e
fix code
tamaroning Jan 30, 2022
df6ef60
update get_unwrap.rs
tamaroning Jan 30, 2022
447ed5c
add attributes
tamaroning Jan 30, 2022
0ed8ca4
Auto merge of #8322 - jubnzv:8282-single-match, r=llogiq
bors Jan 30, 2022
b606d16
Auto merge of #90891 - nbdd0121:format, r=Mark-Simulacrum
bors Jan 31, 2022
5faa7eb
Fix `chars_next_cmp` suggestion not escaped
dswij Jan 31, 2022
7bb69c0
Auto merge of #8369 - Jarcho:ptr_arg_8366, r=flip1995
bors Jan 31, 2022
97e5a70
warn if we find multiple clippy configs
matthiaskrgr Jan 20, 2022
1193abe
multiple configs: add tests
matthiaskrgr Jan 30, 2022
0e1cbc5
fix code
tamaroning Feb 1, 2022
b13704a
update test suites
tamaroning Feb 1, 2022
544ed0b
silence lint in clippy
lcnr Feb 1, 2022
99af4c8
remove `TyS::same_type`
lcnr Jan 25, 2022
c7b7b53
Rollup merge of #93290 - lcnr:same_type, r=jackh726
matthiaskrgr Feb 1, 2022
8ef8745
Minor cleanup on transmute lints
Jarcho Feb 1, 2022
b8c80dd
Auto merge of #8330 - flip1995:changelog, r=llogiq
bors Feb 1, 2022
e4f45c2
Fix ICE in `ptr_arg`
Jarcho Feb 1, 2022
327768c
Auto merge of #8387 - Jarcho:ptr_arg_8386, r=flip1995
bors Feb 1, 2022
cf53710
Auto merge of #8370 - smoelius:master, r=flip1995
bors Feb 1, 2022
f5fd9de
chore
tamaroning Feb 2, 2022
bef92b8
Auto merge of #8382 - tamaroning:suggest_iter_instead_of_into_iter, r…
bors Feb 2, 2022
6987217
Lazily resolve type-alias-impl-trait defining uses
oli-obk Aug 20, 2021
3edfd5e
Remove defaultness from ImplItem.
cjgillot Feb 2, 2022
699ee5e
Auto merge of #8376 - dswij:8373, r=camsteffen
bors Feb 5, 2022
4bae06d
Use source callsite in FormatArgsExpn::inputs_span
Alexendoo Jan 28, 2022
144b4a5
Add `explicit_write` suggestions for `write!`s with format args
Alexendoo Jan 28, 2022
29cc0d8
Auto merge of #8372 - tamaroning:unwrap_used, r=llogiq
bors Feb 5, 2022
68b4498
Auto merge of #8365 - Alexendoo:explicit-write-suggestion, r=camsteffen
bors Feb 5, 2022
3403b3e
Add lint `transumte_undefined_repr`
Jarcho Feb 1, 2022
04dce4a
Support `cargo dev bless` for tests with revisions
Alexendoo Jan 30, 2022
68993b1
Small `transmute_float_to_int` cleanup
Jarcho Feb 6, 2022
093e320
Auto merge of #8398 - Jarcho:unordered_transmute, r=llogiq
bors Feb 6, 2022
aae64e9
ignore test on windows since I don't know why compiletest does not ha…
matthiaskrgr Feb 2, 2022
8dc719c
Auto merge of #8326 - matthiaskrgr:warn_on_multi_configs, r=xFrednet
bors Feb 6, 2022
3d43826
Auto merge of #8305 - camsteffen:util-cleanup, r=flip1995
bors Feb 7, 2022
f7be956
Move `matches.rs` to `mod.rs`
Jarcho Feb 6, 2022
e41a6fc
Split out `match_like_matches_macro`
Jarcho Feb 6, 2022
6454825
Split out `match_same_arms`
Jarcho Feb 6, 2022
f2b6ed7
Split out `redundant_pattern_match`
Jarcho Feb 6, 2022
f23dc16
Split out `single_match`
Jarcho Feb 6, 2022
f3dd909
Split out `match_bool`
Jarcho Feb 6, 2022
2a70439
Split out `overlapping_arms`
Jarcho Feb 6, 2022
dc75695
Split out `match_wild_err_arm`
Jarcho Feb 6, 2022
75923df
Split out `wildcard_enum_match_arm` and `match_wildcard_for_single_va…
Jarcho Feb 6, 2022
bccf06f
Split out `match_as_ref`
Jarcho Feb 6, 2022
1da26c8
Split out `match_single_binding`
Jarcho Feb 6, 2022
fb1093c
Split out `match_ref_pats`
Jarcho Feb 6, 2022
6477923
Split out `infalliable_detructuring_match`
Jarcho Feb 7, 2022
aa3af30
Split out `rest_pat_in_fully_bound_struct`
Jarcho Feb 7, 2022
c65894c
Split out `wild_in_or_pats`
Jarcho Feb 7, 2022
2590701
Auto merge of #8400 - Jarcho:split_matches, r=Manishearth
bors Feb 7, 2022
caeebd6
Auto merge of #8374 - Alexendoo:bless-revisions, r=camsteffen
bors Feb 8, 2022
88fd090
Factor out ui_test suite
camsteffen Feb 8, 2022
5044e37
Rollup merge of #93746 - cjgillot:nodefii, r=nikomatsakis
JohnTitor Feb 9, 2022
6966a42
Auto merge of #8404 - camsteffen:rm-ui-test, r=flip1995
bors Feb 9, 2022
0775c06
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Feb 10, 2022
49b9f92
Bump nightly version -> 2022-02-10
flip1995 Feb 10, 2022
57b3c4b
Auto merge of #8409 - flip1995:rustup, r=flip1995
bors Feb 10, 2022
78ae132
Merge commit '57b3c4b90f4346b3990c1be387c3b3ca7b78412c' into clippyup
flip1995 Feb 10, 2022
04c9842
Clippy: Fix botstrap fallout
flip1995 Feb 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
181 changes: 177 additions & 4 deletions src/tools/clippy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,185 @@ document.

## Unreleased / In Rust Nightly

[e181011...master](https://github.com/rust-lang/rust-clippy/compare/e181011...master)
[0eff589...master](https://github.com/rust-lang/rust-clippy/compare/0eff589...master)

## Rust 1.58 (beta)
## Rust 1.59 (beta)

Current beta, release 2022-01-13
Current beta, release 2022-02-24

[e181011...0eff589](https://github.com/rust-lang/rust-clippy/compare/e181011...0eff589)

### New Lints

* [`index_refutable_slice`]
[#7643](https://github.com/rust-lang/rust-clippy/pull/7643)
* [`needless_splitn`]
[#7896](https://github.com/rust-lang/rust-clippy/pull/7896)
* [`unnecessary_to_owned`]
[#7978](https://github.com/rust-lang/rust-clippy/pull/7978)
* [`needless_late_init`]
[#7995](https://github.com/rust-lang/rust-clippy/pull/7995)
* [`octal_escapes`] [#8007](https://github.com/rust-lang/rust-clippy/pull/8007)
* [`return_self_not_must_use`]
[#8071](https://github.com/rust-lang/rust-clippy/pull/8071)
* [`init_numbered_fields`]
[#8170](https://github.com/rust-lang/rust-clippy/pull/8170)

### Moves and Deprecations

* Move `if_then_panic` to `pedantic` and rename to [`manual_assert`] (now
allow-by-default) [#7810](https://github.com/rust-lang/rust-clippy/pull/7810)
* Rename `disallow_type` to [`disallowed_types`] and `disallowed_method` to
[`disallowed_methods`]
[#7984](https://github.com/rust-lang/rust-clippy/pull/7984)
* Move [`map_flatten`] to `complexity` (now warn-by-default)
[#8054](https://github.com/rust-lang/rust-clippy/pull/8054)

### Enhancements

* [`match_overlapping_arm`]: Fix false negative where after included ranges,
overlapping ranges weren't linted anymore
[#7909](https://github.com/rust-lang/rust-clippy/pull/7909)
* [`deprecated_cfg_attr`]: Now takes the specified MSRV into account
[#7944](https://github.com/rust-lang/rust-clippy/pull/7944)
* [`cast_lossless`]: Now also lints for `bool` to integer casts
[#7948](https://github.com/rust-lang/rust-clippy/pull/7948)
* [`let_underscore_lock`]: Also emit lints for the `parking_lot` crate
[#7957](https://github.com/rust-lang/rust-clippy/pull/7957)
* [`needless_borrow`]
[#7977](https://github.com/rust-lang/rust-clippy/pull/7977)
* Lint when a borrow is auto-dereffed more than once
* Lint in the trailing expression of a block for a match arm
* [`strlen_on_c_strings`]
[8001](https://github.com/rust-lang/rust-clippy/pull/8001)
* Lint when used without a fully-qualified path
* Suggest removing the surrounding unsafe block when possible
* [`non_ascii_literal`]: Now also lints on `char`s, not just `string`s
[#8034](https://github.com/rust-lang/rust-clippy/pull/8034)
* [`single_char_pattern`]: Now also lints on `split_inclusive`, `split_once`,
`rsplit_once`, `replace`, and `replacen`
[#8077](https://github.com/rust-lang/rust-clippy/pull/8077)
* [`unwrap_or_else_default`]: Now also lints on `std` constructors like
`Vec::new`, `HashSet::new`, and `HashMap::new`
[#8163](https://github.com/rust-lang/rust-clippy/pull/8163)
* [`shadow_reuse`]: Now also lints on shadowed `if let` bindings, instead of
[`shadow_unrelated`]
[#8165](https://github.com/rust-lang/rust-clippy/pull/8165)

### False Positive Fixes

* [`or_fun_call`], [`unnecessary_lazy_evaluations`]: Improve heuristics, so that
cheap functions (e.g. calling `.len()` on a `Vec`) won't get linted anymore
[#7639](https://github.com/rust-lang/rust-clippy/pull/7639)
* [`manual_split_once`]: No longer suggests code changing the original behavior
[#7896](https://github.com/rust-lang/rust-clippy/pull/7896)
* Don't show [`no_effect`] or [`unnecessary_operation`] warning for unit struct
implementing `FnOnce`
[#7898](https://github.com/rust-lang/rust-clippy/pull/7898)
* [`semicolon_if_nothing_returned`]: Fixed a bug, where the lint wrongly
triggered on `let-else` statements
[#7955](https://github.com/rust-lang/rust-clippy/pull/7955)
* [`if_then_some_else_none`]: No longer lints if there is an early return
[#7980](https://github.com/rust-lang/rust-clippy/pull/7980)
* [`needless_collect`]: No longer suggests removal of `collect` when removal
would create code requiring mutably borrowing a value multiple times
[#7982](https://github.com/rust-lang/rust-clippy/pull/7982)
* [`shadow_same`]: Fix false positive for `async` function's params
[#7997](https://github.com/rust-lang/rust-clippy/pull/7997)
* [`suboptimal_flops`]: No longer triggers in constant functions
[#8009](https://github.com/rust-lang/rust-clippy/pull/8009)
* [`type_complexity`]: No longer lints on associated types in traits
[#8030](https://github.com/rust-lang/rust-clippy/pull/8030)
* [`question_mark`]: No longer lints if returned object is not local
[#8080](https://github.com/rust-lang/rust-clippy/pull/8080)
* [`option_if_let_else`]: No longer lint on complex sub-patterns
[#8086](https://github.com/rust-lang/rust-clippy/pull/8086)
* [`blocks_in_if_conditions`]: No longer lints on empty closures
[#8100](https://github.com/rust-lang/rust-clippy/pull/8100)
* [`enum_variant_names`]: No longer lint when first prefix is only a substring
of a camel-case word
[#8127](https://github.com/rust-lang/rust-clippy/pull/8127)
* [`identity_op`]: Only lint on integral operands
[#8183](https://github.com/rust-lang/rust-clippy/pull/8183)

### Suggestion Fixes/Improvements

* [`search_is_some`]: Fix suggestion for `any()` not taking item by reference
[#7463](https://github.com/rust-lang/rust-clippy/pull/7463)
* [`almost_swapped`]: Now detects if there is a `no_std` or `no_core` attribute
and adapts the suggestion accordingly
[#7877](https://github.com/rust-lang/rust-clippy/pull/7877)
* [`redundant_pattern_matching`]: Fix suggestion for deref expressions
[#7949](https://github.com/rust-lang/rust-clippy/pull/7949)
* [`explicit_counter_loop`]: Now also produces a suggestion for non-`usize`
types [#7950](https://github.com/rust-lang/rust-clippy/pull/7950)
* [`manual_map`]: Fix suggestion when used with unsafe functions and blocks
[#7968](https://github.com/rust-lang/rust-clippy/pull/7968)
* [`option_map_or_none`]: Suggest `map` over `and_then` when possible
[#7971](https://github.com/rust-lang/rust-clippy/pull/7971)
* [`option_if_let_else`]: No longer expands macros in the suggestion
[#7974](https://github.com/rust-lang/rust-clippy/pull/7974)
* [`iter_cloned_collect`]: Suggest `copied` over `cloned` when possible
[#8006](https://github.com/rust-lang/rust-clippy/pull/8006)
* [`doc_markdown`]: No longer uses inline hints to improve readability of
suggestion [#8011](https://github.com/rust-lang/rust-clippy/pull/8011)
* [`needless_question_mark`]: Now better explains the suggestion
[#8028](https://github.com/rust-lang/rust-clippy/pull/8028)
* [`single_char_pattern`]: Escape backslash `\` in suggestion
[#8067](https://github.com/rust-lang/rust-clippy/pull/8067)
* [`needless_bool`]: Suggest `a != b` over `!(a == b)`
[#8117](https://github.com/rust-lang/rust-clippy/pull/8117)
* [`iter_skip_next`]: Suggest to add a `mut` if it is necessary in order to
apply this lints suggestion
[#8133](https://github.com/rust-lang/rust-clippy/pull/8133)
* [`neg_multiply`]: Now produces a suggestion
[#8144](https://github.com/rust-lang/rust-clippy/pull/8144)
* [`needless_return`]: Now suggests the unit type `()` over an empty block `{}`
in match arms [#8185](https://github.com/rust-lang/rust-clippy/pull/8185)
* [`suboptimal_flops`]: Now gives a syntactically correct suggestion for
`to_radians` and `to_degrees`
[#8187](https://github.com/rust-lang/rust-clippy/pull/8187)

### ICE Fixes

* [`undocumented_unsafe_blocks`]
[#7945](https://github.com/rust-lang/rust-clippy/pull/7945)
[#7988](https://github.com/rust-lang/rust-clippy/pull/7988)
* [`unnecessary_cast`]
[#8167](https://github.com/rust-lang/rust-clippy/pull/8167)

### Documentation Improvements

* [`print_stdout`], [`print_stderr`], [`dbg_macro`]: Document how the lint level
can be changed crate-wide
[#8040](https://github.com/rust-lang/rust-clippy/pull/8040)
* Added a note to the `README` that config changes don't apply to already
compiled code [#8175](https://github.com/rust-lang/rust-clippy/pull/8175)

### Others

* [Clippy's lint
list](https://rust-lang.github.io/rust-clippy/master/index.html) now displays
the version a lint was added. :tada:
[#7813](https://github.com/rust-lang/rust-clippy/pull/7813)
* New and improved issue templates
[#8032](https://github.com/rust-lang/rust-clippy/pull/8032)
* _Dev:_ Add `cargo dev lint` command, to run your modified Clippy version on a
file [#7917](https://github.com/rust-lang/rust-clippy/pull/7917)

## Rust 1.58

Current stable, released 2022-01-13

[00e31fa...e181011](https://github.com/rust-lang/rust-clippy/compare/00e31fa...e181011)

### Rust 1.58.1

* Move [`non_send_fields_in_send_ty`] to `nursery` (now allow-by-default)
[#8075](https://github.com/rust-lang/rust-clippy/pull/8075)
* [`useless_format`]: Handle implicit named arguments
[#8295](https://github.com/rust-lang/rust-clippy/pull/8295)

### New lints

* [`transmute_num_to_bytes`]
Expand Down Expand Up @@ -124,7 +295,7 @@ Current beta, release 2022-01-13

## Rust 1.57

Current stable, released 2021-12-02
Released 2021-12-02

[7bfc26e...00e31fa](https://github.com/rust-lang/rust-clippy/compare/7bfc26e...00e31fa)

Expand Down Expand Up @@ -2930,6 +3101,7 @@ Released 2018-09-13
[`declare_interior_mutable_const`]: https://rust-lang.github.io/rust-clippy/master/index.html#declare_interior_mutable_const
[`default_numeric_fallback`]: https://rust-lang.github.io/rust-clippy/master/index.html#default_numeric_fallback
[`default_trait_access`]: https://rust-lang.github.io/rust-clippy/master/index.html#default_trait_access
[`default_union_representation`]: https://rust-lang.github.io/rust-clippy/master/index.html#default_union_representation
[`deprecated_cfg_attr`]: https://rust-lang.github.io/rust-clippy/master/index.html#deprecated_cfg_attr
[`deprecated_semver`]: https://rust-lang.github.io/rust-clippy/master/index.html#deprecated_semver
[`deref_addrof`]: https://rust-lang.github.io/rust-clippy/master/index.html#deref_addrof
Expand Down Expand Up @@ -3303,6 +3475,7 @@ Released 2018-09-13
[`transmute_num_to_bytes`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_num_to_bytes
[`transmute_ptr_to_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_ptr_to_ptr
[`transmute_ptr_to_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_ptr_to_ref
[`transmute_undefined_repr`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_undefined_repr
[`transmutes_expressible_as_ptr_casts`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmutes_expressible_as_ptr_casts
[`transmuting_null`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmuting_null
[`trivial_regex`]: https://rust-lang.github.io/rust-clippy/master/index.html#trivial_regex
Expand Down
65 changes: 18 additions & 47 deletions src/tools/clippy/clippy_dev/src/bless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ use std::ffi::OsStr;
use std::fs;
use std::lazy::SyncLazy;
use std::path::{Path, PathBuf};
use walkdir::WalkDir;

use crate::clippy_project_root;
use walkdir::{DirEntry, WalkDir};

#[cfg(not(windows))]
static CARGO_CLIPPY_EXE: &str = "cargo-clippy";
Expand All @@ -24,43 +22,25 @@ static CLIPPY_BUILD_TIME: SyncLazy<Option<std::time::SystemTime>> = SyncLazy::ne
///
/// Panics if the path to a test file is broken
pub fn bless(ignore_timestamp: bool) {
let test_suite_dirs = [
clippy_project_root().join("tests").join("ui"),
clippy_project_root().join("tests").join("ui-internal"),
clippy_project_root().join("tests").join("ui-toml"),
clippy_project_root().join("tests").join("ui-cargo"),
];
for test_suite_dir in &test_suite_dirs {
WalkDir::new(test_suite_dir)
.into_iter()
.filter_map(Result::ok)
.filter(|f| f.path().extension() == Some(OsStr::new("rs")))
.for_each(|f| {
let test_name = f.path().strip_prefix(test_suite_dir).unwrap();
for &ext in &["stdout", "stderr", "fixed"] {
let test_name_ext = format!("stage-id.{}", ext);
update_reference_file(
f.path().with_extension(ext),
test_name.with_extension(test_name_ext),
ignore_timestamp,
);
}
});
}
let extensions = ["stdout", "stderr", "fixed"].map(OsStr::new);

WalkDir::new(build_dir())
.into_iter()
.map(Result::unwrap)
.filter(|entry| entry.path().extension().map_or(false, |ext| extensions.contains(&ext)))
.for_each(|entry| update_reference_file(&entry, ignore_timestamp));
}

fn update_reference_file(reference_file_path: PathBuf, test_name: PathBuf, ignore_timestamp: bool) {
let test_output_path = build_dir().join(test_name);
let relative_reference_file_path = reference_file_path.strip_prefix(clippy_project_root()).unwrap();
fn update_reference_file(test_output_entry: &DirEntry, ignore_timestamp: bool) {
let test_output_path = test_output_entry.path();

// If compiletest did not write any changes during the test run,
// we don't have to update anything
if !test_output_path.exists() {
return;
}
let reference_file_name = test_output_entry.file_name().to_str().unwrap().replace(".stage-id", "");
let reference_file_path = Path::new("tests")
.join(test_output_path.strip_prefix(build_dir()).unwrap())
.with_file_name(reference_file_name);

// If the test output was not updated since the last clippy build, it may be outdated
if !ignore_timestamp && !updated_since_clippy_build(&test_output_path).unwrap_or(true) {
if !ignore_timestamp && !updated_since_clippy_build(test_output_entry).unwrap_or(true) {
return;
}

Expand All @@ -69,23 +49,14 @@ fn update_reference_file(reference_file_path: PathBuf, test_name: PathBuf, ignor

if test_output_file != reference_file {
// If a test run caused an output file to change, update the reference file
println!("updating {}", &relative_reference_file_path.display());
println!("updating {}", reference_file_path.display());
fs::copy(test_output_path, &reference_file_path).expect("Could not update reference file");

// We need to re-read the file now because it was potentially updated from copying
let reference_file = fs::read(&reference_file_path).unwrap_or_default();

if reference_file.is_empty() {
// If we copied over an empty output file, we remove the now empty reference file
println!("removing {}", &relative_reference_file_path.display());
fs::remove_file(reference_file_path).expect("Could not remove reference file");
}
}
}

fn updated_since_clippy_build(path: &Path) -> Option<bool> {
fn updated_since_clippy_build(entry: &DirEntry) -> Option<bool> {
let clippy_build_time = (*CLIPPY_BUILD_TIME)?;
let modified = fs::metadata(path).ok()?.modified().ok()?;
let modified = entry.metadata().ok()?.modified().ok()?;
Some(modified >= clippy_build_time)
}

Expand Down
6 changes: 3 additions & 3 deletions src/tools/clippy/clippy_lints/src/blocks_in_if_conditions.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg};
use clippy_utils::get_parent_expr;
use clippy_utils::higher;
use clippy_utils::source::snippet_block_with_applicability;
use clippy_utils::ty::implements_trait;
use clippy_utils::{differing_macro_contexts, get_parent_expr};
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir::intravisit::{walk_expr, Visitor};
Expand Down Expand Up @@ -97,7 +97,7 @@ impl<'tcx> LateLintPass<'tcx> for BlocksInIfConditions {
if let Some(ex) = &block.expr {
// don't dig into the expression here, just suggest that they remove
// the block
if expr.span.from_expansion() || differing_macro_contexts(expr.span, ex.span) {
if expr.span.from_expansion() || ex.span.from_expansion() {
return;
}
let mut applicability = Applicability::MachineApplicable;
Expand All @@ -122,7 +122,7 @@ impl<'tcx> LateLintPass<'tcx> for BlocksInIfConditions {
}
} else {
let span = block.expr.as_ref().map_or_else(|| block.stmts[0].span, |e| e.span);
if span.from_expansion() || differing_macro_contexts(expr.span, span) {
if span.from_expansion() || expr.span.from_expansion() {
return;
}
// move block higher
Expand Down
Loading