Skip to content

Commit bb0de88

Browse files
committed
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
2 parents cdc3e83 + c6637f3 commit bb0de88

File tree

7 files changed

+19
-16
lines changed

7 files changed

+19
-16
lines changed

Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,6 @@ new_ret_no_self = "allow"
168168
useless_asref = "allow"
169169

170170
## Following lints should be tackled at some point
171-
borrowed_box = "allow"
172-
derived_hash_with_manual_eq = "allow"
173-
forget_non_drop = "allow"
174-
needless_doctest_main = "allow"
175171
too_many_arguments = "allow"
176172
type_complexity = "allow"
177173
wrong_self_convention = "allow"

crates/hir-def/src/generics.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ impl GenericParamsCollector {
264264
self.add_where_predicate_from_bound(
265265
lower_ctx,
266266
bound,
267-
lifetimes.as_ref(),
267+
lifetimes.as_deref(),
268268
target.clone(),
269269
);
270270
}
@@ -275,14 +275,14 @@ impl GenericParamsCollector {
275275
&mut self,
276276
lower_ctx: &LowerCtx<'_>,
277277
bound: ast::TypeBound,
278-
hrtb_lifetimes: Option<&Box<[Name]>>,
278+
hrtb_lifetimes: Option<&[Name]>,
279279
target: Either<TypeRef, LifetimeRef>,
280280
) {
281281
let bound = TypeBound::from_ast(lower_ctx, bound);
282282
let predicate = match (target, bound) {
283283
(Either::Left(type_ref), bound) => match hrtb_lifetimes {
284284
Some(hrtb_lifetimes) => WherePredicate::ForLifetime {
285-
lifetimes: hrtb_lifetimes.clone(),
285+
lifetimes: hrtb_lifetimes.to_vec().into_boxed_slice(),
286286
target: WherePredicateTypeTarget::TypeRef(Interned::new(type_ref)),
287287
bound: Interned::new(bound),
288288
},

crates/hir-def/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,9 @@ impl Clone for Box<dyn OpaqueInternableThing> {
721721
pub struct InTypeConstId(salsa::InternId);
722722
impl_intern!(InTypeConstId, InTypeConstLoc, intern_in_type_const, lookup_intern_in_type_const);
723723

724+
// We would like to set `derive(PartialEq)`
725+
// but the compiler complains about that `.expected_ty` does not implement the `Copy` trait.
726+
#[allow(clippy::derived_hash_with_manual_eq)]
724727
#[derive(Debug, Hash, Eq, Clone)]
725728
pub struct InTypeConstLoc {
726729
pub id: AstId<ast::ConstArg>,

crates/hir-ty/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ impl MemoryMap {
228228
&self,
229229
mut f: impl FnMut(&[u8], usize) -> Result<usize, MirEvalError>,
230230
) -> Result<FxHashMap<usize, usize>, MirEvalError> {
231-
let mut transform = |(addr, val): (&usize, &Box<[u8]>)| {
231+
let mut transform = |(addr, val): (&usize, &[u8])| {
232232
let addr = *addr;
233233
let align = if addr == 0 { 64 } else { (addr - (addr & (addr - 1))).min(64) };
234234
f(val, align).map(|it| (addr, it))
@@ -240,7 +240,9 @@ impl MemoryMap {
240240
map.insert(addr, val);
241241
map
242242
}),
243-
MemoryMap::Complex(cm) => cm.memory.iter().map(transform).collect(),
243+
MemoryMap::Complex(cm) => {
244+
cm.memory.iter().map(|(addr, val)| transform((addr, val))).collect()
245+
}
244246
}
245247
}
246248

crates/hir-ty/src/mir/lower.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ impl DropScopeToken {
126126
}
127127
}
128128

129+
impl Drop for DropScopeToken {
130+
fn drop(&mut self) {}
131+
}
132+
129133
// Uncomment this to make `DropScopeToken` a drop bomb. Unfortunately we can't do this in release, since
130134
// in cases that mir lowering fails, we don't handle (and don't need to handle) drop scopes so it will be
131135
// actually reached. `pop_drop_scope_assert_finished` will also detect this case, but doesn't show useful

crates/ide/src/inlay_hints/implicit_drop.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
//! Implementation of "implicit drop" inlay hints:
2-
//! ```no_run
3-
//! fn main() {
4-
//! let x = vec![2];
5-
//! if some_condition() {
6-
//! /* drop(x) */return;
7-
//! }
2+
//! ```ignore
3+
//! let x = vec![2];
4+
//! if some_condition() {
5+
//! /* drop(x) */return;
86
//! }
97
//! ```
108
use hir::{

crates/ide/src/inlay_hints/range_exclusive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Implementation of "range exclusive" inlay hints:
2-
//! ```no_run
2+
//! ```ignore
33
//! for i in 0../* < */10 {}
44
//! if let ../* < */100 = 50 {}
55
//! ```

0 commit comments

Comments
 (0)