Less manipulation of the callee_def_id.
This commit is contained in:
parent
2d3d9b26a4
commit
297dde9b1a
1 changed files with 6 additions and 5 deletions
|
@ -176,7 +176,8 @@ impl<'tcx> Inliner<'tcx> {
|
||||||
callee: &Instance<'tcx>,
|
callee: &Instance<'tcx>,
|
||||||
) -> Result<(), &'static str> {
|
) -> Result<(), &'static str> {
|
||||||
let caller_def_id = caller_body.source.def_id();
|
let caller_def_id = caller_body.source.def_id();
|
||||||
if callee.def_id() == caller_def_id {
|
let callee_def_id = callee.def_id();
|
||||||
|
if callee_def_id == caller_def_id {
|
||||||
return Err("self-recursion");
|
return Err("self-recursion");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +186,7 @@ impl<'tcx> Inliner<'tcx> {
|
||||||
// If there is no MIR available (either because it was not in metadata or
|
// If there is no MIR available (either because it was not in metadata or
|
||||||
// because it has no MIR because it's an extern function), then the inliner
|
// because it has no MIR because it's an extern function), then the inliner
|
||||||
// won't cause cycles on this.
|
// won't cause cycles on this.
|
||||||
if !self.tcx.is_mir_available(callee.def_id()) {
|
if !self.tcx.is_mir_available(callee_def_id) {
|
||||||
return Err("item MIR unavailable");
|
return Err("item MIR unavailable");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,19 +206,19 @@ impl<'tcx> Inliner<'tcx> {
|
||||||
| InstanceDef::CloneShim(..) => return Ok(()),
|
| InstanceDef::CloneShim(..) => return Ok(()),
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.tcx.is_constructor(callee.def_id()) {
|
if self.tcx.is_constructor(callee_def_id) {
|
||||||
trace!("constructors always have MIR");
|
trace!("constructors always have MIR");
|
||||||
// Constructor functions cannot cause a query cycle.
|
// Constructor functions cannot cause a query cycle.
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(callee_def_id) = callee.def_id().as_local() {
|
if callee_def_id.is_local() {
|
||||||
// Avoid a cycle here by only using `instance_mir` only if we have
|
// Avoid a cycle here by only using `instance_mir` only if we have
|
||||||
// a lower `DefPathHash` than the callee. This ensures that the callee will
|
// a lower `DefPathHash` than the callee. This ensures that the callee will
|
||||||
// not inline us. This trick even works with incremental compilation,
|
// not inline us. This trick even works with incremental compilation,
|
||||||
// since `DefPathHash` is stable.
|
// since `DefPathHash` is stable.
|
||||||
if self.tcx.def_path_hash(caller_def_id).local_hash()
|
if self.tcx.def_path_hash(caller_def_id).local_hash()
|
||||||
< self.tcx.def_path_hash(callee_def_id.to_def_id()).local_hash()
|
< self.tcx.def_path_hash(callee_def_id).local_hash()
|
||||||
{
|
{
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue