diff options
| author | Sunjay Varma <varma.sunjay@gmail.com> | 2018-08-09 15:05:24 -0600 |
|---|---|---|
| committer | Sunjay Varma <varma.sunjay@gmail.com> | 2018-08-09 15:05:24 -0600 |
| commit | 644765197abd9a219d88b98323084b2ac29388b7 (patch) | |
| tree | 0501e210cd7824db4479fd2ff568edf6c8a3c72a | |
| parent | 5e7763381f0acf9b2f4058ae110f0bd013d685eb (diff) | |
| download | rust-644765197abd9a219d88b98323084b2ac29388b7.tar.gz rust-644765197abd9a219d88b98323084b2ac29388b7.zip | |
Preferring BuiltInCandidate { has_nested: false } in all cases
| -rw-r--r-- | src/librustc/traits/select.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 35184ca6a25..b67d11914e4 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -226,6 +226,7 @@ pub struct SelectionCache<'tcx> { /// parameter environment. #[derive(PartialEq,Eq,Debug,Clone)] enum SelectionCandidate<'tcx> { + /// If has_nested is false, there are no *further* obligations BuiltinCandidate { has_nested: bool }, ParamCandidate(ty::PolyTraitRef<'tcx>), ImplCandidate(DefId), @@ -2039,12 +2040,20 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { } match other.candidate { + // Prefer BuiltinCandidate { has_nested: false } to anything else. + // This is a fix for #53123 and prevents winnowing from accidentally extending the + // lifetime of a variable. + BuiltinCandidate { has_nested: false } => true, ParamCandidate(ref cand) => match victim.candidate { AutoImplCandidate(..) => { bug!( "default implementations shouldn't be recorded \ when there are other valid candidates"); } + // Prefer BuiltinCandidate { has_nested: false } to anything else. + // This is a fix for #53123 and prevents winnowing from accidentally extending the + // lifetime of a variable. + BuiltinCandidate { has_nested: false } => false, ImplCandidate(..) | ClosureCandidate | GeneratorCandidate | @@ -2072,6 +2081,10 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { "default implementations shouldn't be recorded \ when there are other valid candidates"); } + // Prefer BuiltinCandidate { has_nested: false } to anything else. + // This is a fix for #53123 and prevents winnowing from accidentally extending the + // lifetime of a variable. + BuiltinCandidate { has_nested: false } => false, ImplCandidate(..) | ClosureCandidate | GeneratorCandidate | @@ -2115,7 +2128,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { FnPointerCandidate | BuiltinObjectCandidate | BuiltinUnsizeCandidate | - BuiltinCandidate { .. } => { + BuiltinCandidate { has_nested: true } => { match victim.candidate { ParamCandidate(ref cand) => { // Prefer these to a global where-clause bound |
