Skip to content

Commit

Permalink
Simplify DefIdForest.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Jan 15, 2022
1 parent c9de7d7 commit a5b7e23
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions 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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/inhabitedness/mod.rs
Expand Up @@ -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,
Expand Down

0 comments on commit a5b7e23

Please sign in to comment.