diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2018-08-14 11:26:44 +0300 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2018-08-14 11:26:44 +0300 |
| commit | 262392cd320320029afc3a2d9edad7cd16a32035 (patch) | |
| tree | 9732840c910c947403120ac3c80b667094774c13 | |
| parent | 3e05f80a3790bb96247e9325fe54e484086f77f5 (diff) | |
| download | rust-262392cd320320029afc3a2d9edad7cd16a32035.tar.gz rust-262392cd320320029afc3a2d9edad7cd16a32035.zip | |
rustc_resolve: crates only exist in the type namespace.
| -rw-r--r-- | src/librustc_resolve/resolve_imports.rs | 5 | ||||
| -rw-r--r-- | src/test/run-pass/issue-53333.rs | 17 |
2 files changed, 20 insertions, 2 deletions
diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 1d8cc609f95..35e58bc9fee 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -194,13 +194,14 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> { } // Fall back to resolving to an external crate. - if !self.extern_prelude.contains(&ident.name) { + if !(ns == TypeNS && self.extern_prelude.contains(&ident.name)) { // ... unless the crate name is not in the `extern_prelude`. return binding; } } let crate_root = if + ns == TypeNS && root != keywords::Extern.name() && ( ident.name == keywords::Crate.name() || @@ -208,7 +209,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> { ) { self.resolve_crate_root(ident) - } else if !ident.is_path_segment_keyword() { + } else if ns == TypeNS && !ident.is_path_segment_keyword() { let crate_id = self.crate_loader.process_path_extern(ident.name, ident.span); self.get_module(DefId { krate: crate_id, index: CRATE_DEF_INDEX }) diff --git a/src/test/run-pass/issue-53333.rs b/src/test/run-pass/issue-53333.rs new file mode 100644 index 00000000000..51b90af7164 --- /dev/null +++ b/src/test/run-pass/issue-53333.rs @@ -0,0 +1,17 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// edition:2018 + +fn main() { + use std; + let std = "std"; + println!("{}", std); +} |
