-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove last uses of gensyms #64623
Remove last uses of gensyms #64623
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,7 +93,8 @@ impl<'a> Resolver<'a> { | |
where T: ToNameBinding<'a>, | ||
{ | ||
let binding = def.to_name_binding(self.arenas); | ||
if let Err(old_binding) = self.try_define(parent, ident, ns, binding) { | ||
let key = self.new_key(ident, ns); | ||
if let Err(old_binding) = self.try_define(parent, key, binding) { | ||
self.report_conflict(parent, ident, ns, old_binding, &binding); | ||
} | ||
} | ||
|
@@ -349,9 +350,12 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { | |
|
||
self.r.indeterminate_imports.push(directive); | ||
match directive.subclass { | ||
// Don't add unresolved underscore imports to modules | ||
SingleImport { target: Ident { name: kw::Underscore, .. }, .. } => {} | ||
SingleImport { target, type_ns_only, .. } => { | ||
self.r.per_ns(|this, ns| if !type_ns_only || ns == TypeNS { | ||
let mut resolution = this.resolution(current_module, target, ns).borrow_mut(); | ||
let key = this.new_key(target, ns); | ||
let mut resolution = this.resolution(current_module, key).borrow_mut(); | ||
resolution.add_single_import(directive); | ||
}); | ||
} | ||
|
@@ -407,7 +411,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { | |
}; | ||
match use_tree.kind { | ||
ast::UseTreeKind::Simple(rename, ..) => { | ||
let mut ident = use_tree.ident().gensym_if_underscore(); | ||
let mut ident = use_tree.ident(); | ||
let mut module_path = prefix; | ||
let mut source = module_path.pop().unwrap(); | ||
let mut type_ns_only = false; | ||
|
@@ -585,7 +589,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { | |
let parent_scope = &self.parent_scope; | ||
let parent = parent_scope.module; | ||
let expansion = parent_scope.expansion; | ||
let ident = item.ident.gensym_if_underscore(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I'd expect every Thus we'll reuse the same common mechanism, and when hygiene data becomes encodable we'll be able to properly encode There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Glob imports operate on the actual hygiene data: https://github.com/rust-lang/rust/blob/da01d31ff97feb199036359c364aedc809711123/src/librustc_resolve/resolve_imports.rs#L563 I'll see if there's a way to do this without increasing the complexity of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, right, the difference is that This difference is orthogonal to globs, so perhaps it's collection of traits in scope that needs to be adjusted, not (It's somewhat unfortunate that the difference exists and the features cannot be fully unified, but in both cases the behavior looks entirely reasonable and appropriate.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm specifically concerned about preserving the behavior of the following: mod x {
use Trait as _;
}
use x::*;
fn f() {
().method_on_trait();
// ^This resolves if the whole snippet comes from a single macro expansion
// It generally doesn't resolve otherwise
} I think I have a working solution for this, which I'll push once I'm happy. |
||
let ident = item.ident; | ||
let sp = item.span; | ||
let vis = self.resolve_visibility(&item.vis); | ||
|
||
|
@@ -850,10 +854,6 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { | |
fn build_reduced_graph_for_external_crate_res(&mut self, child: Export<NodeId>) { | ||
let parent = self.parent_scope.module; | ||
let Export { ident, res, vis, span } = child; | ||
// FIXME: We shouldn't create the gensym here, it should come from metadata, | ||
// but metadata cannot encode gensyms currently, so we create it here. | ||
// This is only a guess, two equivalent idents may incorrectly get different gensyms here. | ||
let ident = ident.gensym_if_underscore(); | ||
let expansion = ExpnId::root(); // FIXME(jseyfried) intercrate hygiene | ||
// Record primary definitions. | ||
match res { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if this special case is removed? Some diagnostics regress?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, we just won't be able to remove it in
resolve_imports.rs:831
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see, the disambiguator is not available in that context.