metadata: Remove locator::Context::ident
It's a crate name after renaming, so it's entirely irrelevant to crate loading
This commit is contained in:
parent
acd102aebf
commit
33c9ada800
4 changed files with 24 additions and 29 deletions
|
@ -337,7 +337,6 @@ impl<'a> CrateLoader<'a> {
|
||||||
fn resolve_crate<'b>(
|
fn resolve_crate<'b>(
|
||||||
&'b mut self,
|
&'b mut self,
|
||||||
root: &'b Option<CratePaths>,
|
root: &'b Option<CratePaths>,
|
||||||
ident: Symbol,
|
|
||||||
name: Symbol,
|
name: Symbol,
|
||||||
hash: Option<&'b Svh>,
|
hash: Option<&'b Svh>,
|
||||||
extra_filename: Option<&'b str>,
|
extra_filename: Option<&'b str>,
|
||||||
|
@ -345,7 +344,7 @@ impl<'a> CrateLoader<'a> {
|
||||||
path_kind: PathKind,
|
path_kind: PathKind,
|
||||||
mut dep_kind: DepKind,
|
mut dep_kind: DepKind,
|
||||||
) -> Result<(CrateNum, Lrc<cstore::CrateMetadata>), LoadError<'b>> {
|
) -> Result<(CrateNum, Lrc<cstore::CrateMetadata>), LoadError<'b>> {
|
||||||
info!("resolving crate `extern crate {} as {}`", name, ident);
|
info!("resolving crate `{}`", name);
|
||||||
let result = if let Some(cnum) = self.existing_match(name, hash, path_kind) {
|
let result = if let Some(cnum) = self.existing_match(name, hash, path_kind) {
|
||||||
(LoadResult::Previous(cnum), None)
|
(LoadResult::Previous(cnum), None)
|
||||||
} else {
|
} else {
|
||||||
|
@ -353,7 +352,6 @@ impl<'a> CrateLoader<'a> {
|
||||||
let mut locate_ctxt = locator::Context {
|
let mut locate_ctxt = locator::Context {
|
||||||
sess: self.sess,
|
sess: self.sess,
|
||||||
span,
|
span,
|
||||||
ident,
|
|
||||||
crate_name: name,
|
crate_name: name,
|
||||||
hash,
|
hash,
|
||||||
extra_filename,
|
extra_filename,
|
||||||
|
@ -493,16 +491,15 @@ impl<'a> CrateLoader<'a> {
|
||||||
_ => dep.kind,
|
_ => dep.kind,
|
||||||
};
|
};
|
||||||
let (local_cnum, ..) = self.resolve_crate(
|
let (local_cnum, ..) = self.resolve_crate(
|
||||||
root, dep.name, dep.name, Some(&dep.hash), Some(&dep.extra_filename), span,
|
root, dep.name, Some(&dep.hash), Some(&dep.extra_filename), span,
|
||||||
PathKind::Dependency, dep_kind,
|
PathKind::Dependency, dep_kind,
|
||||||
).unwrap_or_else(|err| err.report());
|
).unwrap_or_else(|err| err.report());
|
||||||
local_cnum
|
local_cnum
|
||||||
})).collect()
|
})).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_extension_crate(&mut self, span: Span, orig_name: Symbol, rename: Symbol)
|
fn read_extension_crate(&mut self, name: Symbol, span: Span) -> ExtensionCrate {
|
||||||
-> ExtensionCrate {
|
info!("read extension crate `{}`", name);
|
||||||
info!("read extension crate `extern crate {} as {}`", orig_name, rename);
|
|
||||||
let target_triple = self.sess.opts.target_triple.clone();
|
let target_triple = self.sess.opts.target_triple.clone();
|
||||||
let host_triple = TargetTriple::from_triple(config::host_triple());
|
let host_triple = TargetTriple::from_triple(config::host_triple());
|
||||||
let is_cross = target_triple != host_triple;
|
let is_cross = target_triple != host_triple;
|
||||||
|
@ -510,8 +507,7 @@ impl<'a> CrateLoader<'a> {
|
||||||
let mut locate_ctxt = locator::Context {
|
let mut locate_ctxt = locator::Context {
|
||||||
sess: self.sess,
|
sess: self.sess,
|
||||||
span,
|
span,
|
||||||
ident: orig_name,
|
crate_name: name,
|
||||||
crate_name: rename,
|
|
||||||
hash: None,
|
hash: None,
|
||||||
extra_filename: None,
|
extra_filename: None,
|
||||||
filesearch: self.sess.host_filesearch(PathKind::Crate),
|
filesearch: self.sess.host_filesearch(PathKind::Crate),
|
||||||
|
@ -606,7 +602,7 @@ impl<'a> CrateLoader<'a> {
|
||||||
span: Span,
|
span: Span,
|
||||||
name: Symbol)
|
name: Symbol)
|
||||||
-> Option<(PathBuf, CrateDisambiguator)> {
|
-> Option<(PathBuf, CrateDisambiguator)> {
|
||||||
let ekrate = self.read_extension_crate(span, name, name);
|
let ekrate = self.read_extension_crate(name, span);
|
||||||
|
|
||||||
if ekrate.target_only {
|
if ekrate.target_only {
|
||||||
// Need to abort before syntax expansion.
|
// Need to abort before syntax expansion.
|
||||||
|
@ -699,7 +695,7 @@ impl<'a> CrateLoader<'a> {
|
||||||
|
|
||||||
let dep_kind = DepKind::Implicit;
|
let dep_kind = DepKind::Implicit;
|
||||||
let (cnum, data) =
|
let (cnum, data) =
|
||||||
self.resolve_crate(&None, name, name, None, None, DUMMY_SP, PathKind::Crate, dep_kind)
|
self.resolve_crate(&None, name, None, None, DUMMY_SP, PathKind::Crate, dep_kind)
|
||||||
.unwrap_or_else(|err| err.report());
|
.unwrap_or_else(|err| err.report());
|
||||||
|
|
||||||
// Sanity check the loaded crate to ensure it is indeed a panic runtime
|
// Sanity check the loaded crate to ensure it is indeed a panic runtime
|
||||||
|
@ -807,7 +803,7 @@ impl<'a> CrateLoader<'a> {
|
||||||
let symbol = Symbol::intern(name);
|
let symbol = Symbol::intern(name);
|
||||||
let dep_kind = DepKind::Explicit;
|
let dep_kind = DepKind::Explicit;
|
||||||
let (_, data) =
|
let (_, data) =
|
||||||
self.resolve_crate(&None, symbol, symbol, None, None, DUMMY_SP,
|
self.resolve_crate(&None, symbol, None, None, DUMMY_SP,
|
||||||
PathKind::Crate, dep_kind)
|
PathKind::Crate, dep_kind)
|
||||||
.unwrap_or_else(|err| err.report());
|
.unwrap_or_else(|err| err.report());
|
||||||
|
|
||||||
|
@ -831,7 +827,7 @@ impl<'a> CrateLoader<'a> {
|
||||||
let symbol = Symbol::intern("profiler_builtins");
|
let symbol = Symbol::intern("profiler_builtins");
|
||||||
let dep_kind = DepKind::Implicit;
|
let dep_kind = DepKind::Implicit;
|
||||||
let (_, data) =
|
let (_, data) =
|
||||||
self.resolve_crate(&None, symbol, symbol, None, None, DUMMY_SP,
|
self.resolve_crate(&None, symbol, None, None, DUMMY_SP,
|
||||||
PathKind::Crate, dep_kind)
|
PathKind::Crate, dep_kind)
|
||||||
.unwrap_or_else(|err| err.report());
|
.unwrap_or_else(|err| err.report());
|
||||||
|
|
||||||
|
@ -1015,7 +1011,7 @@ impl<'a> CrateLoader<'a> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let (cnum, ..) = self.resolve_crate(
|
let (cnum, ..) = self.resolve_crate(
|
||||||
&None, item.ident.name, orig_name, None, None,
|
&None, orig_name, None, None,
|
||||||
item.span, PathKind::Crate, dep_kind,
|
item.span, PathKind::Crate, dep_kind,
|
||||||
).unwrap_or_else(|err| err.report());
|
).unwrap_or_else(|err| err.report());
|
||||||
|
|
||||||
|
@ -1044,7 +1040,7 @@ impl<'a> CrateLoader<'a> {
|
||||||
span: Span,
|
span: Span,
|
||||||
) -> CrateNum {
|
) -> CrateNum {
|
||||||
let cnum = self.resolve_crate(
|
let cnum = self.resolve_crate(
|
||||||
&None, name, name, None, None, span, PathKind::Crate, DepKind::Explicit
|
&None, name, None, None, span, PathKind::Crate, DepKind::Explicit
|
||||||
).unwrap_or_else(|err| err.report()).0;
|
).unwrap_or_else(|err| err.report()).0;
|
||||||
|
|
||||||
self.update_extern_crate(
|
self.update_extern_crate(
|
||||||
|
@ -1068,7 +1064,7 @@ impl<'a> CrateLoader<'a> {
|
||||||
span: Span,
|
span: Span,
|
||||||
) -> Option<CrateNum> {
|
) -> Option<CrateNum> {
|
||||||
let cnum = self.resolve_crate(
|
let cnum = self.resolve_crate(
|
||||||
&None, name, name, None, None, span, PathKind::Crate, DepKind::Explicit
|
&None, name, None, None, span, PathKind::Crate, DepKind::Explicit
|
||||||
).ok()?.0;
|
).ok()?.0;
|
||||||
|
|
||||||
self.update_extern_crate(
|
self.update_extern_crate(
|
||||||
|
|
|
@ -254,7 +254,6 @@ pub struct CrateMismatch {
|
||||||
pub struct Context<'a> {
|
pub struct Context<'a> {
|
||||||
pub sess: &'a Session,
|
pub sess: &'a Session,
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub ident: Symbol,
|
|
||||||
pub crate_name: Symbol,
|
pub crate_name: Symbol,
|
||||||
pub hash: Option<&'a Svh>,
|
pub hash: Option<&'a Svh>,
|
||||||
pub extra_filename: Option<&'a str>,
|
pub extra_filename: Option<&'a str>,
|
||||||
|
@ -332,12 +331,12 @@ impl<'a> Context<'a> {
|
||||||
self.span,
|
self.span,
|
||||||
E0460,
|
E0460,
|
||||||
"found possibly newer version of crate `{}`{}",
|
"found possibly newer version of crate `{}`{}",
|
||||||
self.ident,
|
self.crate_name,
|
||||||
add);
|
add);
|
||||||
err.note("perhaps that crate needs to be recompiled?");
|
err.note("perhaps that crate needs to be recompiled?");
|
||||||
let mismatches = self.rejected_via_hash.iter();
|
let mismatches = self.rejected_via_hash.iter();
|
||||||
for &CrateMismatch { ref path, .. } in mismatches {
|
for &CrateMismatch { ref path, .. } in mismatches {
|
||||||
msg.push_str(&format!("\ncrate `{}`: {}", self.ident, path.display()));
|
msg.push_str(&format!("\ncrate `{}`: {}", self.crate_name, path.display()));
|
||||||
}
|
}
|
||||||
match self.root {
|
match self.root {
|
||||||
&None => {}
|
&None => {}
|
||||||
|
@ -355,13 +354,13 @@ impl<'a> Context<'a> {
|
||||||
E0461,
|
E0461,
|
||||||
"couldn't find crate `{}` \
|
"couldn't find crate `{}` \
|
||||||
with expected target triple {}{}",
|
with expected target triple {}{}",
|
||||||
self.ident,
|
self.crate_name,
|
||||||
self.triple,
|
self.triple,
|
||||||
add);
|
add);
|
||||||
let mismatches = self.rejected_via_triple.iter();
|
let mismatches = self.rejected_via_triple.iter();
|
||||||
for &CrateMismatch { ref path, ref got } in mismatches {
|
for &CrateMismatch { ref path, ref got } in mismatches {
|
||||||
msg.push_str(&format!("\ncrate `{}`, target triple {}: {}",
|
msg.push_str(&format!("\ncrate `{}`, target triple {}: {}",
|
||||||
self.ident,
|
self.crate_name,
|
||||||
got,
|
got,
|
||||||
path.display()));
|
path.display()));
|
||||||
}
|
}
|
||||||
|
@ -372,12 +371,12 @@ impl<'a> Context<'a> {
|
||||||
self.span,
|
self.span,
|
||||||
E0462,
|
E0462,
|
||||||
"found staticlib `{}` instead of rlib or dylib{}",
|
"found staticlib `{}` instead of rlib or dylib{}",
|
||||||
self.ident,
|
self.crate_name,
|
||||||
add);
|
add);
|
||||||
err.help("please recompile that crate using --crate-type lib");
|
err.help("please recompile that crate using --crate-type lib");
|
||||||
let mismatches = self.rejected_via_kind.iter();
|
let mismatches = self.rejected_via_kind.iter();
|
||||||
for &CrateMismatch { ref path, .. } in mismatches {
|
for &CrateMismatch { ref path, .. } in mismatches {
|
||||||
msg.push_str(&format!("\ncrate `{}`: {}", self.ident, path.display()));
|
msg.push_str(&format!("\ncrate `{}`: {}", self.crate_name, path.display()));
|
||||||
}
|
}
|
||||||
err.note(&msg);
|
err.note(&msg);
|
||||||
err
|
err
|
||||||
|
@ -387,14 +386,14 @@ impl<'a> Context<'a> {
|
||||||
E0514,
|
E0514,
|
||||||
"found crate `{}` compiled by an incompatible version \
|
"found crate `{}` compiled by an incompatible version \
|
||||||
of rustc{}",
|
of rustc{}",
|
||||||
self.ident,
|
self.crate_name,
|
||||||
add);
|
add);
|
||||||
err.help(&format!("please recompile that crate using this compiler ({})",
|
err.help(&format!("please recompile that crate using this compiler ({})",
|
||||||
rustc_version()));
|
rustc_version()));
|
||||||
let mismatches = self.rejected_via_version.iter();
|
let mismatches = self.rejected_via_version.iter();
|
||||||
for &CrateMismatch { ref path, ref got } in mismatches {
|
for &CrateMismatch { ref path, ref got } in mismatches {
|
||||||
msg.push_str(&format!("\ncrate `{}` compiled by {}: {}",
|
msg.push_str(&format!("\ncrate `{}` compiled by {}: {}",
|
||||||
self.ident,
|
self.crate_name,
|
||||||
got,
|
got,
|
||||||
path.display()));
|
path.display()));
|
||||||
}
|
}
|
||||||
|
@ -405,10 +404,10 @@ impl<'a> Context<'a> {
|
||||||
self.span,
|
self.span,
|
||||||
E0463,
|
E0463,
|
||||||
"can't find crate for `{}`{}",
|
"can't find crate for `{}`{}",
|
||||||
self.ident,
|
self.crate_name,
|
||||||
add);
|
add);
|
||||||
|
|
||||||
if (self.ident == sym::std || self.ident == sym::core)
|
if (self.crate_name == sym::std || self.crate_name == sym::core)
|
||||||
&& self.triple != TargetTriple::from_triple(config::host_triple()) {
|
&& self.triple != TargetTriple::from_triple(config::host_triple()) {
|
||||||
err.note(&format!("the `{}` target may not be installed", self.triple));
|
err.note(&format!("the `{}` target may not be installed", self.triple));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// error-pattern:can't find crate for `extra`
|
// error-pattern:can't find crate for `fake_crate`
|
||||||
|
|
||||||
extern crate fake_crate as extra;
|
extern crate fake_crate as extra;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0463]: can't find crate for `extra`
|
error[E0463]: can't find crate for `fake_crate`
|
||||||
--> $DIR/use-meta-mismatch.rs:3:1
|
--> $DIR/use-meta-mismatch.rs:3:1
|
||||||
|
|
|
|
||||||
LL | extern crate fake_crate as extra;
|
LL | extern crate fake_crate as extra;
|
||||||
|
|
Loading…
Add table
Reference in a new issue