Skip to content

Commit df03b08

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 485ced5 commit df03b08

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
@@ -64,16 +64,16 @@ impl<'tcx> Bounds<'tcx> {
6464
})
6565
});
6666

67-
sized_predicate
68-
.into_iter()
69-
.chain(self.region_bounds.iter().map(|&(region_bound, span)| {
67+
self.region_bounds
68+
.iter()
69+
.map(|&(region_bound, span)| {
7070
(
7171
region_bound
7272
.map_bound(|region_bound| ty::OutlivesPredicate(param_ty, region_bound))
7373
.to_predicate(tcx),
7474
span,
7575
)
76-
}))
76+
})
7777
.chain(self.trait_bounds.iter().map(|&(bound_trait_ref, span, constness)| {
7878
let predicate = bound_trait_ref.with_constness(constness).to_predicate(tcx);
7979
(predicate, span)
@@ -83,6 +83,7 @@ impl<'tcx> Bounds<'tcx> {
8383
.iter()
8484
.map(|&(projection, span)| (projection.to_predicate(tcx), span)),
8585
)
86+
.chain(sized_predicate.into_iter())
8687
.collect()
8788
}
8889
}

0 commit comments

Comments
 (0)