Skip to content

Commit f649c76

Browse files
committedMar 17, 2019
Auto merge of #59047 - petrochenkov:modnodefid, r=Centril
resolve: Account for new importable entities Fixes the ICE encountered in #58837 r? @Centril
2 parents 070cebd + 47ee538 commit f649c76

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
@@ -635,24 +635,24 @@ impl<'a> Resolver<'a> {
635635
// but metadata cannot encode gensyms currently, so we create it here.
636636
// This is only a guess, two equivalent idents may incorrectly get different gensyms here.
637637
let ident = ident.gensym_if_underscore();
638-
let def_id = def.def_id();
639638
let expansion = Mark::root(); // FIXME(jseyfried) intercrate hygiene
640639
match def {
641-
Def::Mod(..) | Def::Enum(..) => {
640+
Def::Mod(def_id) | Def::Enum(def_id) => {
642641
let module = self.new_module(parent,
643642
ModuleKind::Def(def, ident.name),
644643
def_id,
645644
expansion,
646645
span);
647646
self.define(parent, ident, TypeNS, (module, vis, DUMMY_SP, expansion));
648647
}
649-
Def::Variant(..) | Def::TyAlias(..) | Def::ForeignTy(..) => {
648+
Def::Variant(..) | Def::TyAlias(..) | Def::ForeignTy(..) | Def::Existential(..) |
649+
Def::TraitAlias(..) | Def::PrimTy(..) | Def::ToolMod => {
650650
self.define(parent, ident, TypeNS, (def, vis, DUMMY_SP, expansion));
651651
}
652652
Def::Fn(..) | Def::Static(..) | Def::Const(..) | Def::VariantCtor(..) => {
653653
self.define(parent, ident, ValueNS, (def, vis, DUMMY_SP, expansion));
654654
}
655-
Def::StructCtor(..) => {
655+
Def::StructCtor(def_id, ..) => {
656656
self.define(parent, ident, ValueNS, (def, vis, DUMMY_SP, expansion));
657657

658658
if let Some(struct_def_id) =
@@ -661,7 +661,7 @@ impl<'a> Resolver<'a> {
661661
self.struct_constructors.insert(struct_def_id, (def, vis));
662662
}
663663
}
664-
Def::Trait(..) => {
664+
Def::Trait(def_id) => {
665665
let module_kind = ModuleKind::Def(def, ident.name);
666666
let module = self.new_module(parent,
667667
module_kind,
@@ -682,18 +682,14 @@ impl<'a> Resolver<'a> {
682682
}
683683
module.populated.set(true);
684684
}
685-
Def::Existential(..) |
686-
Def::TraitAlias(..) => {
687-
self.define(parent, ident, TypeNS, (def, vis, DUMMY_SP, expansion));
688-
}
689-
Def::Struct(..) | Def::Union(..) => {
685+
Def::Struct(def_id) | Def::Union(def_id) => {
690686
self.define(parent, ident, TypeNS, (def, vis, DUMMY_SP, expansion));
691687

692688
// Record field names for error reporting.
693689
let field_names = self.cstore.struct_field_names_untracked(def_id);
694690
self.insert_field_names(def_id, field_names);
695691
}
696-
Def::Macro(..) => {
692+
Def::Macro(..) | Def::NonMacroAttr(..) => {
697693
self.define(parent, ident, MacroNS, (def, vis, DUMMY_SP, expansion));
698694
}
699695
_ => 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)
Please sign in to comment.