Delay error reporting of filename mismatch.
When cross compiling with procedural macros, the crate loader starts by looking for a target crate, before trying with a host crate. Rather than emitting an error immediately if the host and target extension differ, the compiler should delay it until both attempts have failed. Fixes #37899 r? @jseyfried
This commit is contained in:
parent
217f57c0b5
commit
2cdde5aef4
@ -344,6 +344,7 @@ fn resolve_crate(&mut self,
|
||||
rejected_via_triple: vec![],
|
||||
rejected_via_kind: vec![],
|
||||
rejected_via_version: vec![],
|
||||
rejected_via_filename: vec![],
|
||||
should_match_name: true,
|
||||
is_proc_macro: Some(false),
|
||||
};
|
||||
@ -359,6 +360,7 @@ fn resolve_crate(&mut self,
|
||||
rejected_via_triple: vec![],
|
||||
rejected_via_kind: vec![],
|
||||
rejected_via_version: vec![],
|
||||
rejected_via_filename: vec![],
|
||||
is_proc_macro: Some(true),
|
||||
..locate_ctxt
|
||||
};
|
||||
@ -502,6 +504,7 @@ fn read_extension_crate(&mut self, span: Span, info: &ExternCrateInfo) -> Extens
|
||||
rejected_via_triple: vec![],
|
||||
rejected_via_kind: vec![],
|
||||
rejected_via_version: vec![],
|
||||
rejected_via_filename: vec![],
|
||||
should_match_name: true,
|
||||
is_proc_macro: None,
|
||||
};
|
||||
|
@ -269,6 +269,7 @@ pub struct Context<'a> {
|
||||
pub rejected_via_triple: Vec<CrateMismatch>,
|
||||
pub rejected_via_kind: Vec<CrateMismatch>,
|
||||
pub rejected_via_version: Vec<CrateMismatch>,
|
||||
pub rejected_via_filename: Vec<CrateMismatch>,
|
||||
pub should_match_name: bool,
|
||||
pub is_proc_macro: Option<bool>,
|
||||
}
|
||||
@ -417,6 +418,18 @@ pub fn report_errs(&mut self) -> ! {
|
||||
got));
|
||||
}
|
||||
}
|
||||
if !self.rejected_via_filename.is_empty() {
|
||||
let dylibname = self.dylibname();
|
||||
let mismatches = self.rejected_via_filename.iter();
|
||||
for &CrateMismatch { ref path, .. } in mismatches {
|
||||
err.note(&format!("extern location for {} is of an unknown type: {}",
|
||||
self.crate_name,
|
||||
path.display()))
|
||||
.help(&format!("file name should be lib*.rlib or {}*.{}",
|
||||
dylibname.0,
|
||||
dylibname.1));
|
||||
}
|
||||
}
|
||||
|
||||
err.emit();
|
||||
self.sess.abort_if_errors();
|
||||
@ -743,13 +756,12 @@ fn find_commandline_library<'b, LOCS>(&mut self, locs: LOCS) -> Option<Library>
|
||||
return true;
|
||||
}
|
||||
}
|
||||
sess.struct_err(&format!("extern location for {} is of an unknown type: {}",
|
||||
self.crate_name,
|
||||
loc.display()))
|
||||
.help(&format!("file name should be lib*.rlib or {}*.{}",
|
||||
dylibname.0,
|
||||
dylibname.1))
|
||||
.emit();
|
||||
|
||||
self.rejected_via_filename.push(CrateMismatch {
|
||||
path: loc.clone(),
|
||||
got: String::new(),
|
||||
});
|
||||
|
||||
false
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user