Unnamed repository; edit this file 'description' to name the repository.
Auto merge of #16519 - tetsuharuohzeki:more-lint, r=lnicola
Enable some minor lints that we should tackles (take2) This enables these lints: - borrowed_box - derived_hash_with_manual_eq - forget_non_drop - needless_doctest_main
bors 2024-02-09
parent cdc3e83 · parent c6637f3 · commit bb0de88
-rw-r--r--Cargo.toml4
-rw-r--r--crates/hir-def/src/generics.rs6
-rw-r--r--crates/hir-def/src/lib.rs3
-rw-r--r--crates/hir-ty/src/lib.rs6
-rw-r--r--crates/hir-ty/src/mir/lower.rs4
-rw-r--r--crates/ide/src/inlay_hints/implicit_drop.rs10
-rw-r--r--crates/ide/src/inlay_hints/range_exclusive.rs2
7 files changed, 19 insertions, 16 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 8bec3893ce..30b59498bd 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -168,10 +168,6 @@ new_ret_no_self = "allow"
useless_asref = "allow"
## Following lints should be tackled at some point
-borrowed_box = "allow"
-derived_hash_with_manual_eq = "allow"
-forget_non_drop = "allow"
-needless_doctest_main = "allow"
too_many_arguments = "allow"
type_complexity = "allow"
wrong_self_convention = "allow"
diff --git a/crates/hir-def/src/generics.rs b/crates/hir-def/src/generics.rs
index 349d327aaa..8dce7fdb4d 100644
--- a/crates/hir-def/src/generics.rs
+++ b/crates/hir-def/src/generics.rs
@@ -264,7 +264,7 @@ impl GenericParamsCollector {
self.add_where_predicate_from_bound(
lower_ctx,
bound,
- lifetimes.as_ref(),
+ lifetimes.as_deref(),
target.clone(),
);
}
@@ -275,14 +275,14 @@ impl GenericParamsCollector {
&mut self,
lower_ctx: &LowerCtx<'_>,
bound: ast::TypeBound,
- hrtb_lifetimes: Option<&Box<[Name]>>,
+ hrtb_lifetimes: Option<&[Name]>,
target: Either<TypeRef, LifetimeRef>,
) {
let bound = TypeBound::from_ast(lower_ctx, bound);
let predicate = match (target, bound) {
(Either::Left(type_ref), bound) => match hrtb_lifetimes {
Some(hrtb_lifetimes) => WherePredicate::ForLifetime {
- lifetimes: hrtb_lifetimes.clone(),
+ lifetimes: hrtb_lifetimes.to_vec().into_boxed_slice(),
target: WherePredicateTypeTarget::TypeRef(Interned::new(type_ref)),
bound: Interned::new(bound),
},
diff --git a/crates/hir-def/src/lib.rs b/crates/hir-def/src/lib.rs
index 6a39e0b695..ef4f538785 100644
--- a/crates/hir-def/src/lib.rs
+++ b/crates/hir-def/src/lib.rs
@@ -721,6 +721,9 @@ impl Clone for Box<dyn OpaqueInternableThing> {
pub struct InTypeConstId(salsa::InternId);
impl_intern!(InTypeConstId, InTypeConstLoc, intern_in_type_const, lookup_intern_in_type_const);
+// We would like to set `derive(PartialEq)`
+// but the compiler complains about that `.expected_ty` does not implement the `Copy` trait.
+#[allow(clippy::derived_hash_with_manual_eq)]
#[derive(Debug, Hash, Eq, Clone)]
pub struct InTypeConstLoc {
pub id: AstId<ast::ConstArg>,
diff --git a/crates/hir-ty/src/lib.rs b/crates/hir-ty/src/lib.rs
index 288c42405d..6ef331c61e 100644
--- a/crates/hir-ty/src/lib.rs
+++ b/crates/hir-ty/src/lib.rs
@@ -228,7 +228,7 @@ impl MemoryMap {
&self,
mut f: impl FnMut(&[u8], usize) -> Result<usize, MirEvalError>,
) -> Result<FxHashMap<usize, usize>, MirEvalError> {
- let mut transform = |(addr, val): (&usize, &Box<[u8]>)| {
+ let mut transform = |(addr, val): (&usize, &[u8])| {
let addr = *addr;
let align = if addr == 0 { 64 } else { (addr - (addr & (addr - 1))).min(64) };
f(val, align).map(|it| (addr, it))
@@ -240,7 +240,9 @@ impl MemoryMap {
map.insert(addr, val);
map
}),
- MemoryMap::Complex(cm) => cm.memory.iter().map(transform).collect(),
+ MemoryMap::Complex(cm) => {
+ cm.memory.iter().map(|(addr, val)| transform((addr, val))).collect()
+ }
}
}
diff --git a/crates/hir-ty/src/mir/lower.rs b/crates/hir-ty/src/mir/lower.rs
index 28d26c6c8a..f4a076737a 100644
--- a/crates/hir-ty/src/mir/lower.rs
+++ b/crates/hir-ty/src/mir/lower.rs
@@ -126,6 +126,10 @@ impl DropScopeToken {
}
}
+impl Drop for DropScopeToken {
+ fn drop(&mut self) {}
+}
+
// Uncomment this to make `DropScopeToken` a drop bomb. Unfortunately we can't do this in release, since
// in cases that mir lowering fails, we don't handle (and don't need to handle) drop scopes so it will be
// actually reached. `pop_drop_scope_assert_finished` will also detect this case, but doesn't show useful
diff --git a/crates/ide/src/inlay_hints/implicit_drop.rs b/crates/ide/src/inlay_hints/implicit_drop.rs
index 3104b85768..8d9ad5bda1 100644
--- a/crates/ide/src/inlay_hints/implicit_drop.rs
+++ b/crates/ide/src/inlay_hints/implicit_drop.rs
@@ -1,10 +1,8 @@
//! Implementation of "implicit drop" inlay hints:
-//! ```no_run
-//! fn main() {
-//! let x = vec![2];
-//! if some_condition() {
-//! /* drop(x) */return;
-//! }
+//! ```ignore
+//! let x = vec![2];
+//! if some_condition() {
+//! /* drop(x) */return;
//! }
//! ```
use hir::{
diff --git a/crates/ide/src/inlay_hints/range_exclusive.rs b/crates/ide/src/inlay_hints/range_exclusive.rs
index 50ab15c504..c4b0c199fc 100644
--- a/crates/ide/src/inlay_hints/range_exclusive.rs
+++ b/crates/ide/src/inlay_hints/range_exclusive.rs
@@ -1,5 +1,5 @@
//! Implementation of "range exclusive" inlay hints:
-//! ```no_run
+//! ```ignore
//! for i in 0../* < */10 {}
//! if let ../* < */100 = 50 {}
//! ```