Auto merge of #80782 - petrochenkov:viscopes, r=matthewjasper

resolve: Scope visiting doesn't need an `Ident`

Resolution scope visitor (`fn visit_scopes`) currently takes an `Ident` parameter, but it doesn't need a full identifier, or even its span, it only needs the `SyntaxContext` part.
The `SyntaxContext` part is necessary because scope visitor has to jump to macro definition sites, so it has to be directed by macro expansion information somehow.

I think it's clearer to pass only the necessary part.
Yes, usually visiting happens as a part of an identifier resolution, but in cases like collecting traits in scope (#80765) or collecting typo suggestions that's not the case.

r? `@matthewjasper`
This commit is contained in:
bors 2021-01-10 23:36:33 +00:00
commit 26d451f4b3
6 changed files with 90 additions and 57 deletions

View file

@ -618,8 +618,9 @@ impl<'a> Resolver<'a> {
let break_result = self.visit_scopes(
scope_set,
parent_scope,
orig_ident,
|this, scope, use_prelude, ident| {
orig_ident.span.ctxt(),
|this, scope, use_prelude, ctxt| {
let ident = Ident::new(orig_ident.name, orig_ident.span.with_ctxt(ctxt));
let ok = |res, span, arenas| {
Ok((
(res, ty::Visibility::Public, span, ExpnId::root()).to_name_binding(arenas),