Skip to content

Commit

Permalink
explain how this works
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Nov 22, 2018
1 parent b83150e commit 5f2a173
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3070,7 +3070,29 @@ impl<'a> LoweringContext<'a> {
hir::ItemKind::Use(path, hir::UseKind::Glob)
}
UseTreeKind::Nested(ref trees) => {
// Nested imports are desugared into simple imports.
// Nested imports are desugared into simple
// imports. So if we start with
//
// ```
// pub(x) use foo::{a, b};
// ```
//
// we will create three items:
//
// ```
// pub(x) use foo::a;
// pub(x) use foo::b;
// pub(x) use foo::{}; // <-- this is called the `ListStem`
// ```
//
// The first two are produced by recursively invoking
// `lower_use_tree` (and indeed there may be things
// like `use foo::{a::{b, c}}` and so forth). They
// wind up being directly added to
// `self.items`. However, the structure of this
// function also requires us to return one item, and
// for that we return the `{}` import (called the
// "`ListStem`").

let prefix = Path {
segments,
Expand Down

0 comments on commit 5f2a173

Please sign in to comment.