Skip to content

Commit 5864487

Browse files
committed
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.
1 parent 704934d commit 5864487

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

compiler/rustc_typeck/src/bounds.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ impl<'tcx> Bounds<'tcx> {
6565
})
6666
});
6767

68-
sized_predicate
69-
.into_iter()
70-
.chain(self.region_bounds.iter().map(|&(region_bound, span)| {
68+
self.region_bounds
69+
.iter()
70+
.map(|&(region_bound, span)| {
7171
(
7272
region_bound
7373
.map_bound(|region_bound| ty::OutlivesPredicate(param_ty, region_bound))
7474
.to_predicate(tcx),
7575
span,
7676
)
77-
}))
77+
})
7878
.chain(self.trait_bounds.iter().map(|&(bound_trait_ref, span, constness)| {
7979
let predicate = bound_trait_ref.with_constness(constness).to_predicate(tcx);
8080
(predicate, span)
@@ -84,6 +84,7 @@ impl<'tcx> Bounds<'tcx> {
8484
.iter()
8585
.map(|&(projection, span)| (projection.to_predicate(tcx), span)),
8686
)
87+
.chain(sized_predicate.into_iter())
8788
.collect()
8889
}
8990
}

0 commit comments

Comments
 (0)