resolve: Do not skip extern prelude during speculative resolution

This commit is contained in:
Vadim Petrochenkov 2018-10-15 23:43:59 +03:00
parent 37ba1071c6
commit 350f9a2be5
5 changed files with 30 additions and 4 deletions

View File

@ -1980,9 +1980,15 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
}
if !module.no_implicit_prelude {
// `record_used` means that we don't try to load crates during speculative resolution
if record_used && ns == TypeNS && self.extern_prelude.contains(&ident.name) {
let crate_id = self.crate_loader.process_path_extern(ident.name, ident.span);
if ns == TypeNS && self.extern_prelude.contains(&ident.name) {
let crate_id = if record_used {
self.crate_loader.process_path_extern(ident.name, ident.span)
} else if let Some(crate_id) =
self.crate_loader.maybe_process_path_extern(ident.name, ident.span) {
crate_id
} else {
return None;
};
let crate_root = self.get_module(DefId { krate: crate_id, index: CRATE_DEF_INDEX });
self.populate_module_if_necessary(&crate_root);

View File

@ -10,7 +10,7 @@
// run-pass
#![allow(unused_variables)]
// compile-flags: --extern LooksLikeExternCrate=/path/to/nowhere
// compile-flags: --extern LooksLikeExternCrate
mod m {
pub struct LooksLikeExternCrate;

View File

@ -0,0 +1 @@
pub trait MyTrait {}

View File

@ -0,0 +1,10 @@
// aux-build:extra-item.rs
// compile-flags:--extern extra_item
struct S;
impl extra_item::MyTrait for S {
fn extra() {} //~ ERROR method `extra` is not a member of trait `extra_item::MyTrait`
}
fn main() {}

View File

@ -0,0 +1,9 @@
error[E0407]: method `extra` is not a member of trait `extra_item::MyTrait`
--> $DIR/extra-item.rs:7:5
|
LL | fn extra() {} //~ ERROR method `extra` is not a member of trait `extra_item::MyTrait`
| ^^^^^^^^^^^^^ not a member of trait `extra_item::MyTrait`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0407`.