Skip to content

Commit 657cb3f

Browse files
authored
Rollup merge of rust-lang#59047 - petrochenkov:modnodefid, r=Centril
resolve: Account for new importable entities Fixes the ICE encountered in rust-lang#58837 r? @Centril
2 parents aa3ada8 + 47ee538 commit 657cb3f

File tree

4 files changed

+49
-11
lines changed

4 files changed

+49
-11
lines changed

src/librustc_resolve/build_reduced_graph.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -636,24 +636,24 @@ impl<'a> Resolver<'a> {
636636
// but metadata cannot encode gensyms currently, so we create it here.
637637
// This is only a guess, two equivalent idents may incorrectly get different gensyms here.
638638
let ident = ident.gensym_if_underscore();
639-
let def_id = def.def_id();
640639
let expansion = Mark::root(); // FIXME(jseyfried) intercrate hygiene
641640
match def {
642-
Def::Mod(..) | Def::Enum(..) => {
641+
Def::Mod(def_id) | Def::Enum(def_id) => {
643642
let module = self.new_module(parent,
644643
ModuleKind::Def(def, ident.name),
645644
def_id,
646645
expansion,
647646
span);
648647
self.define(parent, ident, TypeNS, (module, vis, DUMMY_SP, expansion));
649648
}
650-
Def::Variant(..) | Def::TyAlias(..) | Def::ForeignTy(..) => {
649+
Def::Variant(..) | Def::TyAlias(..) | Def::ForeignTy(..) | Def::Existential(..) |
650+
Def::TraitAlias(..) | Def::PrimTy(..) | Def::ToolMod => {
651651
self.define(parent, ident, TypeNS, (def, vis, DUMMY_SP, expansion));
652652
}
653653
Def::Fn(..) | Def::Static(..) | Def::Const(..) | Def::VariantCtor(..) => {
654654
self.define(parent, ident, ValueNS, (def, vis, DUMMY_SP, expansion));
655655
}
656-
Def::StructCtor(..) => {
656+
Def::StructCtor(def_id, ..) => {
657657
self.define(parent, ident, ValueNS, (def, vis, DUMMY_SP, expansion));
658658

659659
if let Some(struct_def_id) =
@@ -662,7 +662,7 @@ impl<'a> Resolver<'a> {
662662
self.struct_constructors.insert(struct_def_id, (def, vis));
663663
}
664664
}
665-
Def::Trait(..) => {
665+
Def::Trait(def_id) => {
666666
let module_kind = ModuleKind::Def(def, ident.name);
667667
let module = self.new_module(parent,
668668
module_kind,
@@ -683,18 +683,14 @@ impl<'a> Resolver<'a> {
683683
}
684684
module.populated.set(true);
685685
}
686-
Def::Existential(..) |
687-
Def::TraitAlias(..) => {
688-
self.define(parent, ident, TypeNS, (def, vis, DUMMY_SP, expansion));
689-
}
690-
Def::Struct(..) | Def::Union(..) => {
686+
Def::Struct(def_id) | Def::Union(def_id) => {
691687
self.define(parent, ident, TypeNS, (def, vis, DUMMY_SP, expansion));
692688

693689
// Record field names for error reporting.
694690
let field_names = self.cstore.struct_field_names_untracked(def_id);
695691
self.insert_field_names(def_id, field_names);
696692
}
697-
Def::Macro(..) => {
693+
Def::Macro(..) | Def::NonMacroAttr(..) => {
698694
self.define(parent, ident, MacroNS, (def, vis, DUMMY_SP, expansion));
699695
}
700696
_ => bug!("unexpected definition: {:?}", def)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// edition:2018
2+
3+
pub use ignore as built_in_attr;
4+
pub use u8 as built_in_type;
5+
pub use rustfmt as tool_mod;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// edition:2018
2+
// aux-build:cross-crate.rs
3+
4+
extern crate cross_crate;
5+
use cross_crate::*;
6+
7+
#[built_in_attr] //~ ERROR cannot use a built-in attribute through an import
8+
#[tool_mod::skip] //~ ERROR cannot use a tool module through an import
9+
fn main() {
10+
let _: built_in_type; // OK
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error: cannot use a built-in attribute through an import
2+
--> $DIR/cross-crate.rs:7:3
3+
|
4+
LL | #[built_in_attr]
5+
| ^^^^^^^^^^^^^
6+
|
7+
note: the built-in attribute imported here
8+
--> $DIR/cross-crate.rs:5:5
9+
|
10+
LL | use cross_crate::*;
11+
| ^^^^^^^^^^^^^^
12+
13+
error: cannot use a tool module through an import
14+
--> $DIR/cross-crate.rs:8:3
15+
|
16+
LL | #[tool_mod::skip]
17+
| ^^^^^^^^
18+
|
19+
note: the tool module imported here
20+
--> $DIR/cross-crate.rs:5:5
21+
|
22+
LL | use cross_crate::*;
23+
| ^^^^^^^^^^^^^^
24+
25+
error: aborting due to 2 previous errors
26+

0 commit comments

Comments
 (0)