Skip to content

Commit b438449

Browse files
committed
Auto merge of #50908 - petrochenkov:usemacself, r=alexcrichton
resolve: Don't add unnecessary import candidates for `prefix::{self}` imports Fixes #50725
2 parents 22c25dd + 5fd7d2f commit b438449

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

src/librustc_resolve/resolve_imports.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,8 @@ impl<'a> Resolver<'a> {
312312

313313
self.indeterminate_imports.push(directive);
314314
match directive.subclass {
315-
SingleImport { target, .. } => {
316-
self.per_ns(|this, ns| {
315+
SingleImport { target, type_ns_only, .. } => {
316+
self.per_ns(|this, ns| if !type_ns_only || ns == TypeNS {
317317
let mut resolution = this.resolution(current_module, target, ns).borrow_mut();
318318
resolution.single_imports.add_directive(directive, this.use_extern_macros);
319319
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub mod foobarius {}
12+
13+
#[macro_export]
14+
macro_rules! foobarius {
15+
() => { () }
16+
}

src/test/run-pass/use-macro-self.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// aux-build:use-macro-self.rs
12+
13+
#![feature(use_extern_macros)]
14+
15+
#[macro_use]
16+
extern crate use_macro_self;
17+
18+
use use_macro_self::foobarius::{self};
19+
20+
fn main() {
21+
let _: () = foobarius!(); // OK, the macro returns `()`
22+
}

0 commit comments

Comments
 (0)