]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #90202 - matthewjasper:xcrate-hygiene, r=petrochenkov
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Sat, 30 Oct 2021 18:30:27 +0000 (20:30 +0200)
committerGitHub <noreply@github.com>
Sat, 30 Oct 2021 18:30:27 +0000 (20:30 +0200)
Improve and test cross-crate hygiene

- Decode the parent expansion for traits and enums in `rustc_resolve`, this was already being used for resolution in typeck
- Avoid suggesting importing names with def-site hygiene, since it's often not useful
- Add more tests

r? `@petrochenkov`

1  2 
compiler/rustc_resolve/src/diagnostics.rs

index ccfab263bd48ea4c56d8cec004c74ba1d64ba2cb,aefb3f2cb9c8399d25be44f42d7f20a58249bca0..163acebcceacffe792a1238f13a014e71a6858c5
@@@ -831,17 -829,9 +831,18 @@@ impl<'a> Resolver<'a> 
                      return;
                  }
  
 +                // #90113: Do not count an inaccessible reexported item as a candidate.
 +                if let NameBindingKind::Import { binding, .. } = name_binding.kind {
 +                    if this.is_accessible_from(binding.vis, parent_scope.module)
 +                        && !this.is_accessible_from(name_binding.vis, parent_scope.module)
 +                    {
 +                        return;
 +                    }
 +                }
 +
                  // collect results based on the filter function
                  // avoid suggesting anything from the same module in which we are resolving
+                 // avoid suggesting anything with a hygienic name
                  if ident.name == lookup_ident.name
                      && ns == namespace
                      && !ptr::eq(in_module, parent_scope.module)