Skip to content

Commit e622543

Browse files
committed
Auto merge of #78177 - benjaminp:cleanups, r=jyn514
A few miscellaneous comment fixes and a tiny code clarification.
2 parents e9dd18c + 504f136 commit e622543

File tree

4 files changed

+20
-25
lines changed

4 files changed

+20
-25
lines changed

compiler/rustc_infer/src/infer/higher_ranked/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> {
2424
// as-is, we need to do some extra work here in order to make sure
2525
// that function subtyping works correctly with respect to regions
2626
//
27-
// Note: this is a subtle algorithm. For a full explanation,
28-
// please see the large comment at the end of the file in the (inlined) module
29-
// `doc`.
27+
// Note: this is a subtle algorithm. For a full explanation, please see
28+
// the rustc dev guide:
29+
// <https://rustc-dev-guide.rust-lang.org/borrow_check/region_inference/placeholders_and_universes.html>
3030

3131
let span = self.trace.cause.span;
3232

compiler/rustc_typeck/src/bounds.rs

+10-14
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,18 @@ impl<'tcx> Bounds<'tcx> {
6767

6868
sized_predicate
6969
.into_iter()
70+
.chain(self.region_bounds.iter().map(|&(region_bound, span)| {
71+
let outlives = ty::OutlivesPredicate(param_ty, region_bound);
72+
(ty::Binder::bind(outlives).to_predicate(tcx), span)
73+
}))
74+
.chain(self.trait_bounds.iter().map(|&(bound_trait_ref, span, constness)| {
75+
let predicate = bound_trait_ref.with_constness(constness).to_predicate(tcx);
76+
(predicate, span)
77+
}))
7078
.chain(
71-
self.region_bounds
79+
self.projection_bounds
7280
.iter()
73-
.map(|&(region_bound, span)| {
74-
let outlives = ty::OutlivesPredicate(param_ty, region_bound);
75-
(ty::Binder::bind(outlives).to_predicate(tcx), span)
76-
})
77-
.chain(self.trait_bounds.iter().map(|&(bound_trait_ref, span, constness)| {
78-
let predicate = bound_trait_ref.with_constness(constness).to_predicate(tcx);
79-
(predicate, span)
80-
}))
81-
.chain(
82-
self.projection_bounds
83-
.iter()
84-
.map(|&(projection, span)| (projection.to_predicate(tcx), span)),
85-
),
81+
.map(|&(projection, span)| (projection.to_predicate(tcx), span)),
8682
)
8783
.collect()
8884
}

compiler/rustc_typeck/src/check/method/probe.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -765,13 +765,12 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
765765
)
766766
});
767767

768-
// It is illegal to invoke a method on a trait instance that
769-
// refers to the `Self` type. An error will be reported by
770-
// `enforce_object_limitations()` if the method refers to the
771-
// `Self` type anywhere other than the receiver. Here, we use
772-
// a substitution that replaces `Self` with the object type
773-
// itself. Hence, a `&self` method will wind up with an
774-
// argument type like `&Trait`.
768+
// It is illegal to invoke a method on a trait instance that refers to
769+
// the `Self` type. An [`ObjectSafetyViolation::SupertraitSelf`] error
770+
// will be reported by `object_safety.rs` if the method refers to the
771+
// `Self` type anywhere other than the receiver. Here, we use a
772+
// substitution that replaces `Self` with the object type itself. Hence,
773+
// a `&self` method will wind up with an argument type like `&Trait`.
775774
let trait_ref = principal.with_self_ty(self.tcx, self_ty);
776775
self.elaborate_bounds(iter::once(trait_ref), |this, new_trait_ref, item| {
777776
let new_trait_ref = this.erase_late_bound_regions(new_trait_ref);

compiler/rustc_typeck/src/check/writeback.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
8888
}
8989

9090
///////////////////////////////////////////////////////////////////////////
91-
// The Writeback context. This visitor walks the AST, checking the
91+
// The Writeback context. This visitor walks the HIR, checking the
9292
// fn-specific typeck results to find references to types or regions. It
9393
// resolves those regions to remove inference variables and writes the
9494
// final result back into the master typeck results in the tcx. Here and

0 commit comments

Comments
 (0)