diff --git a/clippy_lints/src/derive.rs b/clippy_lints/src/derive.rs index 61c151d4f9d68..82a66cc92029b 100644 --- a/clippy_lints/src/derive.rs +++ b/clippy_lints/src/derive.rs @@ -385,8 +385,7 @@ fn check_unsafe_derive_deserialize<'tcx>( && cx .tcx .inherent_impls(def.did()) - .into_iter() - .flatten() + .iter() .map(|imp_did| cx.tcx.hir().expect_item(imp_did.expect_local())) .any(|imp| has_unsafe(cx, imp)) { diff --git a/clippy_lints/src/inherent_impl.rs b/clippy_lints/src/inherent_impl.rs index d39f910f9936d..309d2dfb28b87 100644 --- a/clippy_lints/src/inherent_impl.rs +++ b/clippy_lints/src/inherent_impl.rs @@ -51,9 +51,7 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl { // List of spans to lint. (lint_span, first_span) let mut lint_spans = Vec::new(); - let Ok(impls) = cx.tcx.crate_inherent_impls(()) else { - return; - }; + let (impls, _) = cx.tcx.crate_inherent_impls(()); for (&id, impl_ids) in &impls.inherent_impls { if impl_ids.len() < 2 diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index 3cd5f76e6b674..c88eb70384333 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -460,8 +460,7 @@ fn check_for_is_empty( let is_empty = cx .tcx .inherent_impls(impl_ty) - .into_iter() - .flatten() + .iter() .flat_map(|&id| cx.tcx.associated_items(id).filter_by_name_unhygienic(is_empty)) .find(|item| item.kind == AssocKind::Fn); @@ -629,7 +628,7 @@ fn has_is_empty(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { /// Checks the inherent impl's items for an `is_empty(self)` method. fn has_is_empty_impl(cx: &LateContext<'_>, id: DefId) -> bool { let is_empty = sym!(is_empty); - cx.tcx.inherent_impls(id).into_iter().flatten().any(|imp| { + cx.tcx.inherent_impls(id).iter().any(|imp| { cx.tcx .associated_items(*imp) .filter_by_name_unhygienic(is_empty) diff --git a/clippy_lints/src/methods/or_fun_call.rs b/clippy_lints/src/methods/or_fun_call.rs index 8a7e72b63bb5e..b971f60d41699 100644 --- a/clippy_lints/src/methods/or_fun_call.rs +++ b/clippy_lints/src/methods/or_fun_call.rs @@ -77,8 +77,7 @@ pub(super) fn check<'tcx>( let Some(suggested_method_def_id) = receiver_ty.ty_adt_def().and_then(|adt_def| { cx.tcx .inherent_impls(adt_def.did()) - .into_iter() - .flatten() + .iter() .flat_map(|impl_id| cx.tcx.associated_items(impl_id).filter_by_name_unhygienic(sugg)) .find_map(|assoc| { if assoc.fn_has_self_parameter diff --git a/clippy_lints/src/utils/internal_lints/interning_defined_symbol.rs b/clippy_lints/src/utils/internal_lints/interning_defined_symbol.rs index 7c2e23995c1d3..9e400d2391f02 100644 --- a/clippy_lints/src/utils/internal_lints/interning_defined_symbol.rs +++ b/clippy_lints/src/utils/internal_lints/interning_defined_symbol.rs @@ -80,7 +80,7 @@ impl<'tcx> LateLintPass<'tcx> for InterningDefinedSymbol { && let ty = cx.tcx.type_of(item_def_id).instantiate_identity() && match_type(cx, ty, &paths::SYMBOL) && let Ok(ConstValue::Scalar(value)) = cx.tcx.const_eval_poly(item_def_id) - && let Ok(value) = value.to_u32() + && let Some(value) = value.to_u32().discard_err() { self.symbol_map.insert(value, item_def_id); } diff --git a/clippy_lints/src/utils/internal_lints/invalid_paths.rs b/clippy_lints/src/utils/internal_lints/invalid_paths.rs index d444ad45087cf..96397375d5edb 100644 --- a/clippy_lints/src/utils/internal_lints/invalid_paths.rs +++ b/clippy_lints/src/utils/internal_lints/invalid_paths.rs @@ -72,8 +72,7 @@ pub fn check_path(cx: &LateContext<'_>, path: &[&str]) -> bool { SimplifiedType::Bool, ] .iter() - .flat_map(|&ty| cx.tcx.incoherent_impls(ty).into_iter()) - .flatten() + .flat_map(|&ty| cx.tcx.incoherent_impls(ty).iter()) .copied(); for item_def_id in lang_items.iter().map(|(_, def_id)| def_id).chain(incoherent_impls) { let lang_item_path = cx.get_def_path(item_def_id); diff --git a/clippy_utils/src/consts.rs b/clippy_utils/src/consts.rs index e0bc27ebe2e5a..510034876e051 100644 --- a/clippy_utils/src/consts.rs +++ b/clippy_utils/src/consts.rs @@ -870,10 +870,10 @@ pub fn mir_to_const<'tcx>(tcx: TyCtxt<'tcx>, result: mir::Const<'tcx>) -> Option let range = alloc_range(offset + size * idx, size); let val = alloc.read_scalar(&tcx, range, /* read_provenance */ false).ok()?; res.push(match flt { - FloatTy::F16 => Constant::F16(f16::from_bits(val.to_u16().ok()?)), - FloatTy::F32 => Constant::F32(f32::from_bits(val.to_u32().ok()?)), - FloatTy::F64 => Constant::F64(f64::from_bits(val.to_u64().ok()?)), - FloatTy::F128 => Constant::F128(f128::from_bits(val.to_u128().ok()?)), + FloatTy::F16 => Constant::F16(f16::from_bits(val.to_u16().discard_err()?)), + FloatTy::F32 => Constant::F32(f32::from_bits(val.to_u32().discard_err()?)), + FloatTy::F64 => Constant::F64(f64::from_bits(val.to_u64().discard_err()?)), + FloatTy::F128 => Constant::F128(f128::from_bits(val.to_u128().discard_err()?)), }); } Some(Constant::Vec(res)) @@ -903,7 +903,7 @@ fn mir_is_empty<'tcx>(tcx: TyCtxt<'tcx>, result: mir::Const<'tcx>) -> Option(tcx: TyCtxt<'tcx>, name: &str) -> impl Iterator SimplifiedType::Float(FloatTy::F32), "f64" => SimplifiedType::Float(FloatTy::F64), _ => { - return Result::<&[_], rustc_errors::ErrorGuaranteed>::Ok(&[]) - .into_iter() - .flatten() - .copied(); + return [].iter().copied(); }, }; - tcx.incoherent_impls(ty).into_iter().flatten().copied() + tcx.incoherent_impls(ty).iter().copied() } fn non_local_item_children_by_name(tcx: TyCtxt<'_>, def_id: DefId, name: Symbol) -> Vec { @@ -734,8 +731,7 @@ pub fn def_path_res_with_base(tcx: TyCtxt<'_>, mut base: Vec, mut path: &[& // `impl S { ... }` let inherent_impl_children = tcx .inherent_impls(def_id) - .into_iter() - .flatten() + .iter() .flat_map(|&impl_def_id| item_children_by_name(tcx, impl_def_id, segment)); let direct_children = item_children_by_name(tcx, def_id, segment); diff --git a/clippy_utils/src/qualify_min_const_fn.rs b/clippy_utils/src/qualify_min_const_fn.rs index 2ed20b7202cc3..5f12b6bf99ec2 100644 --- a/clippy_utils/src/qualify_min_const_fn.rs +++ b/clippy_utils/src/qualify_min_const_fn.rs @@ -123,7 +123,7 @@ fn check_rvalue<'tcx>( | CastKind::FloatToFloat | CastKind::FnPtrToPtr | CastKind::PtrToPtr - | CastKind::PointerCoercion(PointerCoercion::MutToConstPointer | PointerCoercion::ArrayToPointer), + | CastKind::PointerCoercion(PointerCoercion::MutToConstPointer | PointerCoercion::ArrayToPointer, _), operand, _, ) => check_operand(tcx, operand, span, body, msrv), @@ -132,11 +132,12 @@ fn check_rvalue<'tcx>( PointerCoercion::UnsafeFnPointer | PointerCoercion::ClosureFnPointer(_) | PointerCoercion::ReifyFnPointer, + _, ), _, _, ) => Err((span, "function pointer casts are not allowed in const fn".into())), - Rvalue::Cast(CastKind::PointerCoercion(PointerCoercion::Unsize), op, cast_ty) => { + Rvalue::Cast(CastKind::PointerCoercion(PointerCoercion::Unsize, _), op, cast_ty) => { let Some(pointee_ty) = cast_ty.builtin_deref(true) else { // We cannot allow this for now. return Err((span, "unsizing casts are only allowed for references right now".into())); @@ -154,7 +155,7 @@ fn check_rvalue<'tcx>( Rvalue::Cast(CastKind::PointerExposeProvenance, _, _) => { Err((span, "casting pointers to ints is unstable in const fn".into())) }, - Rvalue::Cast(CastKind::DynStar, _, _) => { + Rvalue::Cast(CastKind::PointerCoercion(PointerCoercion::DynStar, _), _, _) => { // FIXME(dyn-star) unimplemented!() }, diff --git a/clippy_utils/src/ty.rs b/clippy_utils/src/ty.rs index 775a98fe361d8..21c2b19f4bdd6 100644 --- a/clippy_utils/src/ty.rs +++ b/clippy_utils/src/ty.rs @@ -1319,7 +1319,7 @@ pub fn deref_chain<'cx, 'tcx>(cx: &'cx LateContext<'tcx>, ty: Ty<'tcx>) -> impl /// If you need this, you should wrap this call in `clippy_utils::ty::deref_chain().any(...)`. pub fn get_adt_inherent_method<'a>(cx: &'a LateContext<'_>, ty: Ty<'_>, method_name: Symbol) -> Option<&'a AssocItem> { if let Some(ty_did) = ty.ty_adt_def().map(AdtDef::did) { - cx.tcx.inherent_impls(ty_did).into_iter().flatten().find_map(|&did| { + cx.tcx.inherent_impls(ty_did).iter().find_map(|&did| { cx.tcx .associated_items(did) .filter_by_name_unhygienic(method_name) diff --git a/rust-toolchain b/rust-toolchain index b431599c224ef..f0c8651efce4e 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2024-09-22" +channel = "nightly-2024-10-03" components = ["cargo", "llvm-tools", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"] profile = "minimal" diff --git a/tests/ui/crashes/ice-6251.stderr b/tests/ui/crashes/ice-6251.stderr index 82e7d72358697..77c3e6288ce3c 100644 --- a/tests/ui/crashes/ice-6251.stderr +++ b/tests/ui/crashes/ice-6251.stderr @@ -1,8 +1,8 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> tests/ui/crashes/ice-6251.rs:4:45 + --> tests/ui/crashes/ice-6251.rs:4:48 | LL | fn bug() -> impl Iterator { - | ^ doesn't have a size known at compile-time + | ^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` = help: unsized fn params are gated as an unstable feature diff --git a/util/versions.py b/util/versions.py index 7a21a840a6d9a..fee0d292df16f 100755 --- a/util/versions.py +++ b/util/versions.py @@ -2,7 +2,6 @@ from string import Template import argparse -import json import os import sys