Skip to content

Commit

Permalink
move implicit Sized predicate to end of list
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tlyu committed Oct 8, 2021
1 parent 485ced5 commit df03b08
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions compiler/rustc_typeck/src/bounds.rs
Expand Up @@ -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)
Expand All @@ -83,6 +83,7 @@ impl<'tcx> Bounds<'tcx> {
.iter()
.map(|&(projection, span)| (projection.to_predicate(tcx), span)),
)
.chain(sized_predicate.into_iter())
.collect()
}
}

0 comments on commit df03b08

Please sign in to comment.