From df03b083c99626bc3728cdf6b49377a749c4d9bd Mon Sep 17 00:00:00 2001 From: Taylor Yu Date: Fri, 4 Jun 2021 17:02:13 -0500 Subject: [PATCH] move implicit `Sized` predicate to end of list In `Bounds::predicates()`, move the implicit `Sized` predicate to the end of the generated list. This means that if there is an explicit `Sized` bound, it will be checked first, and any resulting diagnostics will have a more useful span. --- compiler/rustc_typeck/src/bounds.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_typeck/src/bounds.rs b/compiler/rustc_typeck/src/bounds.rs index 24474e163b9..ff04e07acc4 100644 --- a/compiler/rustc_typeck/src/bounds.rs +++ b/compiler/rustc_typeck/src/bounds.rs @@ -64,16 +64,16 @@ impl<'tcx> Bounds<'tcx> { }) }); - sized_predicate - .into_iter() - .chain(self.region_bounds.iter().map(|&(region_bound, span)| { + self.region_bounds + .iter() + .map(|&(region_bound, span)| { ( region_bound .map_bound(|region_bound| ty::OutlivesPredicate(param_ty, region_bound)) .to_predicate(tcx), span, ) - })) + }) .chain(self.trait_bounds.iter().map(|&(bound_trait_ref, span, constness)| { let predicate = bound_trait_ref.with_constness(constness).to_predicate(tcx); (predicate, span) @@ -83,6 +83,7 @@ impl<'tcx> Bounds<'tcx> { .iter() .map(|&(projection, span)| (projection.to_predicate(tcx), span)), ) + .chain(sized_predicate.into_iter()) .collect() } }