Skip to content

Commit 6f9f903

Browse files
authored
Rollup merge of #34871 - petrochenkov:inherent, r=jseyfried
Do not resolve inherent static methods from other crates prematurely Under some specific circumstances paths like `Type::method` can be resolved early in rustc_resolve instead of type checker. `Type` must be defined in another crate, it should be an enum or a trait object (i.e. a type that acts as a "module" in resolve), and `method` should be an inherent static method. As a result, such paths don't go through `resolve_ufcs`, may be resolved incorrectly and break some invariants in type checker. This patch removes special treatment of such methods. The removed code was introduced in 2bd46e7 to fix a problem that no longer exists. r? @jseyfried
2 parents 001d280 + f66da5e commit 6f9f903

File tree

2 files changed

+1
-27
lines changed

2 files changed

+1
-27
lines changed

src/librustc_metadata/decoder.rs

-26
Original file line numberDiff line numberDiff line change
@@ -687,32 +687,6 @@ fn each_child_of_item_or_crate<F, G>(cdata: Cmd,
687687
}
688688
}
689689

690-
// As a special case, iterate over all static methods of
691-
// associated implementations too. This is a bit of a botch.
692-
// --pcwalton
693-
for inherent_impl_def_id_doc in reader::tagged_docs(item_doc,
694-
tag_items_data_item_inherent_impl) {
695-
let inherent_impl_def_id = item_def_id(inherent_impl_def_id_doc, cdata);
696-
if let Some(inherent_impl_doc) = cdata.get_item(inherent_impl_def_id.index) {
697-
for impl_item_def_id_doc in reader::tagged_docs(inherent_impl_doc,
698-
tag_item_impl_item) {
699-
let impl_item_def_id = item_def_id(impl_item_def_id_doc,
700-
cdata);
701-
if let Some(impl_method_doc) = cdata.get_item(impl_item_def_id.index) {
702-
if let StaticMethod = item_family(impl_method_doc) {
703-
// Hand off the static method to the callback.
704-
let static_method_name = item_name(impl_method_doc);
705-
let static_method_def_like = item_to_def_like(cdata, impl_method_doc,
706-
impl_item_def_id);
707-
callback(static_method_def_like,
708-
static_method_name,
709-
item_visibility(impl_method_doc));
710-
}
711-
}
712-
}
713-
}
714-
}
715-
716690
for reexport_doc in reexports(item_doc) {
717691
let def_id_doc = reader::get_doc(reexport_doc,
718692
tag_items_data_item_reexport_def_id);

src/test/compile-fail/use-from-trait-xc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ use use_from_trait_xc::Bar::new as bnew;
3131
//~^ ERROR unresolved import `use_from_trait_xc::Bar::new`
3232

3333
use use_from_trait_xc::Baz::new as baznew;
34-
//~^ ERROR `baznew` is not directly importable
34+
//~^ ERROR unresolved import `use_from_trait_xc::Baz::new`
3535

3636
fn main() {}

0 commit comments

Comments
 (0)