Check const Drop impls considering ConstIfConst bounds

This commit is contained in:
Michael Goulet
2022-01-18 01:43:49 -08:00
parent f9eb0b3b7b
commit 6ed42a7ca4
7 changed files with 227 additions and 167 deletions

View File

@@ -1153,7 +1153,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
GeneratorCandidate => {}
// FnDef where the function is const
FnPointerCandidate { is_const: true } => {}
ConstDropCandidate => {}
ConstDropCandidate(_) => {}
_ => {
// reject all other types of candidates
continue;
@@ -1537,7 +1537,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
};
// (*) Prefer `BuiltinCandidate { has_nested: false }`, `PointeeCandidate`,
// and `DiscriminantKindCandidate` to anything else.
// `DiscriminantKindCandidate`, and `ConstDropCandidate` to anything else.
//
// This is a fix for #53123 and prevents winnowing from accidentally extending the
// lifetime of a variable.
@@ -1554,7 +1554,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
BuiltinCandidate { has_nested: false }
| DiscriminantKindCandidate
| PointeeCandidate
| ConstDropCandidate,
| ConstDropCandidate(_),
_,
) => true,
(
@@ -1562,7 +1562,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
BuiltinCandidate { has_nested: false }
| DiscriminantKindCandidate
| PointeeCandidate
| ConstDropCandidate,
| ConstDropCandidate(_),
) => false,
(ParamCandidate(other), ParamCandidate(victim)) => {