Skip to content

Commit a5b7e23

Browse files
committed
Simplify DefIdForest.
1 parent c9de7d7 commit a5b7e23

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

compiler/rustc_middle/src/ty/inhabitedness/def_id_forest.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::ty::context::TyCtxt;
22
use crate::ty::{DefId, DefIdTree};
3-
use rustc_hir::CRATE_HIR_ID;
3+
use rustc_span::def_id::CRATE_DEF_ID;
44
use smallvec::SmallVec;
55
use std::mem;
66
use std::sync::Arc;
@@ -43,8 +43,8 @@ impl<'tcx> DefIdForest {
4343
/// Creates a forest consisting of a single tree representing the entire
4444
/// crate.
4545
#[inline]
46-
pub fn full(tcx: TyCtxt<'tcx>) -> DefIdForest {
47-
DefIdForest::from_id(tcx.hir().local_def_id(CRATE_HIR_ID).to_def_id())
46+
pub fn full() -> DefIdForest {
47+
DefIdForest::from_id(CRATE_DEF_ID.to_def_id())
4848
}
4949

5050
/// Creates a forest containing a `DefId` and all its descendants.
@@ -96,7 +96,7 @@ impl<'tcx> DefIdForest {
9696
let mut ret: SmallVec<[_; 1]> = if let Some(first) = iter.next() {
9797
SmallVec::from_slice(first.as_slice())
9898
} else {
99-
return DefIdForest::full(tcx);
99+
return DefIdForest::full();
100100
};
101101

102102
let mut next_ret: SmallVec<[_; 1]> = SmallVec::new();

compiler/rustc_middle/src/ty/inhabitedness/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ pub(crate) fn type_uninhabited_from<'tcx>(
205205
match *ty.kind() {
206206
Adt(def, substs) => def.uninhabited_from(tcx, substs, param_env),
207207

208-
Never => DefIdForest::full(tcx),
208+
Never => DefIdForest::full(),
209209

210210
Tuple(ref tys) => DefIdForest::union(
211211
tcx,

0 commit comments

Comments
 (0)