Skip to content

Commit 647cb20

Browse files
nikomatsakispietroalbini
authored andcommitted
explain how this works
1 parent 19ba1b6 commit 647cb20

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/librustc/hir/lowering.rs

+23-1
Original file line numberDiff line numberDiff line change
@@ -3068,7 +3068,29 @@ impl<'a> LoweringContext<'a> {
30683068
hir::ItemKind::Use(path, hir::UseKind::Glob)
30693069
}
30703070
UseTreeKind::Nested(ref trees) => {
3071-
// Nested imports are desugared into simple imports.
3071+
// Nested imports are desugared into simple
3072+
// imports. So if we start with
3073+
//
3074+
// ```
3075+
// pub(x) use foo::{a, b};
3076+
// ```
3077+
//
3078+
// we will create three items:
3079+
//
3080+
// ```
3081+
// pub(x) use foo::a;
3082+
// pub(x) use foo::b;
3083+
// pub(x) use foo::{}; // <-- this is called the `ListStem`
3084+
// ```
3085+
//
3086+
// The first two are produced by recursively invoking
3087+
// `lower_use_tree` (and indeed there may be things
3088+
// like `use foo::{a::{b, c}}` and so forth). They
3089+
// wind up being directly added to
3090+
// `self.items`. However, the structure of this
3091+
// function also requires us to return one item, and
3092+
// for that we return the `{}` import (called the
3093+
// "`ListStem`").
30723094

30733095
let prefix = Path {
30743096
segments,

0 commit comments

Comments
 (0)