diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2018-05-19 20:31:06 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2018-05-20 02:20:05 +0300 |
| commit | 5fd7d2fc76c28e901ac72b5fe2e3b640f0c165c4 (patch) | |
| tree | 3c6f324e99dbaccb42c2e1ce81ea4a394ce5d994 | |
| parent | a3085756edf66459109c4b07948b08fe3e78bc3b (diff) | |
| download | rust-5fd7d2fc76c28e901ac72b5fe2e3b640f0c165c4.tar.gz rust-5fd7d2fc76c28e901ac72b5fe2e3b640f0c165c4.zip | |
resolve: Don't add unnecessary import candidates for `prefix::{self}` imports
| -rw-r--r-- | src/librustc_resolve/resolve_imports.rs | 4 | ||||
| -rw-r--r-- | src/test/run-pass/auxiliary/use-macro-self.rs | 16 | ||||
| -rw-r--r-- | src/test/run-pass/use-macro-self.rs | 22 |
3 files changed, 40 insertions, 2 deletions
diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index cf1fc7675fe..cb8e63038ff 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -312,8 +312,8 @@ impl<'a> Resolver<'a> { self.indeterminate_imports.push(directive); match directive.subclass { - SingleImport { target, .. } => { - self.per_ns(|this, ns| { + SingleImport { target, type_ns_only, .. } => { + self.per_ns(|this, ns| if !type_ns_only || ns == TypeNS { let mut resolution = this.resolution(current_module, target, ns).borrow_mut(); resolution.single_imports.add_directive(directive, this.use_extern_macros); }); diff --git a/src/test/run-pass/auxiliary/use-macro-self.rs b/src/test/run-pass/auxiliary/use-macro-self.rs new file mode 100644 index 00000000000..cdc519a5fdb --- /dev/null +++ b/src/test/run-pass/auxiliary/use-macro-self.rs @@ -0,0 +1,16 @@ +// 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. + +pub mod foobarius {} + +#[macro_export] +macro_rules! foobarius { + () => { () } +} diff --git a/src/test/run-pass/use-macro-self.rs b/src/test/run-pass/use-macro-self.rs new file mode 100644 index 00000000000..9162ad32681 --- /dev/null +++ b/src/test/run-pass/use-macro-self.rs @@ -0,0 +1,22 @@ +// 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. + +// aux-build:use-macro-self.rs + +#![feature(use_extern_macros)] + +#[macro_use] +extern crate use_macro_self; + +use use_macro_self::foobarius::{self}; + +fn main() { + let _: () = foobarius!(); // OK, the macro returns `()` +} |
