1
Fork 0

Auto merge of #78177 - benjaminp:cleanups, r=jyn514

A few miscellaneous comment fixes and a tiny code clarification.
This commit is contained in:
bors 2020-12-04 07:11:41 +00:00
commit e6225434ff
4 changed files with 20 additions and 25 deletions

View file

@ -24,9 +24,9 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> {
// as-is, we need to do some extra work here in order to make sure // as-is, we need to do some extra work here in order to make sure
// that function subtyping works correctly with respect to regions // that function subtyping works correctly with respect to regions
// //
// Note: this is a subtle algorithm. For a full explanation, // Note: this is a subtle algorithm. For a full explanation, please see
// please see the large comment at the end of the file in the (inlined) module // the rustc dev guide:
// `doc`. // <https://rustc-dev-guide.rust-lang.org/borrow_check/region_inference/placeholders_and_universes.html>
let span = self.trace.cause.span; let span = self.trace.cause.span;

View file

@ -67,22 +67,18 @@ impl<'tcx> Bounds<'tcx> {
sized_predicate sized_predicate
.into_iter() .into_iter()
.chain(self.region_bounds.iter().map(|&(region_bound, span)| {
let outlives = ty::OutlivesPredicate(param_ty, region_bound);
(ty::Binder::bind(outlives).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)
}))
.chain( .chain(
self.region_bounds self.projection_bounds
.iter() .iter()
.map(|&(region_bound, span)| { .map(|&(projection, span)| (projection.to_predicate(tcx), span)),
let outlives = ty::OutlivesPredicate(param_ty, region_bound);
(ty::Binder::bind(outlives).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)
}))
.chain(
self.projection_bounds
.iter()
.map(|&(projection, span)| (projection.to_predicate(tcx), span)),
),
) )
.collect() .collect()
} }

View file

@ -765,13 +765,12 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
) )
}); });
// It is illegal to invoke a method on a trait instance that // It is illegal to invoke a method on a trait instance that refers to
// refers to the `Self` type. An error will be reported by // the `Self` type. An [`ObjectSafetyViolation::SupertraitSelf`] error
// `enforce_object_limitations()` if the method refers to the // will be reported by `object_safety.rs` if the method refers to the
// `Self` type anywhere other than the receiver. Here, we use // `Self` type anywhere other than the receiver. Here, we use a
// a substitution that replaces `Self` with the object type // substitution that replaces `Self` with the object type itself. Hence,
// itself. Hence, a `&self` method will wind up with an // a `&self` method will wind up with an argument type like `&Trait`.
// argument type like `&Trait`.
let trait_ref = principal.with_self_ty(self.tcx, self_ty); let trait_ref = principal.with_self_ty(self.tcx, self_ty);
self.elaborate_bounds(iter::once(trait_ref), |this, new_trait_ref, item| { self.elaborate_bounds(iter::once(trait_ref), |this, new_trait_ref, item| {
let new_trait_ref = this.erase_late_bound_regions(new_trait_ref); let new_trait_ref = this.erase_late_bound_regions(new_trait_ref);

View file

@ -88,7 +88,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// The Writeback context. This visitor walks the AST, checking the // The Writeback context. This visitor walks the HIR, checking the
// fn-specific typeck results to find references to types or regions. It // fn-specific typeck results to find references to types or regions. It
// resolves those regions to remove inference variables and writes the // resolves those regions to remove inference variables and writes the
// final result back into the master typeck results in the tcx. Here and // final result back into the master typeck results in the tcx. Here and