Skip to content

Commit 1536d72

Browse files
committed
Don't suggest importing items with hygienic names
This will potentially hide a few correct suggestions, but importing these items from another module is not generally possible.
1 parent 4ecb49e commit 1536d72

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

compiler/rustc_resolve/src/diagnostics.rs

+2
Original file line numberDiff line numberDiff line change
@@ -831,9 +831,11 @@ impl<'a> Resolver<'a> {
831831

832832
// collect results based on the filter function
833833
// avoid suggesting anything from the same module in which we are resolving
834+
// avoid suggesting anything with a hygienic name
834835
if ident.name == lookup_ident.name
835836
&& ns == namespace
836837
&& !ptr::eq(in_module, parent_scope.module)
838+
&& !ident.span.normalize_to_macros_2_0().from_expansion()
837839
{
838840
let res = name_binding.res();
839841
if filter_fn(res) {

compiler/rustc_span/src/hygiene.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ impl SyntaxContext {
709709
/// pub fn f() {} // `f`'s `SyntaxContext` has a single `ExpnId` from `m`.
710710
/// pub fn $i() {} // `$i`'s `SyntaxContext` is empty.
711711
/// }
712-
/// n(f);
712+
/// n!(f);
713713
/// macro n($j:ident) {
714714
/// use foo::*;
715715
/// f(); // `f`'s `SyntaxContext` has a mark from `m` and a mark from `n`

0 commit comments

Comments
 (0)