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>(
|
||||
&'b mut self,
|
||||
root: &'b Option<CratePaths>,
|
||||
ident: Symbol,
|
||||
name: Symbol,
|
||||
hash: Option<&'b Svh>,
|
||||
extra_filename: Option<&'b str>,
|
||||
|
@ -345,7 +344,7 @@ impl<'a> CrateLoader<'a> {
|
|||
path_kind: PathKind,
|
||||
mut dep_kind: DepKind,
|
||||
) -> 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) {
|
||||
(LoadResult::Previous(cnum), None)
|
||||
} else {
|
||||
|
@ -353,7 +352,6 @@ impl<'a> CrateLoader<'a> {
|
|||
let mut locate_ctxt = locator::Context {
|
||||
sess: self.sess,
|
||||
span,
|
||||
ident,
|
||||
crate_name: name,
|
||||
hash,
|
||||
extra_filename,
|
||||
|
@ -493,16 +491,15 @@ impl<'a> CrateLoader<'a> {
|
|||
_ => dep.kind,
|
||||
};
|
||||
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,
|
||||
).unwrap_or_else(|err| err.report());
|
||||
local_cnum
|
||||
})).collect()
|
||||
}
|
||||
|
||||
fn read_extension_crate(&mut self, span: Span, orig_name: Symbol, rename: Symbol)
|
||||
-> ExtensionCrate {
|
||||
info!("read extension crate `extern crate {} as {}`", orig_name, rename);
|
||||
fn read_extension_crate(&mut self, name: Symbol, span: Span) -> ExtensionCrate {
|
||||
info!("read extension crate `{}`", name);
|
||||
let target_triple = self.sess.opts.target_triple.clone();
|
||||
let host_triple = TargetTriple::from_triple(config::host_triple());
|
||||
let is_cross = target_triple != host_triple;
|
||||
|
@ -510,8 +507,7 @@ impl<'a> CrateLoader<'a> {
|
|||
let mut locate_ctxt = locator::Context {
|
||||
sess: self.sess,
|
||||
span,
|
||||
ident: orig_name,
|
||||
crate_name: rename,
|
||||
crate_name: name,
|
||||
hash: None,
|
||||
extra_filename: None,
|
||||
filesearch: self.sess.host_filesearch(PathKind::Crate),
|
||||
|
@ -606,7 +602,7 @@ impl<'a> CrateLoader<'a> {
|
|||
span: Span,
|
||||
name: Symbol)
|
||||
-> Option<(PathBuf, CrateDisambiguator)> {
|
||||
let ekrate = self.read_extension_crate(span, name, name);
|
||||
let ekrate = self.read_extension_crate(name, span);
|
||||
|
||||
if ekrate.target_only {
|
||||
// Need to abort before syntax expansion.
|
||||
|
@ -699,7 +695,7 @@ impl<'a> CrateLoader<'a> {
|
|||
|
||||
let dep_kind = DepKind::Implicit;
|
||||
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());
|
||||
|
||||
// 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 dep_kind = DepKind::Explicit;
|
||||
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)
|
||||
.unwrap_or_else(|err| err.report());
|
||||
|
||||
|
@ -831,7 +827,7 @@ impl<'a> CrateLoader<'a> {
|
|||
let symbol = Symbol::intern("profiler_builtins");
|
||||
let dep_kind = DepKind::Implicit;
|
||||
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)
|
||||
.unwrap_or_else(|err| err.report());
|
||||
|
||||
|
@ -1015,7 +1011,7 @@ impl<'a> CrateLoader<'a> {
|
|||
};
|
||||
|
||||
let (cnum, ..) = self.resolve_crate(
|
||||
&None, item.ident.name, orig_name, None, None,
|
||||
&None, orig_name, None, None,
|
||||
item.span, PathKind::Crate, dep_kind,
|
||||
).unwrap_or_else(|err| err.report());
|
||||
|
||||
|
@ -1044,7 +1040,7 @@ impl<'a> CrateLoader<'a> {
|
|||
span: Span,
|
||||
) -> CrateNum {
|
||||
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;
|
||||
|
||||
self.update_extern_crate(
|
||||
|
@ -1068,7 +1064,7 @@ impl<'a> CrateLoader<'a> {
|
|||
span: Span,
|
||||
) -> Option<CrateNum> {
|
||||
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;
|
||||
|
||||
self.update_extern_crate(
|
||||
|
|
|
@ -254,7 +254,6 @@ pub struct CrateMismatch {
|
|||
pub struct Context<'a> {
|
||||
pub sess: &'a Session,
|
||||
pub span: Span,
|
||||
pub ident: Symbol,
|
||||
pub crate_name: Symbol,
|
||||
pub hash: Option<&'a Svh>,
|
||||
pub extra_filename: Option<&'a str>,
|
||||
|
@ -332,12 +331,12 @@ impl<'a> Context<'a> {
|
|||
self.span,
|
||||
E0460,
|
||||
"found possibly newer version of crate `{}`{}",
|
||||
self.ident,
|
||||
self.crate_name,
|
||||
add);
|
||||
err.note("perhaps that crate needs to be recompiled?");
|
||||
let mismatches = self.rejected_via_hash.iter();
|
||||
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 {
|
||||
&None => {}
|
||||
|
@ -355,13 +354,13 @@ impl<'a> Context<'a> {
|
|||
E0461,
|
||||
"couldn't find crate `{}` \
|
||||
with expected target triple {}{}",
|
||||
self.ident,
|
||||
self.crate_name,
|
||||
self.triple,
|
||||
add);
|
||||
let mismatches = self.rejected_via_triple.iter();
|
||||
for &CrateMismatch { ref path, ref got } in mismatches {
|
||||
msg.push_str(&format!("\ncrate `{}`, target triple {}: {}",
|
||||
self.ident,
|
||||
self.crate_name,
|
||||
got,
|
||||
path.display()));
|
||||
}
|
||||
|
@ -372,12 +371,12 @@ impl<'a> Context<'a> {
|
|||
self.span,
|
||||
E0462,
|
||||
"found staticlib `{}` instead of rlib or dylib{}",
|
||||
self.ident,
|
||||
self.crate_name,
|
||||
add);
|
||||
err.help("please recompile that crate using --crate-type lib");
|
||||
let mismatches = self.rejected_via_kind.iter();
|
||||
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
|
||||
|
@ -387,14 +386,14 @@ impl<'a> Context<'a> {
|
|||
E0514,
|
||||
"found crate `{}` compiled by an incompatible version \
|
||||
of rustc{}",
|
||||
self.ident,
|
||||
self.crate_name,
|
||||
add);
|
||||
err.help(&format!("please recompile that crate using this compiler ({})",
|
||||
rustc_version()));
|
||||
let mismatches = self.rejected_via_version.iter();
|
||||
for &CrateMismatch { ref path, ref got } in mismatches {
|
||||
msg.push_str(&format!("\ncrate `{}` compiled by {}: {}",
|
||||
self.ident,
|
||||
self.crate_name,
|
||||
got,
|
||||
path.display()));
|
||||
}
|
||||
|
@ -405,10 +404,10 @@ impl<'a> Context<'a> {
|
|||
self.span,
|
||||
E0463,
|
||||
"can't find crate for `{}`{}",
|
||||
self.ident,
|
||||
self.crate_name,
|
||||
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()) {
|
||||
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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
||||
LL | extern crate fake_crate as extra;
|
||||
|
|
Loading…
Add table
Reference in a new issue