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:
parent
a933de8398
commit
5b5964f569
50 changed files with 162 additions and 176 deletions
|
@ -377,7 +377,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
) -> PatKind<'tcx> {
|
||||
let res = match res {
|
||||
Res::Def(DefKind::Ctor(CtorOf::Variant, ..), variant_ctor_id) => {
|
||||
let variant_id = self.tcx.parent(variant_ctor_id).unwrap();
|
||||
let variant_id = self.tcx.parent(variant_ctor_id);
|
||||
Res::Def(DefKind::Variant, variant_id)
|
||||
}
|
||||
res => res,
|
||||
|
@ -385,7 +385,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
|
||||
let mut kind = match res {
|
||||
Res::Def(DefKind::Variant, variant_id) => {
|
||||
let enum_id = self.tcx.parent(variant_id).unwrap();
|
||||
let enum_id = self.tcx.parent(variant_id);
|
||||
let adt_def = self.tcx.adt_def(enum_id);
|
||||
if adt_def.is_enum() {
|
||||
let substs = match ty.kind() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue