Do not encode gensymed imports in metadata
This commit is contained in:
parent
7a4df3b53d
commit
30d5dc9a0a
@ -303,7 +303,7 @@ fn build_reduced_graph_for_use_tree(
|
||||
}
|
||||
|
||||
// Empty groups `a::b::{}` are turned into synthetic `self` imports
|
||||
// `a::b::c::{self as _}`, so that their prefixes are correctly
|
||||
// `a::b::c::{self as __dummy}`, so that their prefixes are correctly
|
||||
// resolved and checked for privacy/stability/etc.
|
||||
if items.is_empty() && !empty_for_self(&prefix) {
|
||||
let new_span = prefix[prefix.len() - 1].ident.span;
|
||||
@ -312,7 +312,7 @@ fn build_reduced_graph_for_use_tree(
|
||||
Ident::new(keywords::SelfLower.name(), new_span)
|
||||
),
|
||||
kind: ast::UseTreeKind::Simple(
|
||||
Some(Ident::new(keywords::Underscore.name().gensymed(), new_span)),
|
||||
Some(Ident::new(Name::gensym("__dummy"), new_span)),
|
||||
ast::DUMMY_NODE_ID,
|
||||
ast::DUMMY_NODE_ID,
|
||||
),
|
||||
|
@ -1295,9 +1295,11 @@ fn finalize_resolutions_in(&mut self, module: Module<'b>) {
|
||||
None => continue,
|
||||
};
|
||||
|
||||
// Filter away "empty import canaries" and ambiguous imports.
|
||||
// Filter away ambiguous and gensymed imports. Gensymed imports
|
||||
// (e.g. implicitly injected `std`) cannot be properly encoded in metadata,
|
||||
// so they can cause name conflict errors downstream.
|
||||
let is_good_import = binding.is_import() && !binding.is_ambiguity() &&
|
||||
binding.vis != ty::Visibility::Invisible;
|
||||
!(ident.name.is_gensymed() && ident.name != "_");
|
||||
if is_good_import || binding.is_macro_def() {
|
||||
let def = binding.def();
|
||||
if def != Def::Err {
|
||||
|
@ -179,6 +179,10 @@ pub fn gensymed(self) -> Self {
|
||||
with_interner(|interner| interner.gensymed(self))
|
||||
}
|
||||
|
||||
pub fn is_gensymed(self) -> bool {
|
||||
with_interner(|interner| interner.is_gensymed(self))
|
||||
}
|
||||
|
||||
pub fn as_str(self) -> LocalInternedString {
|
||||
with_interner(|interner| unsafe {
|
||||
LocalInternedString {
|
||||
|
3
src/test/ui/imports/auxiliary/gensymed.rs
Normal file
3
src/test/ui/imports/auxiliary/gensymed.rs
Normal file
@ -0,0 +1,3 @@
|
||||
// edition:2018
|
||||
|
||||
mod std {}
|
7
src/test/ui/imports/gensymed.rs
Normal file
7
src/test/ui/imports/gensymed.rs
Normal file
@ -0,0 +1,7 @@
|
||||
// compile-pass
|
||||
// edition:2018
|
||||
// aux-build:gensymed.rs
|
||||
|
||||
extern crate gensymed;
|
||||
|
||||
fn main() {}
|
Loading…
Reference in New Issue
Block a user