1
Fork 0

Add an explanation for the create_depgraph_edges

This commit is contained in:
Oliver Schneider 2018-03-30 13:57:11 +02:00 committed by GitHub
parent 70c10f1f14
commit 8107b5606d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -529,6 +529,17 @@ pub fn const_eval_provider<'a, 'tcx>(
})
}
// This function creates dep graph edges from statics to all referred to statics.
// This is necessary, because the `const_eval` query cannot directly call itself
// for other statics, because we cannot prevent recursion in queries.
//
// see test/incremental/static_refering_to_other_static2/issue.rs for an example
// where not creating those edges would cause static A, which refers to static B
// to point to the old allocation of static B, even though B has changed.
//
// In the future we will want to remove this funcion in favour of a system that
// makes sure that statics don't need to have edges to other statics as long as
// they are only referring by reference and not inspecting the other static's body.
fn create_depgraph_edges<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
alloc_id: AllocId,
@ -548,4 +559,4 @@ fn create_depgraph_edges<'a, 'tcx>(
}
}
}
}
}