1
Fork 0

Auto merge of #13492 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none
This commit is contained in:
bors 2024-10-03 13:34:02 +00:00
commit aa0d551351
13 changed files with 23 additions and 33 deletions

View file

@ -385,8 +385,7 @@ fn check_unsafe_derive_deserialize<'tcx>(
&& cx && cx
.tcx .tcx
.inherent_impls(def.did()) .inherent_impls(def.did())
.into_iter() .iter()
.flatten()
.map(|imp_did| cx.tcx.hir().expect_item(imp_did.expect_local())) .map(|imp_did| cx.tcx.hir().expect_item(imp_did.expect_local()))
.any(|imp| has_unsafe(cx, imp)) .any(|imp| has_unsafe(cx, imp))
{ {

View file

@ -51,9 +51,7 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl {
// List of spans to lint. (lint_span, first_span) // List of spans to lint. (lint_span, first_span)
let mut lint_spans = Vec::new(); let mut lint_spans = Vec::new();
let Ok(impls) = cx.tcx.crate_inherent_impls(()) else { let (impls, _) = cx.tcx.crate_inherent_impls(());
return;
};
for (&id, impl_ids) in &impls.inherent_impls { for (&id, impl_ids) in &impls.inherent_impls {
if impl_ids.len() < 2 if impl_ids.len() < 2

View file

@ -460,8 +460,7 @@ fn check_for_is_empty(
let is_empty = cx let is_empty = cx
.tcx .tcx
.inherent_impls(impl_ty) .inherent_impls(impl_ty)
.into_iter() .iter()
.flatten()
.flat_map(|&id| cx.tcx.associated_items(id).filter_by_name_unhygienic(is_empty)) .flat_map(|&id| cx.tcx.associated_items(id).filter_by_name_unhygienic(is_empty))
.find(|item| item.kind == AssocKind::Fn); .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. /// Checks the inherent impl's items for an `is_empty(self)` method.
fn has_is_empty_impl(cx: &LateContext<'_>, id: DefId) -> bool { fn has_is_empty_impl(cx: &LateContext<'_>, id: DefId) -> bool {
let is_empty = sym!(is_empty); 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 cx.tcx
.associated_items(*imp) .associated_items(*imp)
.filter_by_name_unhygienic(is_empty) .filter_by_name_unhygienic(is_empty)

View file

@ -77,8 +77,7 @@ pub(super) fn check<'tcx>(
let Some(suggested_method_def_id) = receiver_ty.ty_adt_def().and_then(|adt_def| { let Some(suggested_method_def_id) = receiver_ty.ty_adt_def().and_then(|adt_def| {
cx.tcx cx.tcx
.inherent_impls(adt_def.did()) .inherent_impls(adt_def.did())
.into_iter() .iter()
.flatten()
.flat_map(|impl_id| cx.tcx.associated_items(impl_id).filter_by_name_unhygienic(sugg)) .flat_map(|impl_id| cx.tcx.associated_items(impl_id).filter_by_name_unhygienic(sugg))
.find_map(|assoc| { .find_map(|assoc| {
if assoc.fn_has_self_parameter if assoc.fn_has_self_parameter

View file

@ -80,7 +80,7 @@ impl<'tcx> LateLintPass<'tcx> for InterningDefinedSymbol {
&& let ty = cx.tcx.type_of(item_def_id).instantiate_identity() && let ty = cx.tcx.type_of(item_def_id).instantiate_identity()
&& match_type(cx, ty, &paths::SYMBOL) && match_type(cx, ty, &paths::SYMBOL)
&& let Ok(ConstValue::Scalar(value)) = cx.tcx.const_eval_poly(item_def_id) && 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); self.symbol_map.insert(value, item_def_id);
} }

View file

@ -72,8 +72,7 @@ pub fn check_path(cx: &LateContext<'_>, path: &[&str]) -> bool {
SimplifiedType::Bool, SimplifiedType::Bool,
] ]
.iter() .iter()
.flat_map(|&ty| cx.tcx.incoherent_impls(ty).into_iter()) .flat_map(|&ty| cx.tcx.incoherent_impls(ty).iter())
.flatten()
.copied(); .copied();
for item_def_id in lang_items.iter().map(|(_, def_id)| def_id).chain(incoherent_impls) { 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); let lang_item_path = cx.get_def_path(item_def_id);

View file

@ -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 range = alloc_range(offset + size * idx, size);
let val = alloc.read_scalar(&tcx, range, /* read_provenance */ false).ok()?; let val = alloc.read_scalar(&tcx, range, /* read_provenance */ false).ok()?;
res.push(match flt { res.push(match flt {
FloatTy::F16 => Constant::F16(f16::from_bits(val.to_u16().ok()?)), FloatTy::F16 => Constant::F16(f16::from_bits(val.to_u16().discard_err()?)),
FloatTy::F32 => Constant::F32(f32::from_bits(val.to_u32().ok()?)), FloatTy::F32 => Constant::F32(f32::from_bits(val.to_u32().discard_err()?)),
FloatTy::F64 => Constant::F64(f64::from_bits(val.to_u64().ok()?)), FloatTy::F64 => Constant::F64(f64::from_bits(val.to_u64().discard_err()?)),
FloatTy::F128 => Constant::F128(f128::from_bits(val.to_u128().ok()?)), FloatTy::F128 => Constant::F128(f128::from_bits(val.to_u128().discard_err()?)),
}); });
} }
Some(Constant::Vec(res)) Some(Constant::Vec(res))
@ -903,7 +903,7 @@ fn mir_is_empty<'tcx>(tcx: TyCtxt<'tcx>, result: mir::Const<'tcx>) -> Option<boo
.read_scalar(&tcx, alloc_range(offset + ptr_size, ptr_size), false) .read_scalar(&tcx, alloc_range(offset + ptr_size, ptr_size), false)
.ok()? .ok()?
.to_target_usize(&tcx) .to_target_usize(&tcx)
.ok()?; .discard_err()?;
Some(len == 0) Some(len == 0)
} else { } else {
None None

View file

@ -593,14 +593,11 @@ fn find_primitive_impls<'tcx>(tcx: TyCtxt<'tcx>, name: &str) -> impl Iterator<It
"f32" => SimplifiedType::Float(FloatTy::F32), "f32" => SimplifiedType::Float(FloatTy::F32),
"f64" => SimplifiedType::Float(FloatTy::F64), "f64" => SimplifiedType::Float(FloatTy::F64),
_ => { _ => {
return Result::<&[_], rustc_errors::ErrorGuaranteed>::Ok(&[]) return [].iter().copied();
.into_iter()
.flatten()
.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<Res> { fn non_local_item_children_by_name(tcx: TyCtxt<'_>, def_id: DefId, name: Symbol) -> Vec<Res> {
@ -734,8 +731,7 @@ pub fn def_path_res_with_base(tcx: TyCtxt<'_>, mut base: Vec<Res>, mut path: &[&
// `impl S { ... }` // `impl S { ... }`
let inherent_impl_children = tcx let inherent_impl_children = tcx
.inherent_impls(def_id) .inherent_impls(def_id)
.into_iter() .iter()
.flatten()
.flat_map(|&impl_def_id| item_children_by_name(tcx, impl_def_id, segment)); .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); let direct_children = item_children_by_name(tcx, def_id, segment);

View file

@ -123,7 +123,7 @@ fn check_rvalue<'tcx>(
| CastKind::FloatToFloat | CastKind::FloatToFloat
| CastKind::FnPtrToPtr | CastKind::FnPtrToPtr
| CastKind::PtrToPtr | CastKind::PtrToPtr
| CastKind::PointerCoercion(PointerCoercion::MutToConstPointer | PointerCoercion::ArrayToPointer), | CastKind::PointerCoercion(PointerCoercion::MutToConstPointer | PointerCoercion::ArrayToPointer, _),
operand, operand,
_, _,
) => check_operand(tcx, operand, span, body, msrv), ) => check_operand(tcx, operand, span, body, msrv),
@ -132,11 +132,12 @@ fn check_rvalue<'tcx>(
PointerCoercion::UnsafeFnPointer PointerCoercion::UnsafeFnPointer
| PointerCoercion::ClosureFnPointer(_) | PointerCoercion::ClosureFnPointer(_)
| PointerCoercion::ReifyFnPointer, | PointerCoercion::ReifyFnPointer,
_,
), ),
_, _,
_, _,
) => Err((span, "function pointer casts are not allowed in const fn".into())), ) => 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 { let Some(pointee_ty) = cast_ty.builtin_deref(true) else {
// We cannot allow this for now. // We cannot allow this for now.
return Err((span, "unsizing casts are only allowed for references right now".into())); 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, _, _) => { Rvalue::Cast(CastKind::PointerExposeProvenance, _, _) => {
Err((span, "casting pointers to ints is unstable in const fn".into())) 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) // FIXME(dyn-star)
unimplemented!() unimplemented!()
}, },

View file

@ -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(...)`. /// 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> { 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) { 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 cx.tcx
.associated_items(did) .associated_items(did)
.filter_by_name_unhygienic(method_name) .filter_by_name_unhygienic(method_name)

View file

@ -1,4 +1,4 @@
[toolchain] [toolchain]
channel = "nightly-2024-09-22" channel = "nightly-2024-10-03"
components = ["cargo", "llvm-tools", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"] components = ["cargo", "llvm-tools", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"]
profile = "minimal" profile = "minimal"

View file

@ -1,8 +1,8 @@
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time 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<T>() -> impl Iterator<Item = [(); { |x: [u8]| x }]> { LL | fn bug<T>() -> impl Iterator<Item = [(); { |x: [u8]| x }]> {
| ^ 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: the trait `std::marker::Sized` is not implemented for `[u8]`
= help: unsized fn params are gated as an unstable feature = help: unsized fn params are gated as an unstable feature

View file

@ -2,7 +2,6 @@
from string import Template from string import Template
import argparse import argparse
import json
import os import os
import sys import sys