Skip to content

Commit 5f2a173

Browse files
committed
explain how this works
1 parent b83150e commit 5f2a173

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

30753097
let prefix = Path {
30763098
segments,

0 commit comments

Comments
 (0)