From a5b7e235d3b6e3bb8406d182cc0280de1844c6d9 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 5 Dec 2021 13:08:24 +0100 Subject: [PATCH] Simplify DefIdForest. --- .../rustc_middle/src/ty/inhabitedness/def_id_forest.rs | 8 ++++---- compiler/rustc_middle/src/ty/inhabitedness/mod.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_middle/src/ty/inhabitedness/def_id_forest.rs b/compiler/rustc_middle/src/ty/inhabitedness/def_id_forest.rs index f31c7dd743d..55807874705 100644 --- a/compiler/rustc_middle/src/ty/inhabitedness/def_id_forest.rs +++ b/compiler/rustc_middle/src/ty/inhabitedness/def_id_forest.rs @@ -1,6 +1,6 @@ use crate::ty::context::TyCtxt; use crate::ty::{DefId, DefIdTree}; -use rustc_hir::CRATE_HIR_ID; +use rustc_span::def_id::CRATE_DEF_ID; use smallvec::SmallVec; use std::mem; use std::sync::Arc; @@ -43,8 +43,8 @@ impl<'tcx> DefIdForest { /// Creates a forest consisting of a single tree representing the entire /// crate. #[inline] - pub fn full(tcx: TyCtxt<'tcx>) -> DefIdForest { - DefIdForest::from_id(tcx.hir().local_def_id(CRATE_HIR_ID).to_def_id()) + pub fn full() -> DefIdForest { + DefIdForest::from_id(CRATE_DEF_ID.to_def_id()) } /// Creates a forest containing a `DefId` and all its descendants. @@ -96,7 +96,7 @@ impl<'tcx> DefIdForest { let mut ret: SmallVec<[_; 1]> = if let Some(first) = iter.next() { SmallVec::from_slice(first.as_slice()) } else { - return DefIdForest::full(tcx); + return DefIdForest::full(); }; let mut next_ret: SmallVec<[_; 1]> = SmallVec::new(); diff --git a/compiler/rustc_middle/src/ty/inhabitedness/mod.rs b/compiler/rustc_middle/src/ty/inhabitedness/mod.rs index 77d82ee6eae..167a54e42a0 100644 --- a/compiler/rustc_middle/src/ty/inhabitedness/mod.rs +++ b/compiler/rustc_middle/src/ty/inhabitedness/mod.rs @@ -205,7 +205,7 @@ pub(crate) fn type_uninhabited_from<'tcx>( match *ty.kind() { Adt(def, substs) => def.uninhabited_from(tcx, substs, param_env), - Never => DefIdForest::full(tcx), + Never => DefIdForest::full(), Tuple(ref tys) => DefIdForest::union( tcx,