rustc: Panic by default in DefIdTree::parent
Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root. So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root. Same applies to `local_parent`/`opt_local_parent`.
This commit is contained in:
@@ -1906,7 +1906,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
GeneratorKind::Async(AsyncGeneratorKind::Fn) => self
|
||||
.tcx
|
||||
.parent(generator_did)
|
||||
.and_then(|parent_did| parent_did.as_local())
|
||||
.as_local()
|
||||
.map(|parent_did| hir.local_def_id_to_hir_id(parent_did))
|
||||
.and_then(|parent_hir_id| hir.opt_name(parent_hir_id))
|
||||
.map(|name| {
|
||||
|
||||
Reference in New Issue
Block a user