about summary refs log tree commit diff
path: root/src/libnative
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-04-08 14:31:25 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-04-10 15:22:00 -0700
commit83d2c0b8a6f6c2ce25fe48b541f176ea88be8d99 (patch)
treec3fe31457b4a636e8ff9745f5a86fb5734677fa7 /src/libnative
parent0bf4e900d421f011d7c68016308aab4998f9084e (diff)
downloadrust-83d2c0b8a6f6c2ce25fe48b541f176ea88be8d99.tar.gz
rust-83d2c0b8a6f6c2ce25fe48b541f176ea88be8d99.zip
rustc: Disallow importing through use statements
Resolve is currently erroneously allowing imports through private `use`
statements in some circumstances, even across module boundaries. For example,
this code compiles successfully today:

    use std::c_str;
    mod test {
        use c_str::CString;
    }

This should not be allowed because it was explicitly decided that private `use`
statements are purely bringing local names into scope, they are not
participating further in name resolution.

As a consequence of this patch, this code, while valid today, is now invalid:

    mod test {
        use std::c_str;

        unsafe fn foo() {
            ::test::c_str::CString::new(0 as *u8, false);
        }
    }

While plausibly acceptable, I found it to be more consistent if private imports
were only considered candidates to resolve the first component in a path, and no
others.

Closes #12612
Diffstat (limited to 'src/libnative')
-rw-r--r--src/libnative/io/file_win32.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libnative/io/file_win32.rs b/src/libnative/io/file_win32.rs
index 8090042f090..de515659bf7 100644
--- a/src/libnative/io/file_win32.rs
+++ b/src/libnative/io/file_win32.rs
@@ -324,7 +324,7 @@ pub fn mkdir(p: &CString, _mode: io::FilePermission) -> IoResult<()> {
 }
 
 pub fn readdir(p: &CString) -> IoResult<Vec<Path>> {
-    use rt::global_heap::malloc_raw;
+    use std::rt::global_heap::malloc_raw;
 
     fn prune(root: &CString, dirs: Vec<Path>) -> Vec<Path> {
         let root = unsafe { CString::new(root.with_ref(|p| p), false) };