Rollup merge of #105867 - matthiaskrgr:rec_param, r=compiler-errors
remove redundant fn params that were only "used" in recursion
This commit is contained in:
commit
e96166eb42
4 changed files with 10 additions and 44 deletions
|
@ -831,7 +831,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||||
if self.eval_verify_bound(
|
if self.eval_verify_bound(
|
||||||
infcx,
|
infcx,
|
||||||
param_env,
|
param_env,
|
||||||
body,
|
|
||||||
generic_ty,
|
generic_ty,
|
||||||
type_test.lower_bound,
|
type_test.lower_bound,
|
||||||
&type_test.verify_bound,
|
&type_test.verify_bound,
|
||||||
|
@ -962,14 +961,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||||
// where `ur` is a local bound -- we are sometimes in a
|
// where `ur` is a local bound -- we are sometimes in a
|
||||||
// position to prove things that our caller cannot. See
|
// position to prove things that our caller cannot. See
|
||||||
// #53570 for an example.
|
// #53570 for an example.
|
||||||
if self.eval_verify_bound(
|
if self.eval_verify_bound(infcx, param_env, generic_ty, ur, &type_test.verify_bound) {
|
||||||
infcx,
|
|
||||||
param_env,
|
|
||||||
body,
|
|
||||||
generic_ty,
|
|
||||||
ur,
|
|
||||||
&type_test.verify_bound,
|
|
||||||
) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1190,7 +1182,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||||
&self,
|
&self,
|
||||||
infcx: &InferCtxt<'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
body: &Body<'tcx>,
|
|
||||||
generic_ty: Ty<'tcx>,
|
generic_ty: Ty<'tcx>,
|
||||||
lower_bound: RegionVid,
|
lower_bound: RegionVid,
|
||||||
verify_bound: &VerifyBound<'tcx>,
|
verify_bound: &VerifyBound<'tcx>,
|
||||||
|
@ -1213,25 +1204,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
VerifyBound::AnyBound(verify_bounds) => verify_bounds.iter().any(|verify_bound| {
|
VerifyBound::AnyBound(verify_bounds) => verify_bounds.iter().any(|verify_bound| {
|
||||||
self.eval_verify_bound(
|
self.eval_verify_bound(infcx, param_env, generic_ty, lower_bound, verify_bound)
|
||||||
infcx,
|
|
||||||
param_env,
|
|
||||||
body,
|
|
||||||
generic_ty,
|
|
||||||
lower_bound,
|
|
||||||
verify_bound,
|
|
||||||
)
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
VerifyBound::AllBounds(verify_bounds) => verify_bounds.iter().all(|verify_bound| {
|
VerifyBound::AllBounds(verify_bounds) => verify_bounds.iter().all(|verify_bound| {
|
||||||
self.eval_verify_bound(
|
self.eval_verify_bound(infcx, param_env, generic_ty, lower_bound, verify_bound)
|
||||||
infcx,
|
|
||||||
param_env,
|
|
||||||
body,
|
|
||||||
generic_ty,
|
|
||||||
lower_bound,
|
|
||||||
verify_bound,
|
|
||||||
)
|
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,18 +99,17 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
span: Span,
|
|
||||||
) -> bool {
|
) -> bool {
|
||||||
// We don't just accept all !needs_drop fields, due to semver concerns.
|
// We don't just accept all !needs_drop fields, due to semver concerns.
|
||||||
match ty.kind() {
|
match ty.kind() {
|
||||||
ty::Ref(..) => true, // references never drop (even mutable refs, which are non-Copy and hence fail the later check)
|
ty::Ref(..) => true, // references never drop (even mutable refs, which are non-Copy and hence fail the later check)
|
||||||
ty::Tuple(tys) => {
|
ty::Tuple(tys) => {
|
||||||
// allow tuples of allowed types
|
// allow tuples of allowed types
|
||||||
tys.iter().all(|ty| allowed_union_field(ty, tcx, param_env, span))
|
tys.iter().all(|ty| allowed_union_field(ty, tcx, param_env))
|
||||||
}
|
}
|
||||||
ty::Array(elem, _len) => {
|
ty::Array(elem, _len) => {
|
||||||
// Like `Copy`, we do *not* special-case length 0.
|
// Like `Copy`, we do *not* special-case length 0.
|
||||||
allowed_union_field(*elem, tcx, param_env, span)
|
allowed_union_field(*elem, tcx, param_env)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// Fallback case: allow `ManuallyDrop` and things that are `Copy`.
|
// Fallback case: allow `ManuallyDrop` and things that are `Copy`.
|
||||||
|
@ -124,7 +123,7 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
|
||||||
for field in &def.non_enum_variant().fields {
|
for field in &def.non_enum_variant().fields {
|
||||||
let field_ty = field.ty(tcx, substs);
|
let field_ty = field.ty(tcx, substs);
|
||||||
|
|
||||||
if !allowed_union_field(field_ty, tcx, param_env, span) {
|
if !allowed_union_field(field_ty, tcx, param_env) {
|
||||||
let (field_span, ty_span) = match tcx.hir().get_if_local(field.did) {
|
let (field_span, ty_span) = match tcx.hir().get_if_local(field.did) {
|
||||||
// We are currently checking the type this field came from, so it must be local.
|
// We are currently checking the type this field came from, so it must be local.
|
||||||
Some(Node::Field(field)) => (field.span, field.ty.span),
|
Some(Node::Field(field)) => (field.span, field.ty.span),
|
||||||
|
|
|
@ -2130,7 +2130,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
&& let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span)
|
&& let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span)
|
||||||
{
|
{
|
||||||
let ty = self.resolve_vars_if_possible(ti.expected);
|
let ty = self.resolve_vars_if_possible(ti.expected);
|
||||||
let is_slice_or_array_or_vector = self.is_slice_or_array_or_vector(&mut err, snippet.clone(), ty);
|
let is_slice_or_array_or_vector = self.is_slice_or_array_or_vector(ty);
|
||||||
match is_slice_or_array_or_vector.1.kind() {
|
match is_slice_or_array_or_vector.1.kind() {
|
||||||
ty::Adt(adt_def, _)
|
ty::Adt(adt_def, _)
|
||||||
if self.tcx.is_diagnostic_item(sym::Option, adt_def.did())
|
if self.tcx.is_diagnostic_item(sym::Option, adt_def.did())
|
||||||
|
@ -2159,17 +2159,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
err.emit();
|
err.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_slice_or_array_or_vector(
|
fn is_slice_or_array_or_vector(&self, ty: Ty<'tcx>) -> (bool, Ty<'tcx>) {
|
||||||
&self,
|
|
||||||
err: &mut Diagnostic,
|
|
||||||
snippet: String,
|
|
||||||
ty: Ty<'tcx>,
|
|
||||||
) -> (bool, Ty<'tcx>) {
|
|
||||||
match ty.kind() {
|
match ty.kind() {
|
||||||
ty::Adt(adt_def, _) if self.tcx.is_diagnostic_item(sym::Vec, adt_def.did()) => {
|
ty::Adt(adt_def, _) if self.tcx.is_diagnostic_item(sym::Vec, adt_def.did()) => {
|
||||||
(true, ty)
|
(true, ty)
|
||||||
}
|
}
|
||||||
ty::Ref(_, ty, _) => self.is_slice_or_array_or_vector(err, snippet, *ty),
|
ty::Ref(_, ty, _) => self.is_slice_or_array_or_vector(*ty),
|
||||||
ty::Slice(..) | ty::Array(..) => (true, ty),
|
ty::Slice(..) | ty::Array(..) => (true, ty),
|
||||||
_ => (false, ty),
|
_ => (false, ty),
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,13 +159,12 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
||||||
orig_env,
|
orig_env,
|
||||||
orig_env,
|
orig_env,
|
||||||
&mut fresh_preds,
|
&mut fresh_preds,
|
||||||
false,
|
|
||||||
) else {
|
) else {
|
||||||
return AutoTraitResult::NegativeImpl;
|
return AutoTraitResult::NegativeImpl;
|
||||||
};
|
};
|
||||||
|
|
||||||
let (full_env, full_user_env) = self
|
let (full_env, full_user_env) = self
|
||||||
.evaluate_predicates(&infcx, trait_did, ty, new_env, user_env, &mut fresh_preds, true)
|
.evaluate_predicates(&infcx, trait_did, ty, new_env, user_env, &mut fresh_preds)
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
panic!("Failed to fully process: {:?} {:?} {:?}", ty, trait_did, orig_env)
|
panic!("Failed to fully process: {:?} {:?} {:?}", ty, trait_did, orig_env)
|
||||||
});
|
});
|
||||||
|
@ -247,7 +246,6 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
user_env: ty::ParamEnv<'tcx>,
|
user_env: ty::ParamEnv<'tcx>,
|
||||||
fresh_preds: &mut FxHashSet<ty::Predicate<'tcx>>,
|
fresh_preds: &mut FxHashSet<ty::Predicate<'tcx>>,
|
||||||
only_projections: bool,
|
|
||||||
) -> Option<(ty::ParamEnv<'tcx>, ty::ParamEnv<'tcx>)> {
|
) -> Option<(ty::ParamEnv<'tcx>, ty::ParamEnv<'tcx>)> {
|
||||||
let tcx = infcx.tcx;
|
let tcx = infcx.tcx;
|
||||||
|
|
||||||
|
@ -322,7 +320,6 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
||||||
fresh_preds,
|
fresh_preds,
|
||||||
&mut predicates,
|
&mut predicates,
|
||||||
&mut select,
|
&mut select,
|
||||||
only_projections,
|
|
||||||
) {
|
) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
@ -600,7 +597,6 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
||||||
fresh_preds: &mut FxHashSet<ty::Predicate<'tcx>>,
|
fresh_preds: &mut FxHashSet<ty::Predicate<'tcx>>,
|
||||||
predicates: &mut VecDeque<ty::PolyTraitPredicate<'tcx>>,
|
predicates: &mut VecDeque<ty::PolyTraitPredicate<'tcx>>,
|
||||||
selcx: &mut SelectionContext<'_, 'tcx>,
|
selcx: &mut SelectionContext<'_, 'tcx>,
|
||||||
only_projections: bool,
|
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let dummy_cause = ObligationCause::dummy();
|
let dummy_cause = ObligationCause::dummy();
|
||||||
|
|
||||||
|
@ -744,7 +740,6 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
||||||
fresh_preds,
|
fresh_preds,
|
||||||
predicates,
|
predicates,
|
||||||
selcx,
|
selcx,
|
||||||
only_projections,
|
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue