Skip to content

Commit f32f57f

Browse files
committed
explain ImportData::imported_module
1 parent 13c46fd commit f32f57f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

compiler/rustc_resolve/src/imports.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,17 @@ pub(crate) struct ImportData<'ra> {
174174

175175
pub parent_scope: ParentScope<'ra>,
176176
pub module_path: Vec<Segment>,
177-
/// The resolution of `module_path`.
177+
/// The resolution of `module_path`:
178+
/// - It refers to `a::b` when the `module_path` is `::a::b::c`
179+
/// in 2018+ editions, where `a` must be an external crate.
180+
/// - It refers to `crate::a::b` when the `module_path` is `::a::b::c`
181+
/// in 2015 edition, where `a` can be either an external crate or
182+
/// a module defined at crate root.
183+
/// - It refers to `a::b` when the `module_path` is `a::b::c`, and
184+
/// `a` refers to the module defined in the scope where the use
185+
/// statement appears.
186+
/// - It refers to the module or scope where the use statement is
187+
/// defined when the `module_path` only has one segment.
178188
pub imported_module: Cell<Option<ModuleOrUniformRoot<'ra>>>,
179189
pub vis: ty::Visibility,
180190
}

0 commit comments

Comments
 (0)