mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Rollup merge of #135069 - matthiaskrgr:param_rec_usage, r=jieyouxu
remove unused function params
This commit is contained in:
commit
725b799478
@ -69,10 +69,10 @@ impl<'tcx> Ty<'tcx> {
|
|||||||
/// description in error messages. This is used in the primary span label. Beyond what
|
/// description in error messages. This is used in the primary span label. Beyond what
|
||||||
/// `is_simple_ty` includes, it also accepts ADTs with no type arguments and references to
|
/// `is_simple_ty` includes, it also accepts ADTs with no type arguments and references to
|
||||||
/// ADTs with no type arguments.
|
/// ADTs with no type arguments.
|
||||||
pub fn is_simple_text(self, tcx: TyCtxt<'tcx>) -> bool {
|
pub fn is_simple_text(self) -> bool {
|
||||||
match self.kind() {
|
match self.kind() {
|
||||||
Adt(_, args) => args.non_erasable_generics().next().is_none(),
|
Adt(_, args) => args.non_erasable_generics().next().is_none(),
|
||||||
Ref(_, ty, _) => ty.is_simple_text(tcx),
|
Ref(_, ty, _) => ty.is_simple_text(),
|
||||||
_ => self.is_simple_ty(),
|
_ => self.is_simple_ty(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1822,9 +1822,6 @@ impl<'tcx> Visitor<'tcx> for EnsureCoroutineFieldAssignmentsNeverAlias<'_> {
|
|||||||
fn check_suspend_tys<'tcx>(tcx: TyCtxt<'tcx>, layout: &CoroutineLayout<'tcx>, body: &Body<'tcx>) {
|
fn check_suspend_tys<'tcx>(tcx: TyCtxt<'tcx>, layout: &CoroutineLayout<'tcx>, body: &Body<'tcx>) {
|
||||||
let mut linted_tys = FxHashSet::default();
|
let mut linted_tys = FxHashSet::default();
|
||||||
|
|
||||||
// We want a user-facing param-env.
|
|
||||||
let param_env = tcx.param_env(body.source.def_id());
|
|
||||||
|
|
||||||
for (variant, yield_source_info) in
|
for (variant, yield_source_info) in
|
||||||
layout.variant_fields.iter().zip(&layout.variant_source_info)
|
layout.variant_fields.iter().zip(&layout.variant_source_info)
|
||||||
{
|
{
|
||||||
@ -1838,7 +1835,7 @@ fn check_suspend_tys<'tcx>(tcx: TyCtxt<'tcx>, layout: &CoroutineLayout<'tcx>, bo
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
check_must_not_suspend_ty(tcx, decl.ty, hir_id, param_env, SuspendCheckData {
|
check_must_not_suspend_ty(tcx, decl.ty, hir_id, SuspendCheckData {
|
||||||
source_span: decl.source_info.span,
|
source_span: decl.source_info.span,
|
||||||
yield_span: yield_source_info.span,
|
yield_span: yield_source_info.span,
|
||||||
plural_len: 1,
|
plural_len: 1,
|
||||||
@ -1868,7 +1865,6 @@ fn check_must_not_suspend_ty<'tcx>(
|
|||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
hir_id: hir::HirId,
|
hir_id: hir::HirId,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
|
||||||
data: SuspendCheckData<'_>,
|
data: SuspendCheckData<'_>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
if ty.is_unit() {
|
if ty.is_unit() {
|
||||||
@ -1883,16 +1879,13 @@ fn check_must_not_suspend_ty<'tcx>(
|
|||||||
ty::Adt(_, args) if ty.is_box() => {
|
ty::Adt(_, args) if ty.is_box() => {
|
||||||
let boxed_ty = args.type_at(0);
|
let boxed_ty = args.type_at(0);
|
||||||
let allocator_ty = args.type_at(1);
|
let allocator_ty = args.type_at(1);
|
||||||
check_must_not_suspend_ty(tcx, boxed_ty, hir_id, param_env, SuspendCheckData {
|
check_must_not_suspend_ty(tcx, boxed_ty, hir_id, SuspendCheckData {
|
||||||
descr_pre: &format!("{}boxed ", data.descr_pre),
|
descr_pre: &format!("{}boxed ", data.descr_pre),
|
||||||
..data
|
..data
|
||||||
}) || check_must_not_suspend_ty(
|
}) || check_must_not_suspend_ty(tcx, allocator_ty, hir_id, SuspendCheckData {
|
||||||
tcx,
|
descr_pre: &format!("{}allocator ", data.descr_pre),
|
||||||
allocator_ty,
|
..data
|
||||||
hir_id,
|
})
|
||||||
param_env,
|
|
||||||
SuspendCheckData { descr_pre: &format!("{}allocator ", data.descr_pre), ..data },
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
ty::Adt(def, _) => check_must_not_suspend_def(tcx, def.did(), hir_id, data),
|
ty::Adt(def, _) => check_must_not_suspend_def(tcx, def.did(), hir_id, data),
|
||||||
// FIXME: support adding the attribute to TAITs
|
// FIXME: support adding the attribute to TAITs
|
||||||
@ -1937,7 +1930,7 @@ fn check_must_not_suspend_ty<'tcx>(
|
|||||||
let mut has_emitted = false;
|
let mut has_emitted = false;
|
||||||
for (i, ty) in fields.iter().enumerate() {
|
for (i, ty) in fields.iter().enumerate() {
|
||||||
let descr_post = &format!(" in tuple element {i}");
|
let descr_post = &format!(" in tuple element {i}");
|
||||||
if check_must_not_suspend_ty(tcx, ty, hir_id, param_env, SuspendCheckData {
|
if check_must_not_suspend_ty(tcx, ty, hir_id, SuspendCheckData {
|
||||||
descr_post,
|
descr_post,
|
||||||
..data
|
..data
|
||||||
}) {
|
}) {
|
||||||
@ -1948,7 +1941,7 @@ fn check_must_not_suspend_ty<'tcx>(
|
|||||||
}
|
}
|
||||||
ty::Array(ty, len) => {
|
ty::Array(ty, len) => {
|
||||||
let descr_pre = &format!("{}array{} of ", data.descr_pre, plural_suffix);
|
let descr_pre = &format!("{}array{} of ", data.descr_pre, plural_suffix);
|
||||||
check_must_not_suspend_ty(tcx, ty, hir_id, param_env, SuspendCheckData {
|
check_must_not_suspend_ty(tcx, ty, hir_id, SuspendCheckData {
|
||||||
descr_pre,
|
descr_pre,
|
||||||
// FIXME(must_not_suspend): This is wrong. We should handle printing unevaluated consts.
|
// FIXME(must_not_suspend): This is wrong. We should handle printing unevaluated consts.
|
||||||
plural_len: len.try_to_target_usize(tcx).unwrap_or(0) as usize + 1,
|
plural_len: len.try_to_target_usize(tcx).unwrap_or(0) as usize + 1,
|
||||||
@ -1959,10 +1952,7 @@ fn check_must_not_suspend_ty<'tcx>(
|
|||||||
// may not be considered live across the await point.
|
// may not be considered live across the await point.
|
||||||
ty::Ref(_region, ty, _mutability) => {
|
ty::Ref(_region, ty, _mutability) => {
|
||||||
let descr_pre = &format!("{}reference{} to ", data.descr_pre, plural_suffix);
|
let descr_pre = &format!("{}reference{} to ", data.descr_pre, plural_suffix);
|
||||||
check_must_not_suspend_ty(tcx, ty, hir_id, param_env, SuspendCheckData {
|
check_must_not_suspend_ty(tcx, ty, hir_id, SuspendCheckData { descr_pre, ..data })
|
||||||
descr_pre,
|
|
||||||
..data
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
|
@ -1496,8 +1496,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||||||
ValuePairs::Terms(ExpectedFound { expected, found }) => {
|
ValuePairs::Terms(ExpectedFound { expected, found }) => {
|
||||||
match (expected.unpack(), found.unpack()) {
|
match (expected.unpack(), found.unpack()) {
|
||||||
(ty::TermKind::Ty(expected), ty::TermKind::Ty(found)) => {
|
(ty::TermKind::Ty(expected), ty::TermKind::Ty(found)) => {
|
||||||
let is_simple_err = expected.is_simple_text(self.tcx)
|
let is_simple_err =
|
||||||
&& found.is_simple_text(self.tcx);
|
expected.is_simple_text() && found.is_simple_text();
|
||||||
OpaqueTypesVisitor::visit_expected_found(
|
OpaqueTypesVisitor::visit_expected_found(
|
||||||
self.tcx, expected, found, span,
|
self.tcx, expected, found, span,
|
||||||
)
|
)
|
||||||
@ -1736,8 +1736,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||||||
(true, _) => format!(" ({})", ty.sort_string(self.tcx)),
|
(true, _) => format!(" ({})", ty.sort_string(self.tcx)),
|
||||||
(false, _) => "".to_string(),
|
(false, _) => "".to_string(),
|
||||||
};
|
};
|
||||||
if !(values.expected.is_simple_text(self.tcx)
|
if !(values.expected.is_simple_text() && values.found.is_simple_text())
|
||||||
&& values.found.is_simple_text(self.tcx))
|
|
||||||
|| (exp_found.is_some_and(|ef| {
|
|| (exp_found.is_some_and(|ef| {
|
||||||
// This happens when the type error is a subset of the expectation,
|
// This happens when the type error is a subset of the expectation,
|
||||||
// like when you have two references but one is `usize` and the other
|
// like when you have two references but one is `usize` and the other
|
||||||
|
Loading…
Reference in New Issue
Block a user