Skip to content

Commit 3c49f17

Browse files
committed
Sam's dev merge
11 parents c97d202 + bd03414 + fcf296c + f6a892f + 357aebd + 8c0a107 + 7da3536 + 5b64ef3 + 02af33e + 967c4ac + 4181ff5 commit 3c49f17

71 files changed

Lines changed: 2464 additions & 335 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ helper.txt
4646
.vscode
4747
.idea
4848

49+
# Emacs
50+
.dir-locals.el
51+
4952
# mdbook generated output
5053
/book/book
5154

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6727,6 +6727,7 @@ Released 2018-09-13
67276727
[`mut_mut`]: https://rust-lang.github.io/rust-clippy/master/index.html#mut_mut
67286728
[`mut_mutex_lock`]: https://rust-lang.github.io/rust-clippy/master/index.html#mut_mutex_lock
67296729
[`mut_range_bound`]: https://rust-lang.github.io/rust-clippy/master/index.html#mut_range_bound
6730+
[`mutable_borrow_of_copy`]: https://rust-lang.github.io/rust-clippy/master/index.html#mutable_borrow_of_copy
67306731
[`mutable_key_type`]: https://rust-lang.github.io/rust-clippy/master/index.html#mutable_key_type
67316732
[`mutex_atomic`]: https://rust-lang.github.io/rust-clippy/master/index.html#mutex_atomic
67326733
[`mutex_integer`]: https://rust-lang.github.io/rust-clippy/master/index.html#mutex_integer
@@ -6819,6 +6820,7 @@ Released 2018-09-13
68196820
[`panic_params`]: https://rust-lang.github.io/rust-clippy/master/index.html#panic_params
68206821
[`panicking_overflow_checks`]: https://rust-lang.github.io/rust-clippy/master/index.html#panicking_overflow_checks
68216822
[`panicking_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#panicking_unwrap
6823+
[`parsed_string_literals`]: https://rust-lang.github.io/rust-clippy/master/index.html#parsed_string_literals
68226824
[`partial_pub_fields`]: https://rust-lang.github.io/rust-clippy/master/index.html#partial_pub_fields
68236825
[`partialeq_ne_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#partialeq_ne_impl
68246826
[`partialeq_to_none`]: https://rust-lang.github.io/rust-clippy/master/index.html#partialeq_to_none
@@ -7041,6 +7043,7 @@ Released 2018-09-13
70417043
[`uninit_vec`]: https://rust-lang.github.io/rust-clippy/master/index.html#uninit_vec
70427044
[`uninlined_format_args`]: https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
70437045
[`unit_arg`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_arg
7046+
[`unit_as_impl_trait`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_as_impl_trait
70447047
[`unit_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_cmp
70457048
[`unit_hash`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_hash
70467049
[`unit_return_expecting_ord`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_return_expecting_ord
@@ -7187,6 +7190,7 @@ Released 2018-09-13
71877190
[`cargo-ignore-publish`]: https://doc.rust-lang.org/clippy/lint_configuration.html#cargo-ignore-publish
71887191
[`check-incompatible-msrv-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#check-incompatible-msrv-in-tests
71897192
[`check-inconsistent-struct-field-initializers`]: https://doc.rust-lang.org/clippy/lint_configuration.html#check-inconsistent-struct-field-initializers
7193+
[`check-mutable-borrow-of-copy-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#check-mutable-borrow-of-copy-in-tests
71907194
[`check-private-items`]: https://doc.rust-lang.org/clippy/lint_configuration.html#check-private-items
71917195
[`cognitive-complexity-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#cognitive-complexity-threshold
71927196
[`const-literal-digits-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#const-literal-digits-threshold

book/src/lint_configuration.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,16 @@ fn main() {
472472
* [`inconsistent_struct_constructor`](https://rust-lang.github.io/rust-clippy/master/index.html#inconsistent_struct_constructor)
473473

474474

475+
## `check-mutable-borrow-of-copy-in-tests`
476+
Whether to search for mutable borrows of freshly copied data in tests.
477+
478+
**Default Value:** `true`
479+
480+
---
481+
**Affected lints:**
482+
* [`mutable_borrow_of_copy`](https://rust-lang.github.io/rust-clippy/master/index.html#mutable_borrow_of_copy)
483+
484+
475485
## `check-private-items`
476486
Whether to also run the listed lints on private items.
477487

clippy_config/src/conf.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,9 @@ define_Conf! {
567567
/// [from rust-clippy#11846]: https://github.com/rust-lang/rust-clippy/issues/11846#issuecomment-1820747924
568568
#[lints(inconsistent_struct_constructor)]
569569
check_inconsistent_struct_field_initializers: bool = false,
570+
/// Whether to search for mutable borrows of freshly copied data in tests.
571+
#[lints(mutable_borrow_of_copy)]
572+
check_mutable_borrow_of_copy_in_tests: bool = true,
570573
/// Whether to also run the listed lints on private items.
571574
#[lints(missing_errors_doc, missing_panics_doc, missing_safety_doc, unnecessary_safety_doc)]
572575
check_private_items: bool = false,

clippy_dev/src/main.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ fn main() {
3939
Err(e) => eprintln!("Unable to create lint: {e}"),
4040
},
4141
DevCommand::Setup(SetupCommand { subcommand }) => match subcommand {
42+
SetupSubcommand::Emacs { remove, force_override } => {
43+
if remove {
44+
setup::emacs::remove_dir_locals();
45+
} else {
46+
setup::emacs::setup_dir_locals(force_override);
47+
}
48+
},
4249
SetupSubcommand::Intellij { remove, repo_path } => {
4350
if remove {
4451
setup::intellij::remove_rustc_src();
@@ -68,6 +75,7 @@ fn main() {
6875
},
6976
},
7077
DevCommand::Remove(RemoveCommand { subcommand }) => match subcommand {
78+
RemoveSubcommand::Emacs => setup::emacs::remove_dir_locals(),
7179
RemoveSubcommand::Intellij => setup::intellij::remove_rustc_src(),
7280
RemoveSubcommand::GitHook => setup::git_hook::remove_hook(),
7381
RemoveSubcommand::VscodeTasks => setup::vscode::remove_tasks(),
@@ -276,6 +284,15 @@ struct SetupCommand {
276284

277285
#[derive(Subcommand)]
278286
enum SetupSubcommand {
287+
/// Add a `.dir-locals.el` so that Emacs can use `rustic-mode` and `eglot`
288+
Emacs {
289+
#[arg(long)]
290+
/// Remove the `.dir-locals.el` file created by `cargo dev setup emacs`
291+
remove: bool,
292+
#[arg(long, short)]
293+
/// Forces the override of an existing git pre-commit hook
294+
force_override: bool,
295+
},
279296
/// Alter dependencies so Intellij Rust can find rustc internals
280297
Intellij {
281298
#[arg(long)]
@@ -336,6 +353,8 @@ struct RemoveCommand {
336353

337354
#[derive(Subcommand)]
338355
enum RemoveSubcommand {
356+
/// Remove the `.dir-locals.el` file created by `cargo dev setup emacs`
357+
Emacs,
339358
/// Remove the dependencies added with 'cargo dev setup intellij'
340359
Intellij,
341360
/// Remove the pre-commit git hook

clippy_dev/src/setup/emacs.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const DIR_LOCALS_EL: &str = ".dir-locals.el";
2+
const DIR_LOCALS: &str = r#";; Emacs configuration
3+
((nil . ((eglot-workspace-configuration .
4+
(:rust-analyzer
5+
(:rustc
6+
(:source "discover" :linkedProjects ["./Cargo.toml" "clippy_dev/Cargo.toml" "lintcheck/Cargo.toml"])
7+
:cargo
8+
(:features ["internal"]))))))
9+
("tests/ui" . ((auto-mode-alist ("\\.fixed\\'" . rustic-mode)))))
10+
"#;
11+
12+
pub fn setup_dir_locals(force_override: bool) {
13+
if !force_override && matches!(std::fs::exists(DIR_LOCALS_EL), Ok(true)) {
14+
eprintln!("error: `{DIR_LOCALS_EL}` already exists");
15+
return;
16+
}
17+
if std::fs::write(DIR_LOCALS_EL, DIR_LOCALS).is_err() {
18+
eprintln!("error: unable to create file `{DIR_LOCALS_EL}`");
19+
return;
20+
}
21+
println!("info: created `{DIR_LOCALS_EL}`");
22+
}
23+
24+
pub fn remove_dir_locals() {
25+
if std::fs::remove_file(DIR_LOCALS_EL).is_err() {
26+
eprintln!("error: unable to remove `{DIR_LOCALS_EL}`");
27+
return;
28+
}
29+
println!("info: removed `{DIR_LOCALS_EL}`");
30+
}

clippy_dev/src/setup/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
pub mod emacs;
12
pub mod git_hook;
23
pub mod intellij;
34
pub mod toolchain;

clippy_lints/src/casts/cast_nan_to_int.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>,
2121

2222
fn is_known_nan(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
2323
match ConstEvalCtxt::new(cx).eval(e) {
24-
// FIXME(f16_f128): add these types when nan checks are available on all platforms
24+
Some(Constant::F128(n)) => n.is_nan(),
2525
Some(Constant::F64(n)) => n.is_nan(),
2626
Some(Constant::F32(n)) => n.is_nan(),
27+
Some(Constant::F16(n)) => n.is_nan(),
2728
_ => false,
2829
}
2930
}

clippy_lints/src/collapsible_if.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_config::Conf;
22
use clippy_utils::diagnostics::span_lint_hir_and_then;
33
use clippy_utils::msrvs::Msrv;
4-
use clippy_utils::source::{IntoSpan as _, SpanRangeExt, snippet, snippet_block_with_applicability};
4+
use clippy_utils::source::{IntoSpan as _, SpanRangeExt as _, snippet, snippet_block_with_applicability};
55
use clippy_utils::{can_use_if_let_chains, span_contains_non_whitespace, sym, tokenize_with_text};
66
use rustc_ast::{BinOpKind, MetaItemInner};
77
use rustc_errors::Applicability;

clippy_lints/src/declared_lints.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ pub static LINTS: &[&::declare_clippy_lint::LintInfo] = &[
444444
crate::methods::OPTION_MAP_OR_NONE_INFO,
445445
crate::methods::OR_FUN_CALL_INFO,
446446
crate::methods::OR_THEN_UNWRAP_INFO,
447+
crate::methods::PARSED_STRING_LITERALS_INFO,
447448
crate::methods::PATH_BUF_PUSH_OVERWRITE_INFO,
448449
crate::methods::PATH_ENDS_WITH_EXT_INFO,
449450
crate::methods::PTR_OFFSET_BY_LITERAL_INFO,
@@ -535,6 +536,7 @@ pub static LINTS: &[&::declare_clippy_lint::LintInfo] = &[
535536
crate::multiple_unsafe_ops_per_block::MULTIPLE_UNSAFE_OPS_PER_BLOCK_INFO,
536537
crate::mut_key::MUTABLE_KEY_TYPE_INFO,
537538
crate::mut_mut::MUT_MUT_INFO,
539+
crate::mutable_borrow_of_copy::MUTABLE_BORROW_OF_COPY_INFO,
538540
crate::mutable_debug_assertion::DEBUG_ASSERT_WITH_MUT_CALL_INFO,
539541
crate::mutex_atomic::MUTEX_ATOMIC_INFO,
540542
crate::mutex_atomic::MUTEX_INTEGER_INFO,
@@ -752,6 +754,7 @@ pub static LINTS: &[&::declare_clippy_lint::LintInfo] = &[
752754
crate::unicode::UNICODE_NOT_NFC_INFO,
753755
crate::uninhabited_references::UNINHABITED_REFERENCES_INFO,
754756
crate::uninit_vec::UNINIT_VEC_INFO,
757+
crate::unit_as_impl_trait::UNIT_AS_IMPL_TRAIT_INFO,
755758
crate::unit_return_expecting_ord::UNIT_RETURN_EXPECTING_ORD_INFO,
756759
crate::unit_types::LET_UNIT_VALUE_INFO,
757760
crate::unit_types::UNIT_ARG_INFO,

0 commit comments

Comments
 (0)