about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
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/rustllvm/RustWrapper.cpp
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/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions