Skip to content

Commit 5bf5994

Browse files
author
Alexander Regueiro
committed
Fixed up some comments.
1 parent 538ebd1 commit 5bf5994

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

src/librustc/hir/lowering.rs

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,53 +1381,48 @@ impl<'a> LoweringContext<'a> {
13811381
let ty = match c.kind {
13821382
AssocTyConstraintKind::Equality { ref ty } => self.lower_ty(ty, itctx),
13831383
AssocTyConstraintKind::Bound { ref bounds } => {
1384-
// Piggy-back on the impl trait context to figure out
1385-
// the correct behavior.
1384+
// Piggy-back on the `impl Trait` context to figure out the correct behavior.
13861385
let (desugar_to_impl_trait, itctx) = match itctx {
13871386
// We are in the return position:
13881387
//
1389-
// fn foo() -> impl Iterator<Item: Debug>
1388+
// fn foo() -> impl Iterator<Item: Debug>
13901389
//
13911390
// so desugar to
13921391
//
1393-
// fn foo() -> impl Iterator<Item = impl Debug>
1392+
// fn foo() -> impl Iterator<Item = impl Debug>
13941393
ImplTraitContext::Existential(_) => (true, itctx),
13951394

13961395
// We are in the argument position, but within a dyn type:
13971396
//
1398-
// fn foo(x: dyn Iterator<Item: Debug>)
1397+
// fn foo(x: dyn Iterator<Item: Debug>)
13991398
//
14001399
// so desugar to
14011400
//
1402-
// fn foo(x: dyn Iterator<Item = impl Debug>)
1401+
// fn foo(x: dyn Iterator<Item = impl Debug>)
14031402
ImplTraitContext::Universal(_) if self.is_in_dyn_type => (true, itctx),
14041403

1405-
// In `type Foo = dyn Iterator<Item: Debug>` we
1406-
// desugar to `type Foo = dyn Iterator<Item = impl
1407-
// Debug>` but we have to override the "impl trait
1408-
// context" to permit `impl Debug` in this
1409-
// position (it desugars then to an existential
1410-
// type).
1404+
// In `type Foo = dyn Iterator<Item: Debug>` we desugar to
1405+
// `type Foo = dyn Iterator<Item = impl Debug>` but we have to override the
1406+
// "impl trait context" to permit `impl Debug` in this position (it desugars
1407+
// then to an existential type).
14111408
//
14121409
// FIXME: this is only needed until `impl Trait` is allowed in type aliases.
14131410
ImplTraitContext::Disallowed(_) if self.is_in_dyn_type =>
14141411
(true, ImplTraitContext::Existential(None)),
14151412

14161413
// We are in the argument position, but not within a dyn type:
14171414
//
1418-
// fn foo(x: impl Iterator<Item: Debug>)
1415+
// fn foo(x: impl Iterator<Item: Debug>)
14191416
//
1420-
// so we leave it as is and this gets expanded in
1421-
// astconv to a bound like `<T as Iterator>::Item:
1422-
// Debug` where `T` is the type parameter for the
1417+
// so we leave it as is and this gets expanded in astconv to a bound like
1418+
// `<T as Iterator>::Item: Debug` where `T` is the type parameter for the
14231419
// `impl Iterator`.
14241420
_ => (false, itctx),
14251421
};
14261422

14271423
if desugar_to_impl_trait {
1428-
// Desugar `AssocTy: Bounds` into `AssocTy = impl
1429-
// Bounds`. We do this by constructing the HIR
1430-
// for "impl bounds" and then lowering that.
1424+
// Desugar `AssocTy: Bounds` into `AssocTy = impl Bounds`. We do this by
1425+
// constructing the HIR for "impl bounds" and then lowering that.
14311426

14321427
let impl_trait_node_id = self.sess.next_node_id();
14331428
let parent_def_index = self.current_hir_id_owner.last().unwrap().0;

0 commit comments

Comments
 (0)